Skip to content

Commit 56ac91f

Browse files
3D reconstruction demo with hands & faces
1 parent 6fd758c commit 56ac91f

File tree

18 files changed

+501
-436
lines changed

18 files changed

+501
-436
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ The pose estimation work is based on the C++ code from [the ECCV 2016 demo](http
4949

5050
## Operating Systems
5151
1. **Ubuntu** 14 and 16.
52-
2. **Windows** 10.
53-
3. Other people have been able to install it on **Windows 7 and 8**, **Mac**, **CentOS**, and **Nvidia Jetson (TK1 and TX1)** embedded systems. However, we do not officially support them at the moment.
52+
2. **Windows** 8 and 10.
53+
3. OpenPose has also been used on **Windows 7**, **Mac**, **CentOS**, and **Nvidia Jetson (TK1 and TX1)** embedded systems. However, we do not officially support them at the moment.
5454

5555

5656

doc/installation.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ You just need to remove the OpenPose or portable demo folder.
131131
132132
133133
## OpenPose 3D Demo
134-
This is a beta version that makes body pose 3-D reconstruction and rendering. We will not keep updating it nor solving questions/issues about it at the moment. It requires the user to be familiar with camera calibration, i.e. extraction of intrinsic and extrinsic parameters. The Windows steps were tested and worked in the OpenPose 1.0.1 version from the first GitHub commit on July 17th, 2017 in the [oficial repository](https://github.com/CMU-Perceptual-Computing-Lab/openpose).
135-
136-
If you still wanna try our OpenPose 3-D reconstruction demo, see [doc/openpose_3d_reconstruction_demo.md](./openpose_3d_reconstruction_demo.md).
137-
134+
If you want to try our OpenPose 3-D reconstruction demo, see [doc/openpose_3d_reconstruction_demo.md](./openpose_3d_reconstruction_demo.md).
138135
139136
140137
@@ -205,6 +202,23 @@ windows\x64\Release\OpenPoseDemo.exe --image_dir examples\media\ --face --hand
205202
206203
207204
205+
**4. Maximum Accuracy Configuration**
206+
207+
This command provides the most accurate results we have been able to achieve for body, hand and face keypoint detection. However, this command will need around 8 GB of GPU memory and runs around 1 FPS on a Titan X.
208+
```
209+
# Ubuntu
210+
./build/examples/openpose/openpose.bin --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25 --hand --hand_scale_number 6 --hand_scale_range 0.4 --face
211+
```
212+
```
213+
:: Windows - Demo
214+
bin\OpenPoseDemo.exe --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25 --hand --hand_scale_number 6 --hand_scale_range 0.4 --face
215+
```
216+
:: Windows - Library
217+
windows\x64\Release\OpenPoseDemo.exe --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25 --hand --hand_scale_number 6 --hand_scale_range 0.4 --face
218+
```
219+
220+
221+
208222

209223

210224
## Expected Visual Results

doc/openpose_3d_reconstruction_demo.md

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
# Running OpenPose 3-D Reconstruction Demo - Windows
2-
This is a beta version that makes body pose 3-D reconstruction and rendering. We will not keep updating it nor solving questions/issues about it at the moment. It requires the user to be familiar with computer vision, in particular with camera calibration, i.e. extraction of intrinsic and extrinsic parameters.
1+
Running OpenPose 3-D Reconstruction Demo
2+
====================================
33

4-
The Windows steps were tested and worked in the OpenPose 1.0.1 version from the last GitHub commit on July 7th, 2017 in the [oficial repository](https://github.com/CMU-Perceptual-Computing-Lab/openpose).
4+
This is a beta version that makes body + face + hand keypoint 3-D reconstruction and rendering for 1 person. We will not keep updating it nor solving questions/issues about it at the moment. It requires the user to be familiar with computer vision, in particular with camera calibration, i.e. extraction of intrinsic and extrinsic parameters.
5+
6+
The Windows steps were tested and worked in the OpenPose 1.0.1 version from the last GitHub commit on July 18th, 2017 in the [official repository](https://github.com/CMU-Perceptual-Computing-Lab/openpose).
7+
8+
9+
10+
### Description of this demo:
11+
- Auto detection of all the FLIR cameras, and extraction of images from each one of them.
12+
- Hardware trigger and buffer `NewestFirstOverwrite` modes enabled. Hence, the algorithm will always get the last synchronized frame from each camera, deleting the rest.
13+
- 3-D reconstruction of body, face and hands for 1 person.
14+
- If more than 1 person is detected per camera, the algorithm will just try to match person 0 on each camera, which will potentially correspond to different people in the scene. Thus, the 3-D reconstruction will completely fail.
15+
- Only points with high threshold with respect to each one of the cameras are reprojected (and later rendered). An alternative for > 4 cameras could be to do 3-D reprojection and render all points with good views in more than N different cameras (not implemented here).
16+
- Only Direct linear transformation (DLT) applied. Non-linear optimization methods (e.g. from Ceres Solver) will potentially improve results (not implemented).
17+
- Basic OpenGL rendering with the `freeglut` library.
518

619

720

821
### Hardware
9-
This demo assumes 3 stereo cameras, FLIR company (former Point Grey). Ideally any USB-3 FLIR model should work, but we have only used the following specific specifications:
22+
This demo assumes n arbitrary stereo cameras, FLIR company (former Point Grey). Ideally any USB-3 FLIR model should work, but we have only used the following specific specifications:
1023

1124
1. Camera details:
1225
- Blackfly S Color 1.3 MP USB3 Vision (ON Semi PYTHON 1300)
@@ -26,7 +39,7 @@ This demo assumes 3 stereo cameras, FLIR company (former Point Grey). Ideally an
2639

2740

2841
### Calibrate Cameras
29-
You must manually get the intrinsic and extrinsic parameters of your cameras and introduce them on: `openpose3d\cameraParameters.hpp`. We used the 8-distortion-parameter version of OpenCV.
42+
You must manually get the intrinsic and extrinsic parameters of your cameras and introduce them on: `openpose3d\cameraParameters.hpp`. We used the 8-distortion-parameter version of OpenCV. By default, the program uses 3 cameras, but you can add or remove cameras from `cameraParameters.hpp` by adding or removing elements to `INTRINSICS`, `DISTORTIONS` and `M_EACH_CAMERA`. `INTRINSICS` corresponds to the intrinsic parameters, `DISTORTIONS` to the distortion coefficients, and `M_EACH_CAMERA` corresponds to the extrinsic parameters of the cameras with respect to camera 1 as origin.
3043

3144

3245

@@ -49,13 +62,51 @@ You must manually get the intrinsic and extrinsic parameters of your cameras and
4962

5063

5164
### Ubuntu
52-
We do not support Ubuntu at all for this demo. We did an original and very initial version long ago, but it was highly changed later. In case you need Ubuntu, these are the steps we used for our that original version in Ubuntu 16. Note that they might be several differences to make it work in the current version. Feel free to send us or make a pull request with the updated steps and we will update them, but we will not answer any kind of questions about it.
53-
54-
1. `sudo apt-get install freeglut3-dev`.
55-
2. Compile OpenPose by your own [from https://github.com/CMU-Perceptual-Computing-Lab/openpose](from https://github.com/CMU-Perceptual-Computing-Lab/openpose).
56-
3. Perform `make distribute` on OpenPose, and copy the `include` and `lib` files in [3rdparty/openpose/](3rdparty/openpose/).
57-
4. Copy the `include` and `lib` folders from {OpenPose path}/3rdparty/caffe/distribute/ to [3rdparty/caffe/](3rdparty/caffe/).
58-
5. Copy your Spinnaker desired version `include` and `lib` folders on [3rdparty/spinnaker/](3rdparty/spinnaker/).
59-
6. Open the [rtstereo.pro](rtstereo.pro) file with Qt to have the project ready-to-compile-and-go. If you prefer using your own Makefile file, you can take a look to this Qt file to know which files (basically [src/](src/) and [include/](include/)) and compiler flags used.
60-
1. If using Qt, you will have to manually copy the {OpenPose path}/models folder inside the generated build folder.
61-
7. You must copy the contents of [add_to_bin_file/](add_to_bin_file/) where the final binary file is generated.
65+
We did not create an Ubuntu version. We did an very first version for Ubuntu 16 long ago, but it was highly changed later. These are the steps we used for that one. Note that there might be needed some changes to make it work. Feel free to send us or make a pull request with any updated steps.
66+
67+
1. Install the OpenGL rendering library: `sudo apt-get install freeglut3-dev`.
68+
2. Compile the standard OpenPose [from https://github.com/CMU-Perceptual-Computing-Lab/openpose](from https://github.com/CMU-Perceptual-Computing-Lab/openpose).
69+
3. Perform `make distribute` on OpenPose, and copy the `include` and `lib` files from `distribute` into your custom `3rdparty/openpose/`.
70+
4. Copy the `include` and `lib` folders from {OpenPose path}/3rdparty/caffe/distribute/ into your custom `3rdparty/caffe/`.
71+
5. Copy your Spinnaker desired version `include` and `lib` folders in your custom `3rdparty/spinnaker/`.
72+
7. From the Spinnaker `bin` folder, copy all the *.xml files to the generated build folder of your project.
73+
8. Get the required files from the `include` and `src` folders placed in `{OpenPose path}/windows/OpenPose3DReconstruction/`. Check the Windows VS solution for more details.
74+
9. Create a proper Makefile or CMake file to run it. The following code is part of an old QMake (Qt) file generated for the old version, you can ideally get all the flags and includes from it:
75+
```
76+
DEFINES += USE_CAFFE USE_CUDNN
77+
INCLUDEPATH += \
78+
$$PWD/include \
79+
$$PWD/3rdparty/caffe/include \
80+
$$PWD/3rdparty/openpose/include \
81+
$$PWD/3rdparty/spinnaker/include \
82+
/usr/include \
83+
/usr/local/include \
84+
/usr/local/cuda-8.0/include
85+
}
86+
# Generic
87+
LIBS += -L/usr/lib/ -L/usr/local/lib/ -L/usr/lib/x86_64-linux-gnu
88+
# OpenPose
89+
LIBS += -Wl,-rpath=$$PWD/3rdparty/openpose/lib
90+
LIBS += -Wl,-Bdynamic -L$$PWD/3rdparty/openpose/lib/ -lopenpose
91+
# Caffe
92+
LIBS += -Wl,-rpath=$$PWD/3rdparty/caffe/lib
93+
LIBS += -Wl,-Bdynamic -L$$PWD/3rdparty/caffe/lib/ -lcaffe
94+
# Spinnaker
95+
LIBS += -Wl,-rpath=$$PWD/3rdparty/spinnaker/lib
96+
LIBS += -Wl,-Bdynamic -L$$PWD/3rdparty/spinnaker/lib/ -lSpinnaker
97+
# OpenCV
98+
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_contrib -lopencv_calib3d
99+
# CUDA
100+
LIBS += -I/usr/local/cuda-8.0/include/
101+
LIBS += -L/usr/local/cuda-8.0/lib64 -lcudart -lcublas -lcurand
102+
# OpenGL
103+
LIBS += -lGLU -lGL -lglut
104+
# Other 3rdparty
105+
LIBS += -lcudnn -lglog -lgflags -lboost_system -lboost_filesystem -lm -lboost_thread
106+
LIBS += -pthread -fPIC -std=c++11 -fopenmp
107+
# Optimization flags
108+
LIBS += -DNDEBUG -O3 -march=native
109+
# Debug flags
110+
LIBS += -Wpedantic -Wall -Wextra -Wfatal-errors
111+
```
112+
10. If you find any error/difference, feel free to add a pull request to help other users.

include/openpose/face/faceParameters.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ namespace op
1313
41,36, 42,43, 43,44, 44,45, 45,46, 46,47, 47,42, 48,49, 49,50, 50,51, 51,52, 52,53, 53,54, 54,55, 55,56, 56,57, 57,58, \
1414
58,59, 59,48, 60,61, 61,62, 62,63, 63,64, 64,65, 65,66, 66,67, 67,60}
1515
const std::vector<unsigned int> FACE_PAIRS_RENDER {FACE_PAIRS_RENDER_GPU};
16-
#define FACE_COLORS_RENDER 255.f, 255.f, 255.f
16+
#define FACE_COLORS_RENDER_GPU 255.f, 255.f, 255.f
17+
const std::vector<float> FACE_COLORS_RENDER{FACE_COLORS_RENDER_GPU};
1718

1819
// Constant parameters
1920
const auto FACE_CCN_DECREASE_FACTOR = 8.f;

include/openpose/hand/handParameters.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace op
1010
const auto HAND_NUMBER_PARTS = 21u;
1111
#define HAND_PAIRS_RENDER_GPU {0,1, 1,2, 2,3, 3,4, 0,5, 5,6, 6,7, 7,8, 0,9, 9,10, 10,11, 11,12, 0,13, 13,14, 14,15, 15,16, 0,17, 17,18, 18,19, 19,20}
1212
const std::vector<unsigned int> HAND_PAIRS_RENDER {HAND_PAIRS_RENDER_GPU};
13-
#define HAND_COLORS_RENDER \
13+
#define HAND_COLORS_RENDER_GPU \
1414
100.f, 100.f, 100.f, \
1515
100.f, 0.f, 0.f, \
1616
150.f, 0.f, 0.f, \
@@ -32,6 +32,8 @@ namespace op
3232
150.f, 0.f, 150.f, \
3333
200.f, 0.f, 200.f, \
3434
255.f, 0.f, 255.f
35+
const std::vector<float> HAND_COLORS_RENDER{HAND_COLORS_RENDER_GPU};
36+
3537

3638
// Constant parameters
3739
const auto HAND_CCN_DECREASE_FACTOR = 8.f;

include/openpose/pose/poseParameters.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace op
4040
#define POSE_COCO_PAIRS_RENDER_GPU {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12, 12,13, 1,0, 0,14, 14,16, 0,15, 15,17}
4141
const std::vector<unsigned int> POSE_COCO_PAIRS_RENDER {POSE_COCO_PAIRS_RENDER_GPU};
4242
const std::vector<unsigned int> POSE_COCO_PAIRS {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12, 12,13, 1,0, 0,14, 14,16, 0,15, 15,17, 2,16, 5,17};
43-
#define POSE_COCO_COLORS_RENDER \
43+
#define POSE_COCO_COLORS_RENDER_GPU \
4444
255.f, 0.f, 85.f, \
4545
255.f, 0.f, 0.f, \
4646
255.f, 85.f, 0.f, \
@@ -59,6 +59,7 @@ namespace op
5959
170.f, 0.f, 255.f, \
6060
255.f, 0.f, 255.f, \
6161
85.f, 0.f, 255.f
62+
const std::vector<float> POSE_COCO_COLORS_RENDER{POSE_COCO_COLORS_RENDER_GPU};
6263
// MPI
6364
const std::map<unsigned int, std::string> POSE_MPI_BODY_PARTS{
6465
{0, "Head"},
@@ -83,7 +84,7 @@ namespace op
8384
#define POSE_MPI_PAIRS_RENDER_GPU { 0,1, 1,2, 2,3, 3,4, 1,5, 5,6, 6,7, 1,14, 14,8, 8,9, 9,10, 14,11, 11,12, 12,13}
8485
const std::vector<unsigned int> POSE_MPI_PAIRS POSE_MPI_PAIRS_RENDER_GPU;
8586
// MPI colors chosen such that they are closed to COCO colors
86-
#define POSE_MPI_COLORS_RENDER \
87+
#define POSE_MPI_COLORS_RENDER_GPU \
8788
255.f, 0.f, 85.f, \
8889
255.f, 0.f, 0.f, \
8990
255.f, 85.f, 0.f, \
@@ -99,6 +100,7 @@ namespace op
99100
0.f, 170.f, 255.f, \
100101
0.f, 85.f, 255.f, \
101102
0.f, 0.f, 255.f
103+
const std::vector<float> POSE_MPI_COLORS_RENDER{POSE_MPI_COLORS_RENDER_GPU};
102104
// BODY_22 (experimental, do not use)
103105
const std::map<unsigned int, std::string> POSE_BODY_22_BODY_PARTS {
104106
{0, "Nose"},
@@ -130,7 +132,7 @@ namespace op
130132
#define POSE_BODY_22_PAIRS_RENDER_GPU {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12}
131133
const std::vector<unsigned int> POSE_BODY_22_PAIRS_RENDER {POSE_BODY_22_PAIRS_RENDER_GPU};
132134
const std::vector<unsigned int> POSE_BODY_22_PAIRS {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12, 12,13, 1,0};
133-
#define POSE_BODY_22_COLORS_RENDER \
135+
#define POSE_BODY_22_COLORS_RENDER_GPU \
134136
255.f, 0.f, 0.f, \
135137
255.f, 85.f, 0.f, \
136138
255.f, 170.f, 0.f, \
@@ -149,6 +151,7 @@ namespace op
149151
255.f, 0.f, 255.f, \
150152
255.f, 0.f, 170.f, \
151153
255.f, 0.f, 85.f
154+
const std::vector<float> POSE_BODY_22_COLORS_RENDER{POSE_BODY_22_COLORS_RENDER_GPU};
152155

153156
// Constant Array Parameters
154157
const std::array<float, (int)PoseModel::Size> POSE_CCN_DECREASE_FACTOR{
@@ -169,6 +172,9 @@ namespace op
169172
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_MAP_IDX{
170173
POSE_COCO_MAP_IDX, POSE_MPI_MAP_IDX, POSE_MPI_MAP_IDX, POSE_BODY_22_MAP_IDX
171174
};
175+
const std::array<std::vector<float>, (int)PoseModel::Size> POSE_COLORS{
176+
POSE_COCO_COLORS_RENDER,POSE_MPI_COLORS_RENDER, POSE_MPI_COLORS_RENDER, POSE_BODY_22_COLORS_RENDER
177+
};
172178
const std::array<std::string, (int)PoseModel::Size> POSE_PROTOTXT{
173179
"pose/coco/pose_deploy_linevec.prototxt",
174180
"pose/mpi/pose_deploy_linevec.prototxt",

src/openpose/face/renderFace.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
namespace op
77
{
8-
const std::vector<float> COLORS{FACE_COLORS_RENDER};
9-
108
void renderFaceKeypointsCpu(Array<float>& frameArray, const Array<float>& faceKeypoints, const float renderThreshold)
119
{
1210
try
@@ -19,7 +17,7 @@ namespace op
1917
const auto& pairs = FACE_PAIRS_RENDER;
2018

2119
// Render keypoints
22-
renderKeypointsCpu(frameArray, faceKeypoints, pairs, COLORS, thicknessCircleRatio, thicknessLineRatioWRTCircle, renderThreshold);
20+
renderKeypointsCpu(frameArray, faceKeypoints, pairs, FACE_COLORS_RENDER, thicknessCircleRatio, thicknessLineRatioWRTCircle, renderThreshold);
2321
}
2422
}
2523
catch (const std::exception& e)

src/openpose/face/renderFace.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace op
88
{
99
const dim3 THREADS_PER_BLOCK{128, 128, 1};
1010
__constant__ const unsigned int PART_PAIRS_GPU[] = FACE_PAIRS_RENDER_GPU;
11-
__constant__ const float COLORS[] = {FACE_COLORS_RENDER};
11+
__constant__ const float COLORS[] = {FACE_COLORS_RENDER_GPU};
1212

1313
__global__ void renderFaceParts(float* targetPtr, const int targetWidth, const int targetHeight,
1414
const float* const facePtr, const int numberPeople, const float threshold,

src/openpose/hand/renderHand.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
namespace op
77
{
8-
const std::vector<float> COLORS{HAND_COLORS_RENDER};
9-
108
void renderHandKeypointsCpu(Array<float>& frameArray, const std::array<Array<float>, 2>& handKeypoints,
119
const float renderThreshold)
1210
{
@@ -18,10 +16,10 @@ namespace op
1816
const auto& pairs = HAND_PAIRS_RENDER;
1917
// Render keypoints
2018
if (!frameArray.empty())
21-
renderKeypointsCpu(frameArray, handKeypoints[0], pairs, COLORS, thicknessCircleRatio,
19+
renderKeypointsCpu(frameArray, handKeypoints[0], pairs, HAND_COLORS_RENDER, thicknessCircleRatio,
2220
thicknessLineRatioWRTCircle, renderThreshold);
2321
if (!frameArray.empty())
24-
renderKeypointsCpu(frameArray, handKeypoints[1], pairs, COLORS, thicknessCircleRatio,
22+
renderKeypointsCpu(frameArray, handKeypoints[1], pairs, HAND_COLORS_RENDER, thicknessCircleRatio,
2523
thicknessLineRatioWRTCircle, renderThreshold);
2624
}
2725
catch (const std::exception& e)

src/openpose/hand/renderHand.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace op
88
{
99
__constant__ const unsigned int PART_PAIRS_GPU[] = HAND_PAIRS_RENDER_GPU;
10-
__constant__ const float COLORS[] = {HAND_COLORS_RENDER};
10+
__constant__ const float COLORS[] = {HAND_COLORS_RENDER_GPU};
1111

1212

1313

0 commit comments

Comments
 (0)