01_demo.md 20.2 KB
Newer Older
1
OpenPose Doc - Demo
2 3
====================================

G
Gines Hidalgo 已提交
4 5
Forget about the OpenPose code, just download the portable Windows binaries (or compile the code from source) and use the demo by following this tutorial!

6
## Contents
7
1. [Quick Start](#quick-start)
G
Gines Hidalgo 已提交
8 9 10 11 12 13
    1. [Running on Images, Video, or Webcam](#running-on-images-video-or-webcam)
    2. [Face and Hands](#face-and-hands)
    3. [Different Outputs (JSON, Images, Video, UI)](#different-outputs-json-images-video-ui)
    4. [Only Skeleton without Background Image](#only-skeleton-without-background-image)
    5. [Not Running All GPUs](#not-running-all-gpus)
    6. [Maximum Accuracy Configuration](#maximum-accuracy-configuration)
14 15
        1. [Additional Model with Maximum Accuracy](#additional-model-with-maximum-accuracy)
        2. [Additional Model with Lower False Positives](#additional-model-with-lower-false-positives)
G
Gines Hidalgo 已提交
16 17 18 19
    7. [3-D Reconstruction](#3-d-reconstruction)
    8. [Tracking](#tracking)
    9. [Kinect 2.0 as Webcam on Windows 10](#kinect-20-as-webcam-on-windows-10)
    10. [Main Flags](#main-flags)
20 21 22 23 24
2. [Advanced Quick Start](#advanced-quick-start)
3. [Bug Solving](#bug-solving)
    1. [Improving Memory and Speed but Decreasing Accuracy](#improving-memory-and-speed-but-decreasing-accuracy)
    2. [Mac OSX Additional Step](#mac-osx-additional-step)
    3. [FAQ](#faq)
25 26 27 28 29





G
Gines Hidalgo 已提交
30
## Quick Start
31
In Ubuntu, Mac, and other Unix systems, use `Terminal` or `Terminator`. In Windows, the `Windows PowerShell`. Watch any Youtube video tutorial if you are not familiar with these tools. Make sure that you are in the **root directory of the project** when running any command (i.e., in the OpenPose folder, not inside `build/` nor `windows/` nor `bin/`). In addition, `examples/media/video.avi` and `examples/media` exist, so there is no need to change any lines of code.
G
Gines Hidalgo 已提交
32

33
Test OpenPose by running the following. The expected visual result should look like [doc/02_output.md#ui-and-visual-output](02_output.md#ui-and-visual-output).
G
Gines Hidalgo 已提交
34 35 36 37 38 39
```
# Ubuntu and Mac
./build/examples/openpose/openpose.bin --video examples/media/video.avi
```
```
:: Windows - Portable Demo
G
Gines Hidalgo 已提交
40
bin\OpenPoseDemo.exe --video examples/media/video.avi
G
Gines Hidalgo 已提交
41 42
```

43
If you are only using the OpenPose demo, we highly recommend using [the latest Windows portable version of OpenPose](doc/installation/0_index.md#windows-portable-demo). If you still want to use the demo with Visual Studio, you can copy the `bin/*.dll` files into the final DLL bin location following [doc/installation/0_index.md#windows](installation/0_index.md#windows), or you could also simply modify the default flag values from [include/flags.hpp](../include/flags.hpp). If you have copied the DLLs, you can execute this:
G
Gines Hidalgo 已提交
44
```
45
:: Windows - Library - Assuming you have copied the DLLs following doc/installation/0_index.md#windows
G
Gines Hidalgo 已提交
46
build\x64\Release\OpenPoseDemo.exe --video examples/media/video.avi
G
Gines Hidalgo 已提交
47 48
```

49
If it worked, continue with the next section. Otherwise:
50 51 52
- If these failed with an out of memory error, check and follow the section [Improving Memory and Speed but Decreasing Accuracy](#improving-memory-and-speed-but-decreasing-accuracy).
- If you are using Mac, make sure to check and follow the section [Mac OSX Additional Step](#mac-osx-additional-step).
- Otherwise, check the section [FAQ](#faq).
G
Gines Hidalgo 已提交
53 54


55 56 57 58 59 60 61 62 63

### Running on Images, Video, or Webcam
- Directory with images (`--image_dir {DIRECTORY_PATH}`):
```
# Ubuntu and Mac
./build/examples/openpose/openpose.bin --image_dir examples/media/
```
```
:: Windows - Portable Demo
G
Gines Hidalgo 已提交
64
bin\OpenPoseDemo.exe --image_dir examples/media/
65 66
```
- Video (`--video {VIDEO_PATH}`):
67
```
G
gineshidalgo99 已提交
68
# Ubuntu and Mac
69 70 71
./build/examples/openpose/openpose.bin --video examples/media/video.avi
```
```
G
gineshidalgo99 已提交
72
:: Windows - Portable Demo
G
Gines Hidalgo 已提交
73
bin\OpenPoseDemo.exe --video examples/media/video.avi
74
```
75
- Webcam is applied by default (i.e., if no `--image_dir` or `--video` flags used). Optionally, if you have more than 1 camera, you could use `--camera {CAMERA_NUMBER}` to select the right one:
76
```
G
gineshidalgo99 已提交
77
# Ubuntu and Mac
78
./build/examples/openpose/openpose.bin
79 80
./build/examples/openpose/openpose.bin --camera 0
./build/examples/openpose/openpose.bin --camera 1
81 82
```
```
G
gineshidalgo99 已提交
83
:: Windows - Portable Demo
84
bin\OpenPoseDemo.exe
85 86
bin\OpenPoseDemo.exe --camera 0
bin\OpenPoseDemo.exe --camera 1
87 88 89 90
```



91 92
### Face and Hands
Simply add `--face` and/or `--hand` to any command:
93
```
G
gineshidalgo99 已提交
94
# Ubuntu and Mac
G
Gines Hidalgo 已提交
95 96
./build/examples/openpose/openpose.bin --image_dir examples/media/ --face --hand
./build/examples/openpose/openpose.bin --video examples/media/video.avi --face --hand
97
./build/examples/openpose/openpose.bin --face --hand
98 99
```
```
G
gineshidalgo99 已提交
100
:: Windows - Portable Demo
G
Gines Hidalgo 已提交
101 102
bin\OpenPoseDemo.exe --image_dir examples/media/ --face --hand
bin\OpenPoseDemo.exe --video examples/media/video.avi --face --hand
103
bin\OpenPoseDemo.exe --face --hand
104
```
105 106 107 108 109 110



## Different Outputs (JSON, Images, Video, UI)
All the output options are complementary to each other. E.g., whether you display the images with the skeletons on the UI (or not) is independent on whether you save them on disk (or not).

111
- Save the skeletons in a set of JSON files with `--write_json {OUTPUT_JSON_PATH}`, see [doc/02_output.md](02_output.md) to understand its format.
112
```
113
# Ubuntu and Mac (same flags for Windows)
114
./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_json output_jsons/
115 116 117
./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output_jsons/
./build/examples/openpose/openpose.bin --write_json output_jsons/
```
118
- Save on disk the visual output of OpenPose (the images with the skeletons overlaid) as an output video (`--write_video {OUTPUT_VIDEO_PATH}`) or set of images (`--write_images {OUTPUT_IMAGE_DIRECTORY_PATH}`.:
119 120 121
```
# Ubuntu and Mac (same flags for Windows)
./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_video output/result.avi
122 123 124 125 126
./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_video output/result.avi
./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_images output_images/
./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_images output_images/ --write_images_format jpg
./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_images output_images/
./build/examples/openpose/openpose.bin --image_dir examples/media/ --write_images output_images/ --write_images_format jpg
127
```
128
- You can also disable the UI visualization with `--display 0`. However, some kind of output must be generated. I.e., set one out of `--write_json`, `--write_video`, or `--write_images` if `--display 0`.
129 130 131 132
```
# Ubuntu and Mac (same flags for Windows)
./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_images output_images/ --display 0
```
133
- To speed up OpenPose even further when using `--display 0`, also add `--render_pose 0` if you are not using `--write_video` or `--write_images` (so OpenPose will not overlay skeletons with the input images).
134 135 136
```
# Ubuntu and Mac (same flags for Windows)
./build/examples/openpose/openpose.bin --video examples/media/video.avi --write_json output_jsons/ --display 0 --render_pose 0
137 138 139 140
```



141 142 143 144 145 146 147 148 149 150 151
## Only Skeleton without Background Image
You can also visualize/save the skeleton without the original image overlaid or blended by adding `--disable_blending`:
```
# Ubuntu and Mac (same flags for Windows)
# Only body
./build/examples/openpose/openpose.bin --video examples/media/video.avi --disable_blending
```



## Not Running All GPUs
152
By default, OpenPose will use all the GPUs available in your machine. Otherwise, `--num_gpu` sets the number of total GPUs and `--num_gpu_start` the first GPU to use. E.g., `--num_gpu 2 --num_gpu_start 1` will use GPUs ID 1 and 2 while ignore GPU ID 0 (assuming there are at least 3 GPUs):
153 154 155 156
```
:: Windows - Portable Demo (same flags for Ubuntu and Mac)
bin\OpenPoseDemo.exe --video examples/media/video.avi --num_gpu 2 --num_gpu_start 1
```
G
Gines Hidalgo 已提交
157 158 159



160
### Maximum Accuracy Configuration
G
Gines Hidalgo 已提交
161
This command provides the most accurate results we have been able to achieve for body, hand and face keypoint detection.
162
```
G
gineshidalgo99 已提交
163
# Ubuntu and Mac: Body
G
gineshidalgo99 已提交
164
./build/examples/openpose/openpose.bin --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25
G
gineshidalgo99 已提交
165
# Ubuntu and Mac: Body + Hand + Face
166 167 168
./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
```
```
G
gineshidalgo99 已提交
169
:: Windows - Portable Demo: Body
G
gineshidalgo99 已提交
170
bin\OpenPoseDemo.exe --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25
G
gineshidalgo99 已提交
171
:: Windows - Portable Demo: Body + Hand + Face
172 173 174
bin\OpenPoseDemo.exe --net_resolution "1312x736" --scale_number 4 --scale_gap 0.25 --hand --hand_scale_number 6 --hand_scale_range 0.4 --face
```

175 176 177 178 179 180 181 182 183 184 185 186 187
- Required:
    - `BODY_25` (default model). `COCO` is less accurate (but still usable), while `MPI` is not supported (i.e., `MPI` accuracy and speed will drop by using these settings).
    - Nvidia GPU with at least 16 GB of memory. 8 or 12 GB could work in some subcases detailed here.
        - `BODY_25` (body + foot, default model): Nvidia GPU with at least about 10.5 GB of memory. E.g., Titan X(P), some Quadro models, P100, V100.
        - `BODY_25` + face + hands: Nvidia GPU with at least about 16 GB of memory. E.g., V100.
        - `COCO` Body + face + hands: Nvidia GPU with at least about 6.7 GB of memory. E.g., 2070, 2080.
    - It won't work on CPU/OpenCL modes, your only option there is to manually crop each person, rescale it, and fed it into the default OpenPose
- Additional information:
    - It runs at about 2 FPS on a Titan X for `BODY_25` (1 FPS for COCO).
    - Increasing `--net_resolution` will highly reduce speed, while it does not guarantee the accuracy to increase. Thus, we recommend only using the exact flags and values detailed here (or alternatively ask the user to make their own accuracy analysis if using other values).
    - (Not recommended, use at your own risk) You can add `--maximize_positives` to harm the visual/qualitative accuracy, but it increases the accuracy value metric on COCO challenge. It reduces the thresholds to accept a person candidate (i.e., more false and true positives), which maximizes average recall but could harm average precision. Our experience: it looks much worse visually, but improves the challenge accuracy numbers.
    - If you are operating on Ubuntu, you can check the experimental scripts that we use to test our accuracy (we do not officially support it, i.e., we will not answer questions about it, as well as it might change it continuously), they are placed in `openpose/scripts/tests/`, called `pose_accuracy_coco_test_dev.sh` and `pose_accuracy_coco_val.sh`.

G
gineshidalgo99 已提交
188

189
#### Additional Model with Maximum Accuracy
G
Gines Hidalgo 已提交
190
Disclaimer: It is more accurate but also slower, requires more GPU memory, and must use the Nvidia GPU version.
G
gineshidalgo99 已提交
191

192 193 194 195 196 197
Our paper accuracy numbers do not match the default model numbers. We released our best model at the time but found better ones later.

For our best model, you can download the `BODY_25B` pre-trained model from the OpenPose training repository: [BODY_25B Model - Option 1 (Maximum Accuracy, Less Speed)](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/tree/master/experimental_models#body_25b-model---option-1-maximum-accuracy-less-speed).


#### Additional Model with Lower False Positives
G
Gines Hidalgo 已提交
198 199
Disclaimer: It must use the Nvidia GPU version.

200
Do you need a model with less false positives but the same runtime performance and GPU requirements? You can download the `BODY_25B` pre-trained model from the OpenPose training repository: [BODY_25B Model - Option 2 (Recommended)](https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/tree/master/experimental_models#body_25b-model---option-2-recommended).
G
gineshidalgo99 已提交
201

202 203


G
gineshidalgo99 已提交
204
### 3-D Reconstruction
205
1. Real-time demo
G
gineshidalgo99 已提交
206
```
G
gineshidalgo99 已提交
207
# Ubuntu and Mac
208
./build/examples/openpose/openpose.bin --flir_camera --3d --number_people_max 1
G
gineshidalgo99 已提交
209
# With face and hands
210
./build/examples/openpose/openpose.bin --flir_camera --3d --number_people_max 1 --face --hand
G
gineshidalgo99 已提交
211 212 213
```
```
:: Windows - Portable Demo
214
bin\OpenPoseDemo.exe --flir_camera --3d --number_people_max 1
G
gineshidalgo99 已提交
215
:: With face and hands
216
bin\OpenPoseDemo.exe --flir_camera --3d --number_people_max 1 --face --hand
G
gineshidalgo99 已提交
217 218
```

219
2. Saving 3-D keypoints and video
220
```
221
# Ubuntu and Mac (same flags for Windows)
222
./build/examples/openpose/openpose.bin --flir_camera --3d --number_people_max 1 --write_json output_folder_path/ --write_video_3d output_folder_path/video_3d.avi
223 224
```

225
3. Fast stereo camera image saving (without keypoint detection) for later post-processing
226
```
227
# Ubuntu and Mac (same flags for Windows)
228 229
# Saving video
# Note: saving in PNG rather than JPG will improve image quality, but slow down FPS (depending on hard disk writing speed and camera number)
230
./build/examples/openpose/openpose.bin --flir_camera --num_gpu 0 --write_video output_folder_path/video.avi --write_video_fps 5
231
# Saving images
232
# Note: saving in PNG rather than JPG will improve image quality, but slow down FPS (depending on hard disk writing speed and camera number)
G
gineshidalgo99 已提交
233
./build/examples/openpose/openpose.bin --flir_camera --num_gpu 0 --write_images output_folder_path/ --write_images_format jpg
234 235 236
```

4. Reading and processing previouly saved stereo camera images
237
```
238
# Ubuntu and Mac (same flags for Windows)
239
# Optionally add `--face` and/or `--hand` to include face and/or hands
240
# Assuming 3 cameras
G
gineshidalgo99 已提交
241
# Note: We highly recommend to reduce `--output_resolution`. E.g., for 3 cameras recording at 1920x1080, the resulting image is (3x1920)x1080, so we recommend e.g. 640x360 (x3 reduction).
242 243 244 245
# Video
./build/examples/openpose/openpose.bin --video output_folder_path/video.avi --3d_views 3 --3d --number_people_max 1 --output_resolution {desired_output_resolution}
# Images
./build/examples/openpose/openpose.bin --image_dir output_folder_path/ --3d_views 3 --3d --number_people_max 1 --output_resolution {desired_output_resolution}
246 247
```

G
Gines Hidalgo 已提交
248
5. Reconstruction when the keypoint is visible in at least `x` camera views out of the total `n` cameras
G
gineshidalgo99 已提交
249
```
250
# Ubuntu and Mac (same flags for Windows)
G
Gines Hidalgo 已提交
251
# Reconstruction when a keypoint is visible in at least 2 camera views (assuming `n` >= 2)
G
gineshidalgo99 已提交
252
./build/examples/openpose/openpose.bin --flir_camera --3d --number_people_max 1 --3d_min_views 2 --output_resolution {desired_output_resolution}
G
Gines Hidalgo 已提交
253 254
# Reconstruction when a keypoint is visible in at least max(2, min(4, n-1)) camera views
./build/examples/openpose/openpose.bin --flir_camera --3d --number_people_max 1 --output_resolution {desired_output_resolution}
G
gineshidalgo99 已提交
255 256
```

G
gineshidalgo99 已提交
257 258


259 260
### Tracking
1. Runtime huge speed up by reducing the accuracy:
G
Gines Hidalgo 已提交
261
```
262 263 264
:: Windows - Portable Demo (same flags for Ubuntu and Mac)
# Using OpenPose 1 frame, tracking the following e.g., 5 frames
bin\OpenPoseDemo.exe --tracking 5 --number_people_max 1
G
Gines Hidalgo 已提交
265 266
```

267
2. Runtime speed up while keeping most of the accuracy:
G
Gines Hidalgo 已提交
268
```
269 270 271
:: Windows - Portable Demo (same flags for Ubuntu and Mac)
# Using OpenPose 1 frame and tracking another frame
bin\OpenPoseDemo.exe --tracking 1 --number_people_max 1
G
Gines Hidalgo 已提交
272 273
```

274
3. Visual smoothness:
G
Gines Hidalgo 已提交
275
```
276 277 278
:: Windows - Portable Demo (same flags for Ubuntu and Mac)
# Running both OpenPose and tracking on each frame. Note: There is no speed up/slow down
bin\OpenPoseDemo.exe --tracking 0 --number_people_max 1
G
Gines Hidalgo 已提交
279 280 281 282 283 284 285 286 287
```



## Kinect 2.0 as Webcam on Windows 10
Since the Windows 10 Anniversary, Kinect 2.0 can be read as a normal webcam. All you need to do is go to `device manager`, expand the `kinect sensor devices` tab, right click and update driver of `WDF kinectSensor Interface`. If you already have another webcam, disconnect it or use `--camera 2`.



G
gineshidalgo99 已提交
288 289


290
### Main Flags
291
These are the most common flags, but check [doc/advanced/demo_advanced.md](advanced/demo_advanced.md) for a full list and description of all of them.
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308

- `--face`: Enables face keypoint detection.
- `--hand`: Enables hand keypoint detection.
- `--video input.mp4`: Read video `input.mp4`.
- `--camera 3`: Read webcam number 3.
- `--image_dir path_with_images/`: Run on the directory `path_with_images/` with images.
- `--ip_camera http://iris.not.iac.es/axis-cgi/mjpg/video.cgi?resolution=320x240?x.mjpeg`: Run on a streamed IP camera. See examples public IP cameras [here](http://www.webcamxp.com/publicipcams.aspx).
- `--write_video path.avi`: Save processed images as video.
- `--write_images folder_path`: Save processed images on a folder.
- `--write_keypoint path/`: Output JSON, XML or YML files with the people pose data on a folder.
- `--process_real_time`: For video, it might skip frames to display at real time.
- `--disable_blending`: If enabled, it will render the results (keypoint skeletons or heatmaps) on a black background, not showing the original image. Related: `part_to_show`, `alpha_pose`, and `alpha_pose`.
- `--part_to_show`: Prediction channel to visualize.
- `--display 0`: Display window not opened. Useful for servers and/or to slightly speed up OpenPose.
- `--num_gpu 2 --num_gpu_start 1`: Parallelize over this number of GPUs starting by the desired device id. By default it uses all the available GPUs.
- `--model_pose MPI`: Model to use, affects number keypoints, speed and accuracy.
- `--logging_level 3`: Logging messages threshold, range [0,255]: 0 will output any message & 255 will output none. Current messages in the range [1-4], 1 for low priority messages and 4 for important ones.
G
gineshidalgo99 已提交
309 310 311



312 313


G
Gines Hidalgo 已提交
314
## Advanced Quick Start
315
In order to learn about many more flags, check [doc/advanced/demo_advanced.md](advanced/demo_advanced.md).
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334





## Bug Solving
### Improving Memory and Speed but Decreasing Accuracy
**If you have a Nvidia GPU that does not goes out of memory when running, you should skip this step!**

**Use `net_resolution` at your own risk**: If your GPU runs out of memory or you do not have a Nvidia GPU, you can reduce `--net_resolution` to improve the speed and reduce the memory requirements, but it will also highly reduce accuracy! The lower the resolution, the lower accuracy but better speed/memory.
```
# Ubuntu and Mac
./build/examples/openpose/openpose.bin --video examples/media/video.avi --net_resolution -1x320
./build/examples/openpose/openpose.bin --video examples/media/video.avi --net_resolution -1x256
./build/examples/openpose/openpose.bin --video examples/media/video.avi --net_resolution -1x196
./build/examples/openpose/openpose.bin --video examples/media/video.avi --net_resolution -1x128
```
```
:: Windows - Portable Demo
G
Gines Hidalgo 已提交
335 336 337 338
bin\OpenPoseDemo.exe --video examples/media/video.avi --net_resolution -1x320
bin\OpenPoseDemo.exe --video examples/media/video.avi --net_resolution -1x256
bin\OpenPoseDemo.exe --video examples/media/video.avi --net_resolution -1x196
bin\OpenPoseDemo.exe --video examples/media/video.avi --net_resolution -1x128
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
```

Additional notes:
- The default resolution is `-1x368`, any resolution smaller will improve speed.
- The `-1` means that that the resolution will be adapted to maintain the aspect ratio of the input source. E.g., `-1x368`, `656x-1`, and `656x368` will result in the same exact resolution for 720p and 1080p input images.
- For videos, using `-1` is recommended to let OpenPose find the ideal resolution. For a folder of images of different sizes, not adding `-1` and using images with completely different aspect ratios might result in out of memory issues. E.g., if a folder contains 2 images of resolution `100x11040` and `10000x368`. Then, using the default `-1x368` will result in the network output resolutions of `3x368` and `10000x368`, resulting in an obvious out of memory for the `10000x368` image.



### Mac OSX Additional Step
**If you are not using Mac, or you are using Mac with `CPU_only`, you can skip this section.**

If you are using a Mac and selected `OPENCL` support, and it has an AMD graphics card, that means that the machine has 2 GPUs that are not compatible with each other (AMD and Intel). Then, you will have to manually select one of them (the AMD one should be more poweful). To do that, first check which device your Graphics card is set under. Most likely, your AMD device will be device 2.
```bash
clinfo
```

For any OpenPose command you run, add the following 2 flags to use your AMD card for acceleration (where `num_gpu_start` should be the ID number given above).
```bash
./build/examples/openpose/openpose.bin --num_gpu 1 --num_gpu_start 2
```

If you only have an integrated Intel Graphics card, then it will most probably be the device 1. Then, always add the following 2 flags to use your AMD card for acceleration.
```bash
./build/examples/openpose/openpose.bin --num_gpu 1 --num_gpu_start 1
```


### FAQ
368
Check [doc/05_faq.md](05_faq.md) to see if you can find your error, issue, or concern.