Copy files from datasets/ParityLab/Hand-Datasets
Browse files- RHD/raw/data/RHD_v1-1.zip +3 -0
- RHD/raw/doc/README.md +121 -0
- RHD/raw/doc/SOURCES.md +7 -0
- RHD/raw/doc/dataset_README.txt +71 -0
- RHD/raw/script/create_binary_db.py +118 -0
RHD/raw/data/RHD_v1-1.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e04310f19ccb0429c999efaf2a1e2a2b046f3024cada6794585a08fb92fb876f
|
| 3 |
+
size 7080690299
|
RHD/raw/doc/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ColorHandPose3D network
|
| 2 |
+
|
| 3 |
+

|
| 4 |
+
|
| 5 |
+
ColorHandPose3D is a Convolutional Neural Network estimating 3D Hand Pose from a single RGB Image. See the [project page](https://lmb.informatik.uni-freiburg.de/projects/hand3d/) for the dataset used and additional information.
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
## Usage: Forward pass
|
| 9 |
+
The network ships with a minimal example, that performs a forward pass and shows the predictions.
|
| 10 |
+
|
| 11 |
+
- Download [data](https://lmb.informatik.uni-freiburg.de/projects/hand3d/ColorHandPose3D_data_v3.zip) and unzip it into the projects root folder (This will create 3 folders: "data", "results" and "weights")
|
| 12 |
+
- *run.py* - Will run a forward pass of the network on the provided examples
|
| 13 |
+
|
| 14 |
+
You can compare your results to the content of the folder "results", which shows the predictions we get on our system.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
## Recommended system
|
| 18 |
+
Recommended system (tested):
|
| 19 |
+
- Ubuntu 16.04.2 (xenial)
|
| 20 |
+
- Tensorflow 1.3.0 GPU build with CUDA 8.0.44 and CUDNN 5.1
|
| 21 |
+
- Python 3.5.2
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Python packages used by the example provided and their recommended version:
|
| 25 |
+
- tensorflow==1.3.0
|
| 26 |
+
- numpy==1.13.0
|
| 27 |
+
- scipy==0.18.1
|
| 28 |
+
- matplotlib==1.5.3
|
| 29 |
+
|
| 30 |
+
## Preprocessing for training and evaluation
|
| 31 |
+
In order to use the training and evaluation scripts you need download and preprocess the datasets.
|
| 32 |
+
|
| 33 |
+
### Rendered Hand Pose Dataset (RHD)
|
| 34 |
+
|
| 35 |
+
- Download the dataset accompanying this publication [RHD dataset v. 1.1](https://lmb.informatik.uni-freiburg.de/resources/datasets/RenderedHandposeDataset.en.html)
|
| 36 |
+
- Set the variable 'path_to_db' to where the dataset is located on your machine
|
| 37 |
+
- Optionally modify 'set' variable to training or evaluation
|
| 38 |
+
- Run
|
| 39 |
+
|
| 40 |
+
python3.5 create_binary_db.py
|
| 41 |
+
- This will create a binary file in *./data/bin* according to how 'set' was configured
|
| 42 |
+
|
| 43 |
+
### Stereo Tracking Benchmark Dataset (STB)
|
| 44 |
+
- For eval3d_full.py it is necessary to get the dataset presented in Zhang et al., ‘3d Hand Pose Tracking and Estimation Using Stereo Matching’, 2016
|
| 45 |
+
- After unzipping the dataset run
|
| 46 |
+
|
| 47 |
+
cd ./data/stb/
|
| 48 |
+
matlab -nodesktop -nosplash -r "create_db"
|
| 49 |
+
- This will create the binary file *./data/stb/stb_evaluation.bin*
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
## Network training
|
| 53 |
+
We provide scripts to train HandSegNet and PoseNet on the [Rendered Hand Pose Dataset (RHD)](https://lmb.informatik.uni-freiburg.de/resources/datasets/RenderedHandposeDataset.en.html).
|
| 54 |
+
In case you want to retrain the networks on new data you can adapt the code provided to your needs.
|
| 55 |
+
|
| 56 |
+
The following steps guide you through training HandSegNet and PoseNet on the Rendered Hand Pose Dataset (RHD).
|
| 57 |
+
|
| 58 |
+
- Make sure you followed the steps in the section 'Preprocessing'
|
| 59 |
+
- Start training of HandSegNet with training_handsegnet.py
|
| 60 |
+
- Start training of PoseNet with training_posenet.py
|
| 61 |
+
- Set USE_RETRAINED = True on line 32 in eval2d_gt_cropped.py
|
| 62 |
+
- Run eval2d_gt_cropped.py to evaluate the retrained PoseNet on RHD-e
|
| 63 |
+
- Set USE_RETRAINED = True on line 31 in eval2d.py
|
| 64 |
+
- Run eval2d.py to evaluate the retrained HandSegNet + PoseNet on RHD-e
|
| 65 |
+
|
| 66 |
+
You should be able to obtain results that roughly match the following numbers we obtain with Tensorflow v1.3:
|
| 67 |
+
|
| 68 |
+
eval2d_gt_cropped.py yields:
|
| 69 |
+
|
| 70 |
+
Evaluation results:
|
| 71 |
+
Average mean EPE: 7.630 pixels
|
| 72 |
+
Average median EPE: 3.939 pixels
|
| 73 |
+
Area under curve: 0.771
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
eval2d.py yields:
|
| 77 |
+
|
| 78 |
+
Evaluation results:
|
| 79 |
+
Average mean EPE: 15.469 pixels
|
| 80 |
+
Average median EPE: 4.374 pixels
|
| 81 |
+
Area under curve: 0.715
|
| 82 |
+
|
| 83 |
+
Because training itself isn't a deterministic process results will differ between runs.
|
| 84 |
+
Note that these results are not listed in the paper.
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
## Evaluation
|
| 89 |
+
|
| 90 |
+
There are four scripts that evaluate different parts of the architecture:
|
| 91 |
+
|
| 92 |
+
1. eval2d_gt_cropped.py: Evaluates PoseNet on 2D keypoint localization using ground truth annoation to create hand cropped images (section 6.1, Table 1 of the paper)
|
| 93 |
+
2. eval2d.py: Evaluates HandSegNet and PoseNet on 2D keypoint localization (section 6.1, Table 1 of the paper)
|
| 94 |
+
3. eval3d.py: Evaluates different approaches on lifting 2D predictions into 3D (section 6.2.1, Table 2 of the paper)
|
| 95 |
+
3. eval3d_full.py: Evaluates our full pipeline on 3D keypoint localization from RGB (section 6.2.1, Table 2 of the paper)
|
| 96 |
+
|
| 97 |
+
This provides the possibility to reproduce results from the paper that are based on the RHD dataset.
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
## License and Citation
|
| 101 |
+
This project is licensed under the terms of the GPL v2 license. By using the software, you are agreeing to the terms of the [license agreement](https://github.com/lmb-freiburg/hand3d/blob/master/LICENSE).
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
Please cite us in your publications if it helps your research:
|
| 105 |
+
|
| 106 |
+
@InProceedings{zb2017hand,
|
| 107 |
+
author = {Christian Zimmermann and Thomas Brox},
|
| 108 |
+
title = {Learning to Estimate 3D Hand Pose from Single RGB Images},
|
| 109 |
+
booktitle = "IEEE International Conference on Computer Vision (ICCV)",
|
| 110 |
+
year = {2017},
|
| 111 |
+
note = "https://arxiv.org/abs/1705.01389",
|
| 112 |
+
url = "https://lmb.informatik.uni-freiburg.de/projects/hand3d/"
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
## Known issues
|
| 118 |
+
|
| 119 |
+
- There is an issue with the results of section 6.1, Table 1 that reports performance of 2D keypoint localization on full scale images (eval2d.py). PoseNet was trained to predict the "palm center", but the evaluation script compares to the "wrist". This results into an systematic error and therefore the reported results are significantly worse than under a correct evaluation setting. Using the correct setting during evaluation improves results approximately by 2-10% (dependent on the measure).
|
| 120 |
+
- The numbers reported for the "Bottleneck" approach in Table 2 of the paper are not correct. The actual result are approx. 8 % worse.
|
| 121 |
+
- There is a minor issue with the first version of RHD. There was a rounding/casting problem, which led to values of the images to be off by one every now and then compared to the version used in the paper. The difference is visually not noticable and not large, but it prevents from reaching the reported numbers exactly.
|
RHD/raw/doc/SOURCES.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RHD 原始包来源
|
| 2 |
+
|
| 3 |
+
本包复用本地此前从官方获取的完整 ZIP,未解压。官方项目:https://github.com/lmb-freiburg/hand3d 。
|
| 4 |
+
|
| 5 |
+
文件:`RHD_v1-1.zip`;大小:7080690299 字节;SHA256:`e04310f19ccb0429c999efaf2a1e2a2b046f3024cada6794585a08fb92fb876f`。该摘要与本地下载回执一致,不宣称为官方独立发布的摘要。
|
| 6 |
+
|
| 7 |
+
下一步:小规模真实转换与本地人工核验;本次仅准备 raw。
|
RHD/raw/doc/dataset_README.txt
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--------------------------
|
| 2 |
+
RENDERED HAND POSE DATASET - version 1.1
|
| 3 |
+
--------------------------
|
| 4 |
+
|
| 5 |
+
_______
|
| 6 |
+
LICENCE
|
| 7 |
+
This dataset is provided for research purposes only and without any warranty. Any commercial use is prohibited. If you use the dataset or parts of it in your research, you must cite the respective paper.
|
| 8 |
+
|
| 9 |
+
@InProceedings{zb2017hand,
|
| 10 |
+
author = {Christian Zimmermann and Thomas Brox},
|
| 11 |
+
title = {Learning to Estimate 3D Hand Pose from Single RGB Images},
|
| 12 |
+
booktitle = "IEEE International Conference on Computer Vision (ICCV)",
|
| 13 |
+
year = {2017},
|
| 14 |
+
note = "https://arxiv.org/abs/1705.01389",
|
| 15 |
+
url = "https://lmb.informatik.uni-freiburg.de/projects/hand3d/"
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
_______
|
| 19 |
+
CONTENT
|
| 20 |
+
|
| 21 |
+
This dataset provides 41258 training and 2728 testing samples. Each sample provides:
|
| 22 |
+
- RGB image (320x320 pixels)
|
| 23 |
+
- Depth map (320x320 pixels); See examples for how to convert the provided RGB
|
| 24 |
+
- Segmentation masks (320x320 pixels) for the following classes: background, person, three classes for each finger and one for each palm
|
| 25 |
+
- 21 Keypoints for each hand with their uv coordinates in the image frame, xyz coordinates in the world frame and an indicator if they are visible
|
| 26 |
+
- Intrinsic Camera Matrix K
|
| 27 |
+
It was created with freely available character from www.mixamo.com and rendered with www.blender.org
|
| 28 |
+
For more details see the aforementioned paper.
|
| 29 |
+
|
| 30 |
+
Keypoints available:
|
| 31 |
+
0: left wrist, 1-4: left thumb [tip to palm], 5-8: left index, ..., 17-20: left pinky,
|
| 32 |
+
21: right wrist, 22-25: right thumb, ..., 38-41: right pinky
|
| 33 |
+
|
| 34 |
+
Segmentation masks available:
|
| 35 |
+
0: background, 1: person,
|
| 36 |
+
2-4: left thumb [tip to palm], 5-7: left index, ..., 14-16: left pinky, 17: palm,
|
| 37 |
+
18-20: right thumb, ..., right palm: 33
|
| 38 |
+
|
| 39 |
+
_______
|
| 40 |
+
HOW TO USE
|
| 41 |
+
|
| 42 |
+
The dataset ships with minimal examples, that browse the dataset and show samples.
|
| 43 |
+
There is one example for Phython and one for MATLAB users; Their functionality is identical.
|
| 44 |
+
Both files are located in the root folder.
|
| 45 |
+
|
| 46 |
+
_______
|
| 47 |
+
STRUCTURE
|
| 48 |
+
|
| 49 |
+
./ : Root folder
|
| 50 |
+
./view_samples.m : Script that shows basic use of the data for MATLAB
|
| 51 |
+
./view_samples.py : Script that shows basic use of the data for Python
|
| 52 |
+
./evaluation/ : Contains the split used for evaluation of our algorithm
|
| 53 |
+
./evaluation/anno_training.mat : Data structure for MATLAB use containing keypoint annotations and camera matrices K
|
| 54 |
+
./evaluation/anno_training.pickle : Data structure for Python use containing keypoint annotations and camera matrices K
|
| 55 |
+
./evaluation/color/ : Color images
|
| 56 |
+
./evaluation/depth/ : 16bit Depth maps, where the 8 top bits are stored in red and the lower 8 bits are stored in green channel
|
| 57 |
+
./evaluation/mask/ : Segmentation masks
|
| 58 |
+
./training/ : Contains the split used for training of our algorithm (subfolders identical to ./evaluation/)
|
| 59 |
+
|
| 60 |
+
_______
|
| 61 |
+
CHANGELOG
|
| 62 |
+
|
| 63 |
+
version 1.1
|
| 64 |
+
- There was a rounding/casting problem, which led to values of the images to be off by one every now and then compared to the version used in the paper. The difference is visually not noticable and not large, but it prevents from reaching the reported numbers exactly.
|
| 65 |
+
- There were two minor bugs in view_samples.m. Thank you Franziska Mueller for reporting them.
|
| 66 |
+
|
| 67 |
+
_______
|
| 68 |
+
CONTACT
|
| 69 |
+
|
| 70 |
+
For questions about the dataset please contact Christian Zimmermann (zimmermann@cs.uni-freiburg.de)
|
| 71 |
+
|
RHD/raw/script/create_binary_db.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# ColorHandPose3DNetwork - Network for estimating 3D Hand Pose from a single RGB Image
|
| 3 |
+
# Copyright (C) 2017 Christian Zimmermann
|
| 4 |
+
#
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 2 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 17 |
+
#
|
| 18 |
+
"""
|
| 19 |
+
Script to convert Rendered Handpose Dataset into binary files,
|
| 20 |
+
which allows for much faster reading than plain image files.
|
| 21 |
+
|
| 22 |
+
Set "path_to_db" and "set" accordingly.
|
| 23 |
+
|
| 24 |
+
In order to use this file you need to download and unzip the dataset first.
|
| 25 |
+
"""
|
| 26 |
+
from __future__ import print_function, unicode_literals
|
| 27 |
+
|
| 28 |
+
import pickle
|
| 29 |
+
import os
|
| 30 |
+
import scipy.misc
|
| 31 |
+
import struct
|
| 32 |
+
|
| 33 |
+
# SET THIS to where RHD is located on your machine
|
| 34 |
+
path_to_db = './RHD_published_v2/'
|
| 35 |
+
|
| 36 |
+
# chose if you want to create a binary for training or evaluation set
|
| 37 |
+
# set = 'training'
|
| 38 |
+
set = 'evaluation'
|
| 39 |
+
|
| 40 |
+
### No more changes below this line ###
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# function to write the binary file
|
| 44 |
+
def write_to_binary(file_handle, image, mask, kp_coord_xyz, kp_coord_uv, kp_visible, K_mat):
|
| 45 |
+
"""" Writes records to an open binary file. """
|
| 46 |
+
bytes_written = 0
|
| 47 |
+
# 1. write kp_coord_xyz
|
| 48 |
+
for coord in kp_coord_xyz:
|
| 49 |
+
file_handle.write(struct.pack('f', coord[0]))
|
| 50 |
+
file_handle.write(struct.pack('f', coord[1]))
|
| 51 |
+
file_handle.write(struct.pack('f', coord[2]))
|
| 52 |
+
bytes_written += 4*kp_coord_xyz.shape[0]*kp_coord_xyz.shape[1]
|
| 53 |
+
|
| 54 |
+
# 2. write kp_coord_uv
|
| 55 |
+
for coord in kp_coord_uv:
|
| 56 |
+
file_handle.write(struct.pack('f', coord[0]))
|
| 57 |
+
file_handle.write(struct.pack('f', coord[1]))
|
| 58 |
+
bytes_written += 4*kp_coord_uv.shape[0]*kp_coord_uv.shape[1]
|
| 59 |
+
|
| 60 |
+
# 3. write camera intrinsic matrix
|
| 61 |
+
for K_row in K_mat:
|
| 62 |
+
for K_element in K_row:
|
| 63 |
+
file_handle.write(struct.pack('f', K_element))
|
| 64 |
+
bytes_written += 4*9
|
| 65 |
+
|
| 66 |
+
file_handle.write(struct.pack('B', 255))
|
| 67 |
+
file_handle.write(struct.pack('B', 255))
|
| 68 |
+
bytes_written += 2
|
| 69 |
+
|
| 70 |
+
# 4. write image
|
| 71 |
+
for x in range(image.shape[0]):
|
| 72 |
+
for y in range(image.shape[1]):
|
| 73 |
+
file_handle.write(struct.pack('B', image[x, y, 0]))
|
| 74 |
+
file_handle.write(struct.pack('B', image[x, y, 1]))
|
| 75 |
+
file_handle.write(struct.pack('B', image[x, y, 2]))
|
| 76 |
+
bytes_written += 4*image.shape[0]*image.shape[1]*image.shape[2]
|
| 77 |
+
|
| 78 |
+
# 5. write mask
|
| 79 |
+
for x in range(mask.shape[0]):
|
| 80 |
+
for y in range(mask.shape[1]):
|
| 81 |
+
file_handle.write(struct.pack('B', mask[x, y]))
|
| 82 |
+
bytes_written += 4*mask.shape[0]*mask.shape[1]
|
| 83 |
+
|
| 84 |
+
# 6. write visibility
|
| 85 |
+
for x in range(kp_visible.shape[0]):
|
| 86 |
+
file_handle.write(struct.pack('B', kp_visible[x]))
|
| 87 |
+
bytes_written += kp_visible.shape[0]
|
| 88 |
+
|
| 89 |
+
# print('bytes_written', bytes_written)
|
| 90 |
+
|
| 91 |
+
# binary file we will write
|
| 92 |
+
file_name_out = './data/bin/rhd_%s.bin' % set
|
| 93 |
+
|
| 94 |
+
if not os.path.exists('./data/bin'):
|
| 95 |
+
os.mkdir('./data/bin')
|
| 96 |
+
|
| 97 |
+
# load annotations of this set
|
| 98 |
+
with open(os.path.join(path_to_db, set, 'anno_%s.pickle' % set), 'rb') as fi:
|
| 99 |
+
anno_all = pickle.load(fi)
|
| 100 |
+
|
| 101 |
+
# iterate samples of the set and write to binary file
|
| 102 |
+
with open(file_name_out, 'wb') as fo:
|
| 103 |
+
num_samples = len(anno_all.items())
|
| 104 |
+
for sample_id, anno in anno_all.items():
|
| 105 |
+
# load data
|
| 106 |
+
image = scipy.misc.imread(os.path.join(path_to_db, set, 'color', '%.5d.png' % sample_id))
|
| 107 |
+
mask = scipy.misc.imread(os.path.join(path_to_db, set, 'mask', '%.5d.png' % sample_id))
|
| 108 |
+
|
| 109 |
+
# get info from annotation dictionary
|
| 110 |
+
kp_coord_uv = anno['uv_vis'][:, :2] # u, v coordinates of 42 hand keypoints, pixel
|
| 111 |
+
kp_visible = anno['uv_vis'][:, 2] == 1 # visibility of the keypoints, boolean
|
| 112 |
+
kp_coord_xyz = anno['xyz'] # x, y, z coordinates of the keypoints, in meters
|
| 113 |
+
camera_intrinsic_matrix = anno['K'] # matrix containing intrinsic parameters
|
| 114 |
+
|
| 115 |
+
write_to_binary(fo, image, mask, kp_coord_xyz, kp_coord_uv, kp_visible, camera_intrinsic_matrix)
|
| 116 |
+
|
| 117 |
+
if (sample_id % 100) == 0:
|
| 118 |
+
print('%d / %d images done: %.3f percent' % (sample_id, num_samples, sample_id*100.0/num_samples))
|