OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
flags.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_FLAGS_HPP
2 #define OPENPOSE_FLAGS_HPP
3 
4 // Note: This class is not included within the basic OpenPose `headers.hpp` and must be explicitly included. In
5 // addition, Google Flags library must also be linked to the resulting binary or library. OpenPose library does
6 // not force to use Google Flags, but the OpenPose examples do so.
7 
8 // GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string
9 #include <gflags/gflags.h>
10 // Allow Google Flags in Ubuntu 14
11 #ifndef GFLAGS_GFLAGS_H_
12  namespace gflags = google;
13 #endif
14 
15 // See all the available parameter options withe the `--help` flag. E.g., `build/examples/openpose/openpose.bin --help`
16 // Note: This command will show you flags for other unnecessary 3rdparty files. Check only the flags for the OpenPose
17 // executable. E.g., for `openpose.bin`, look for `Flags from examples/openpose/openpose.cpp:`.
18 // Debugging/Other
19 DEFINE_int32(logging_level, 3, "The logging level. Integer in the range [0, 255]. 0 will output any log() message, while"
20  " 255 will not output any. Current OpenPose library messages are in the range 0-4: 1 for"
21  " low priority messages and 4 for important ones.");
22 DEFINE_bool(disable_multi_thread, false, "It would slightly reduce the frame rate in order to highly reduce the lag. Mainly useful"
23  " for 1) Cases where it is needed a low latency (e.g., webcam in real-time scenarios with"
24  " low-range GPU devices); and 2) Debugging OpenPose when it is crashing to locate the"
25  " error.");
26 DEFINE_int32(profile_speed, 1000, "If PROFILER_ENABLED was set in CMake or Makefile.config files, OpenPose will show some"
27  " runtime statistics at this frame number.");
28 #ifndef OPENPOSE_FLAGS_DISABLE_POSE
29 #ifndef OPENPOSE_FLAGS_DISABLE_PRODUCER
30 // Producer
31 DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative"
32  " number (by default), to auto-detect and open the first available camera.");
33 DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the"
34  " default 1280x720 for `--camera`, or the maximum flir camera resolution available for"
35  " `--flir_camera`");
36 #endif // OPENPOSE_FLAGS_DISABLE_PRODUCER
37 DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (also used when saving video). Set this value to the minimum"
38  " value between the OpenPose displayed speed and the webcam real frame rate.");
39 #ifndef OPENPOSE_FLAGS_DISABLE_PRODUCER
40 DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default"
41  " example video.");
42 DEFINE_string(image_dir, "", "Process a directory of images. Use `examples/media/` for our default example folder with 20"
43  " images. Read all standard formats (jpg, png, bmp, etc.).");
44 DEFINE_bool(flir_camera, false, "Whether to use FLIR (Point-Grey) stereo camera.");
45 DEFINE_int32(flir_camera_index, -1, "Select -1 (default) to run on all detected flir cameras at once. Otherwise, select the flir"
46  " camera index to run, where 0 corresponds to the detected flir camera with the lowest"
47  " serial number, and `n` to the `n`-th lowest serial number camera.");
48 DEFINE_string(ip_camera, "", "String with the IP camera URL. It supports protocols like RTSP and HTTP.");
49 DEFINE_uint64(frame_first, 0, "Start on desired frame number. Indexes are 0-based, i.e., the first frame has index 0.");
50 DEFINE_uint64(frame_step, 1, "Step or gap between processed frames. E.g., `--frame_step 5` would read and process frames"
51  " 0, 5, 10, etc..");
52 DEFINE_uint64(frame_last, -1, "Finish on desired frame number. Select -1 to disable. Indexes are 0-based, e.g., if set to"
53  " 10, it will process 11 frames (0-10).");
54 DEFINE_bool(frame_flip, false, "Flip/mirror each frame (e.g., for real time webcam demonstrations).");
55 DEFINE_int32(frame_rotate, 0, "Rotate each frame, 4 possible values: 0, 90, 180, 270.");
56 DEFINE_bool(frames_repeat, false, "Repeat frames when finished.");
57 DEFINE_bool(process_real_time, false, "Enable to keep the original source frame rate (e.g., for video). If the processing time is"
58  " too long, it will skip frames. If it is too fast, it will slow it down.");
59 DEFINE_string(camera_parameter_folder, "models/cameraParameters/flir/", "String with the folder where the camera parameters are located.");
60 DEFINE_bool(frame_keep_distortion, false, "If false (default), it will undistortionate the image based on the"
61  " `camera_parameter_folder` camera parameters; if true, it will not undistortionate, i.e.,"
62  " it will leave it as it is.");
63 #endif // OPENPOSE_FLAGS_DISABLE_PRODUCER
64 // OpenPose
65 DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located.");
66 DEFINE_string(output_resolution, "-1x-1", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the"
67  " input image resolution.");
68 DEFINE_int32(num_gpu, -1, "The number of GPU devices to use. If negative, it will use all the available GPUs in your"
69  " machine.");
70 DEFINE_int32(num_gpu_start, 0, "GPU device start number.");
71 DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) coordinates of the final pose data array, i.e., the scale of the (x,y)"
72  " coordinates that will be saved with the `write_json` & `write_keypoint` flags."
73  " Select `0` to scale it to the original source resolution; `1`to scale it to the net output"
74  " size (set with `net_resolution`); `2` to scale it to the final output size (set with"
75  " `resolution`); `3` to scale it in the range [0,1], where (0,0) would be the top-left"
76  " corner of the image, and (1,1) the bottom-right one; and 4 for range [-1,1], where"
77  " (-1,-1) would be the top-left corner of the image, and (1,1) the bottom-right one. Non"
78  " related with `scale_number` and `scale_gap`.");
79 DEFINE_int32(number_people_max, -1, "This parameter will limit the maximum number of people detected, by keeping the people with"
80  " top scores. The score is based in person area over the image, body part score, as well as"
81  " joint score (between each pair of connected body parts). Useful if you know the exact"
82  " number of people in the scene, so it can remove false positives (if all the people have"
83  " been detected. However, it might also include false negatives by removing very small or"
84  " highly occluded people. -1 will keep them all.");
85 DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and"
86  " true positives. I.e., it maximizes average recall but could harm average precision.");
87 // OpenPose Body Pose
88 DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face"
89  " keypoint detection.");
90 DEFINE_string(model_pose, "BODY_25", "Model to be used. E.g., `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), "
91  "`MPI_4_layers` (15 keypoints, even faster but less accurate).");
92 DEFINE_string(net_resolution, "-1x368", "Multiples of 16. If it is increased, the accuracy potentially increases. If it is"
93  " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the"
94  " closest aspect ratio possible to the images or videos to be processed. Using `-1` in"
95  " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's"
96  " input value. E.g., the default `-1x368` is equivalent to `656x368` in 16:9 resolutions,"
97  " e.g., full HD (1980x1080) and HD (1280x720) resolutions.");
98 DEFINE_int32(scale_number, 1, "Number of scales to average.");
99 DEFINE_double(scale_gap, 0.3, "Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1."
100  " If you want to change the initial scale, you actually want to multiply the"
101  " `net_resolution` by your desired initial scale.");
102 // OpenPose Body Pose Heatmaps and Part Candidates
103 DEFINE_bool(heatmaps_add_parts, false, "If true, it will fill op::Datum::poseHeatMaps array with the body part heatmaps, and"
104  " analogously face & hand heatmaps to op::Datum::faceHeatMaps & op::Datum::handHeatMaps."
105  " If more than one `add_heatmaps_X` flag is enabled, it will place then in sequential"
106  " memory order: body parts + bkg + PAFs. It will follow the order on"
107  " POSE_BODY_PART_MAPPING in `src/openpose/pose/poseParameters.cpp`. Program speed will"
108  " considerably decrease. Not required for OpenPose, enable it only if you intend to"
109  " explicitly use this information later.");
110 DEFINE_bool(heatmaps_add_bkg, false, "Same functionality as `add_heatmaps_parts`, but adding the heatmap corresponding to"
111  " background.");
112 DEFINE_bool(heatmaps_add_PAFs, false, "Same functionality as `add_heatmaps_parts`, but adding the PAFs.");
113 DEFINE_int32(heatmaps_scale, 2, "Set 0 to scale op::Datum::poseHeatMaps in the range [-1,1], 1 for [0,1]; 2 for integer"
114  " rounded [0,255]; and 3 for no scaling.");
115 DEFINE_bool(part_candidates, false, "Also enable `write_json` in order to save this information. If true, it will fill the"
116  " op::Datum::poseCandidates array with the body part candidates. Candidates refer to all"
117  " the detected body parts, before being assembled into people. Note that the number of"
118  " candidates is equal or higher than the number of final body parts (i.e., after being"
119  " assembled into people). The empty body parts are filled with 0s. Program speed will"
120  " slightly decrease. Not required for OpenPose, enable it only if you intend to explicitly"
121  " use this information.");
122 // OpenPose Face
123 DEFINE_bool(face, false, "Enables face keypoint detection. It will share some parameters from the body pose, e.g."
124  " `model_folder`. Note that this will considerable slow down the performance and increse"
125  " the required GPU memory. In addition, the greater number of people on the image, the"
126  " slower OpenPose will be.");
127 DEFINE_string(face_net_resolution, "368x368", "Multiples of 16 and squared. Analogous to `net_resolution` but applied to the face keypoint"
128  " detector. 320x320 usually works fine while giving a substantial speed up when multiple"
129  " faces on the image.");
130 // OpenPose Hand
131 DEFINE_bool(hand, false, "Enables hand keypoint detection. It will share some parameters from the body pose, e.g."
132  " `model_folder`. Analogously to `--face`, it will also slow down the performance, increase"
133  " the required GPU memory and its speed depends on the number of people.");
134 DEFINE_string(hand_net_resolution, "368x368", "Multiples of 16 and squared. Analogous to `net_resolution` but applied to the hand keypoint"
135  " detector.");
136 DEFINE_int32(hand_scale_number, 1, "Analogous to `scale_number` but applied to the hand keypoint detector. Our best results"
137  " were found with `hand_scale_number` = 6 and `hand_scale_range` = 0.4.");
138 DEFINE_double(hand_scale_range, 0.4, "Analogous purpose than `scale_gap` but applied to the hand keypoint detector. Total range"
139  " between smallest and biggest scale. The scales will be centered in ratio 1. E.g., if"
140  " scaleRange = 0.4 and scalesNumber = 2, then there will be 2 scales, 0.8 and 1.2.");
141 DEFINE_bool(hand_tracking, false, "Adding hand tracking might improve hand keypoints detection for webcam (if the frame rate"
142  " is high enough, i.e., >7 FPS per GPU) and video. This is not person ID tracking, it"
143  " simply looks for hands in positions at which hands were located in previous frames, but"
144  " it does not guarantee the same person ID among frames.");
145 // OpenPose 3-D Reconstruction
146 DEFINE_bool(3d, false, "Running OpenPose 3-D reconstruction demo: 1) Reading from a stereo camera system."
147  " 2) Performing 3-D reconstruction from the multiple views. 3) Displaying 3-D reconstruction"
148  " results. Note that it will only display 1 person. If multiple people is present, it will"
149  " fail.");
150 DEFINE_int32(3d_min_views, -1, "Minimum number of views required to reconstruct each keypoint. By default (-1), it will"
151  " require all the cameras to see the keypoint in order to reconstruct it.");
152 DEFINE_int32(3d_views, 1, "Complementary option to `--image_dir` or `--video`. OpenPose will read as many images per"
153  " iteration, allowing tasks such as stereo camera processing (`--3d`). Note that"
154  " `--camera_parameters_folder` must be set. OpenPose must find as many `xml` files in the"
155  " parameter folder as this number indicates.");
156 // Extra algorithms
157 DEFINE_bool(identification, false, "Experimental, not available yet. Whether to enable people identification across frames.");
158 DEFINE_int32(tracking, -1, "Experimental, not available yet. Whether to enable people tracking across frames. The"
159  " value indicates the number of frames where tracking is run between each OpenPose keypoint"
160  " detection. Select -1 (default) to disable it or 0 to run simultaneously OpenPose keypoint"
161  " detector and tracking for potentially higher accurary than only OpenPose.");
162 DEFINE_int32(ik_threads, 0, "Experimental, not available yet. Whether to enable inverse kinematics (IK) from 3-D"
163  " keypoints to obtain 3-D joint angles. By default (0 threads), it is disabled. Increasing"
164  " the number of threads will increase the speed but also the global system latency.");
165 // OpenPose Rendering
166 DEFINE_int32(part_to_show, 0, "Prediction channel to visualize (default: 0). 0 for all the body parts, 1-18 for each body"
167  " part heat map, 19 for the background heat map, 20 for all the body part heat maps"
168  " together, 21 for all the PAFs, 22-40 for each body part pair PAF.");
169 DEFINE_bool(disable_blending, false, "If enabled, it will render the results (keypoint skeletons or heatmaps) on a black"
170  " background, instead of being rendered into the original image. Related: `part_to_show`,"
171  " `alpha_pose`, and `alpha_pose`.");
172 // OpenPose Rendering Pose
173 DEFINE_double(render_threshold, 0.05, "Only estimated keypoints whose score confidences are higher than this threshold will be"
174  " rendered. Generally, a high threshold (> 0.5) will only render very clear body parts;"
175  " while small thresholds (~0.1) will also output guessed and occluded keypoints, but also"
176  " more false positives (i.e., wrong detections).");
177 DEFINE_int32(render_pose, -1, "Set to 0 for no rendering, 1 for CPU rendering (slightly faster), and 2 for GPU rendering"
178  " (slower but greater functionality, e.g., `alpha_X` flags). If -1, it will pick CPU if"
179  " CPU_ONLY is enabled, or GPU if CUDA is enabled. If rendering is enabled, it will render"
180  " both `outputData` and `cvOutputData` with the original image and desired body part to be"
181  " shown (i.e., keypoints, heat maps or PAFs).");
182 DEFINE_double(alpha_pose, 0.6, "Blending factor (range 0-1) for the body part rendering. 1 will show it completely, 0 will"
183  " hide it. Only valid for GPU rendering.");
184 DEFINE_double(alpha_heatmap, 0.7, "Blending factor (range 0-1) between heatmap and original frame. 1 will only show the"
185  " heatmap, 0 will only show the frame. Only valid for GPU rendering.");
186 // OpenPose Rendering Face
187 DEFINE_double(face_render_threshold, 0.4, "Analogous to `render_threshold`, but applied to the face keypoints.");
188 DEFINE_int32(face_render, -1, "Analogous to `render_pose` but applied to the face. Extra option: -1 to use the same"
189  " configuration that `render_pose` is using.");
190 DEFINE_double(face_alpha_pose, 0.6, "Analogous to `alpha_pose` but applied to face.");
191 DEFINE_double(face_alpha_heatmap, 0.7, "Analogous to `alpha_heatmap` but applied to face.");
192 // OpenPose Rendering Hand
193 DEFINE_double(hand_render_threshold, 0.2, "Analogous to `render_threshold`, but applied to the hand keypoints.");
194 DEFINE_int32(hand_render, -1, "Analogous to `render_pose` but applied to the hand. Extra option: -1 to use the same"
195  " configuration that `render_pose` is using.");
196 DEFINE_double(hand_alpha_pose, 0.6, "Analogous to `alpha_pose` but applied to hand.");
197 DEFINE_double(hand_alpha_heatmap, 0.7, "Analogous to `alpha_heatmap` but applied to hand.");
198 #ifndef OPENPOSE_FLAGS_DISABLE_DISPLAY
199 // Display
200 DEFINE_bool(fullscreen, false, "Run in full-screen mode (press f during runtime to toggle).");
201 DEFINE_bool(no_gui_verbose, false, "Do not write text on output images on GUI (e.g., number of current frame and people). It"
202  " does not affect the pose rendering.");
203 DEFINE_int32(display, -1, "Display mode: -1 for automatic selection; 0 for no display (useful if there is no X server"
204  " and/or to slightly speed up the processing if visual output is not required); 2 for 2-D"
205  " display; 3 for 3-D display (if `--3d` enabled); and 1 for both 2-D and 3-D display.");
206 #endif // OPENPOSE_FLAGS_DISABLE_DISPLAY
207 // Command Line Interface Verbose
208 DEFINE_double(cli_verbose, -1.f, "If -1, it will be disabled (default). If it is a positive integer number, it will print on"
209  " the command line every `verbose` frames. If number in the range (0,1), it will print the"
210  " progress every `verbose` times the total of frames.");
211 // Result Saving
212 DEFINE_string(write_images, "", "Directory to write rendered frames in `write_images_format` image format.");
213 DEFINE_string(write_images_format, "png", "File extension and format for `write_images`, e.g., png, jpg or bmp. Check the OpenCV"
214  " function cv::imwrite for all compatible extensions.");
215 DEFINE_string(write_video, "", "Full file path to write rendered frames in motion JPEG video format. It might fail if the"
216  " final path does not finish in `.avi`. It internally uses cv::VideoWriter. Flag"
217  " `camera_fps` controls FPS.");
218 DEFINE_string(write_json, "", "Directory to write OpenPose output in JSON format. It includes body, hand, and face pose"
219  " keypoints (2-D and 3-D), as well as pose candidates (if `--part_candidates` enabled).");
220 DEFINE_string(write_coco_json, "", "Full file path to write people pose data with JSON COCO validation format.");
221 DEFINE_string(write_coco_foot_json, "", "Full file path to write people foot pose data with JSON COCO validation format.");
222 DEFINE_int32(write_coco_json_variant, 0, "Currently, this option is experimental and only makes effect on car JSON generation. It"
223  " selects the COCO variant for cocoJsonSaver.");
224 DEFINE_string(write_heatmaps, "", "Directory to write body pose heatmaps in PNG format. At least 1 `add_heatmaps_X` flag"
225  " must be enabled.");
226 DEFINE_string(write_heatmaps_format, "png", "File extension and format for `write_heatmaps`, analogous to `write_images_format`."
227  " For lossless compression, recommended `png` for integer `heatmaps_scale` and `float` for"
228  " floating values.");
229 DEFINE_string(write_keypoint, "", "(Deprecated, use `write_json`) Directory to write the people pose keypoint data. Set format"
230  " with `write_keypoint_format`.");
231 DEFINE_string(write_keypoint_format, "yml", "(Deprecated, use `write_json`) File extension and format for `write_keypoint`: json, xml,"
232  " yaml & yml. Json not available for OpenCV < 3.0, use `write_json` instead.");
233 // Result Saving - Extra Algorithms
234 DEFINE_string(write_video_adam, "", "Experimental, not available yet. E.g., `~/Desktop/adamResult.avi`. Flag `camera_fps`"
235  " controls FPS.");
236 DEFINE_string(write_bvh, "", "Experimental, not available yet. E.g., `~/Desktop/mocapResult.bvh`.");
237 // UDP Communication
238 DEFINE_string(udp_host, "", "Experimental, not available yet. IP for UDP communication. E.g., `192.168.0.1`.");
239 DEFINE_string(udp_port, "8051", "Experimental, not available yet. Port number for UDP communication.");
240 #endif // OPENPOSE_FLAGS_DISABLE_POSE
241 
242 #endif // OPENPOSE_FLAGS_HPP
DEFINE_double(camera_fps, 30.0,"Frame rate for the webcam (also used when saving video). Set this value to the minimum"" value between the OpenPose displayed speed and the webcam real frame rate.")
DEFINE_bool(disable_multi_thread, false,"It would slightly reduce the frame rate in order to highly reduce the lag. Mainly useful"" for 1) Cases where it is needed a low latency (e.g., webcam in real-time scenarios with"" low-range GPU devices); and 2) Debugging OpenPose when it is crashing to locate the"" error.")
DEFINE_string(camera_resolution,"-1x-1","Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the"" default 1280x720 for `--camera`, or the maximum flir camera resolution available for"" `--flir_camera`")
DEFINE_int32(logging_level, 3,"The logging level. Integer in the range [0, 255]. 0 will output any log() message, while"" 255 will not output any. Current OpenPose library messages are in the range 0-4: 1 for"" low priority messages and 4 for important ones.")
DEFINE_uint64(frame_first, 0,"Start on desired frame number. Indexes are 0-based, i.e., the first frame has index 0.")