1 #ifndef OPENPOSE_FLAGS_HPP
2 #define OPENPOSE_FLAGS_HPP
9 #include <gflags/gflags.h>
11 #ifndef GFLAGS_GFLAGS_H_
12 namespace gflags = google;
19 DEFINE_int32(logging_level, 3,
"The logging level. Integer in the range [0, 255]. 0 will output any opLog() message,"
20 " while 255 will not output any. Current OpenPose library messages are in the range 0-4:"
21 " 1 for 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"
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
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"
36 DEFINE_string(video,
"",
"Use a video file instead of the camera. Use `examples/media/video.avi` for our default"
38 DEFINE_string(image_dir,
"",
"Process a directory of images. Use `examples/media/` for our default example folder with 20"
39 " images. Read all standard formats (jpg, png, bmp, etc.).");
40 DEFINE_bool(flir_camera,
false,
"Whether to use FLIR (Point-Grey) stereo camera.");
41 DEFINE_int32(flir_camera_index, -1,
"Select -1 (default) to run on all detected flir cameras at once. Otherwise, select the flir"
42 " camera index to run, where 0 corresponds to the detected flir camera with the lowest"
43 " serial number, and `n` to the `n`-th lowest serial number camera.");
44 DEFINE_string(ip_camera,
"",
"String with the IP camera URL. It supports protocols like RTSP and HTTP.");
45 DEFINE_uint64(frame_first, 0,
"Start on desired frame number. Indexes are 0-based, i.e., the first frame has index 0.");
46 DEFINE_uint64(frame_step, 1,
"Step or gap between processed frames. E.g., `--frame_step 5` would read and process frames"
48 DEFINE_uint64(frame_last, -1,
"Finish on desired frame number. Select -1 to disable. Indexes are 0-based, e.g., if set to"
49 " 10, it will process 11 frames (0-10).");
50 DEFINE_bool(frame_flip,
false,
"Flip/mirror each frame (e.g., for real time webcam demonstrations).");
51 DEFINE_int32(frame_rotate, 0,
"Rotate each frame, 4 possible values: 0, 90, 180, 270.");
52 DEFINE_bool(frames_repeat,
false,
"Repeat frames when finished.");
53 DEFINE_bool(process_real_time,
false,
"Enable to keep the original source frame rate (e.g., for video). If the processing time is"
54 " too long, it will skip frames. If it is too fast, it will slow it down.");
55 DEFINE_string(camera_parameter_path,
"models/cameraParameters/flir/",
"String with the folder where the camera parameters are located. If there"
56 " is only 1 XML file (for single video, webcam, or images from the same camera), you must"
57 " specify the whole XML file path (ending in .xml).");
58 DEFINE_bool(frame_undistort,
false,
"If false (default), it will not undistort the image, if true, it will undistortionate them"
59 " based on the camera parameters found in `camera_parameter_path`");
62 DEFINE_string(model_folder,
"models/",
"Folder path (absolute or relative) where the models (pose, face, ...) are located.");
63 DEFINE_string(prototxt_path,
"",
"The combination `--model_folder` + `--prototxt_path` represents the whole path to the"
64 " prototxt file. If empty, it will use the default OpenPose ProtoTxt file.");
65 DEFINE_string(caffemodel_path,
"",
"The combination `--model_folder` + `--caffemodel_path` represents the whole path to the"
66 " caffemodel file. If empty, it will use the default OpenPose CaffeModel file.");
67 DEFINE_string(output_resolution,
"-1x-1",
"The image resolution (display and output). Use \"-1x-1\" to force the program to use the"
68 " input image resolution.");
69 DEFINE_int32(num_gpu, -1,
"The number of GPU devices to use. If negative, it will use all the available GPUs in your"
72 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)"
73 " coordinates that will be saved with the `write_json` & `write_keypoint` flags."
74 " Select `0` to scale it to the original source resolution; `1`to scale it to the net output"
75 " size (set with `net_resolution`); `2` to scale it to the final output size (set with"
76 " `resolution`); `3` to scale it in the range [0,1], where (0,0) would be the top-left"
77 " corner of the image, and (1,1) the bottom-right one; and 4 for range [-1,1], where"
78 " (-1,-1) would be the top-left corner of the image, and (1,1) the bottom-right one. Non"
79 " related with `scale_number` and `scale_gap`.");
80 DEFINE_int32(number_people_max, -1,
"This parameter will limit the maximum number of people detected, by keeping the people with"
81 " top scores. The score is based in person area over the image, body part score, as well as"
82 " joint score (between each pair of connected body parts). Useful if you know the exact"
83 " number of people in the scene, so it can remove false positives (if all the people have"
84 " been detected. However, it might also include false negatives by removing very small or"
85 " highly occluded people. -1 will keep them all.");
86 DEFINE_bool(maximize_positives,
false,
"It reduces the thresholds to accept a person candidate. It highly increases both false and"
87 " true positives. I.e., it maximizes average recall but could harm average precision.");
88 DEFINE_double(fps_max, -1.,
"Maximum processing frame rate. By default (-1), OpenPose will process frames as fast as"
89 " possible. Example usage: If OpenPose is displaying images too quickly, this can reduce"
90 " the speed so the user can analyze better each frame from the GUI.");
92 DEFINE_int32(body, 1,
"Select 0 to disable body keypoint detection (e.g., for faster but less accurate face"
93 " keypoint detection, custom hand detector, etc.), 1 (default) for body keypoint"
94 " estimation, and 2 to disable its internal body pose estimation network but still"
95 " still run the greedy association parsing algorithm");
96 DEFINE_string(model_pose,
"BODY_25",
"Model to be used. E.g., `BODY_25` (fastest for CUDA version, most accurate, and includes"
97 " foot keypoints), `COCO` (18 keypoints), `MPI` (15 keypoints, least accurate model but"
98 " fastest on CPU), `MPI_4_layers` (15 keypoints, even faster but less accurate).");
99 DEFINE_string(net_resolution,
"-1x368",
"Multiples of 16. If it is increased, the accuracy potentially increases. If it is"
100 " decreased, the speed increases. For maximum speed-accuracy balance, it should keep the"
101 " closest aspect ratio possible to the images or videos to be processed. Using `-1` in"
102 " any of the dimensions, OP will choose the optimal aspect ratio depending on the user's"
103 " input value. E.g., the default `-1x368` is equivalent to `656x368` in 16:9 resolutions,"
104 " e.g., full HD (1980x1080) and HD (1280x720) resolutions.");
105 DEFINE_double(net_resolution_dynamic, 1.,
"This flag only applies to images or custom inputs (not to video or webcam). If it is zero"
106 " or a negative value, it means that using `-1` in `net_resolution` will behave as explained"
107 " in its description. Otherwise, and to avoid out of memory errors, the `-1` in"
108 " `net_resolution` will clip to this value times the default 16/9 aspect ratio value (which"
109 " is 656 width for a 368 height). E.g., `net_resolution_dynamic 10 net_resolution -1x368`"
110 " will clip to 6560x368 (10 x 656). Recommended 1 for small GPUs (to avoid out of memory"
111 " errors but maximize speed) and 0 for big GPUs (for maximum accuracy and speed).");
113 DEFINE_double(scale_gap, 0.25,
"Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1."
114 " If you want to change the initial scale, you actually want to multiply the"
115 " `net_resolution` by your desired initial scale.");
117 DEFINE_bool(heatmaps_add_parts,
false,
"If true, it will fill op::Datum::poseHeatMaps array with the body part heatmaps, and"
118 " analogously face & hand heatmaps to op::Datum::faceHeatMaps & op::Datum::handHeatMaps."
119 " If more than one `add_heatmaps_X` flag is enabled, it will place then in sequential"
120 " memory order: body parts + bkg + PAFs. It will follow the order on"
121 " POSE_BODY_PART_MAPPING in `src/openpose/pose/poseParameters.cpp`. Program speed will"
122 " considerably decrease. Not required for OpenPose, enable it only if you intend to"
123 " explicitly use this information later.");
124 DEFINE_bool(heatmaps_add_bkg,
false,
"Same functionality as `add_heatmaps_parts`, but adding the heatmap corresponding to"
126 DEFINE_bool(heatmaps_add_PAFs,
false,
"Same functionality as `add_heatmaps_parts`, but adding the PAFs.");
127 DEFINE_int32(heatmaps_scale, 2,
"Set 0 to scale op::Datum::poseHeatMaps in the range [-1,1], 1 for [0,1]; 2 for integer"
128 " rounded [0,255]; and 3 for no scaling.");
129 DEFINE_bool(part_candidates,
false,
"Also enable `write_json` in order to save this information. If true, it will fill the"
130 " op::Datum::poseCandidates array with the body part candidates. Candidates refer to all"
131 " the detected body parts, before being assembled into people. Note that the number of"
132 " candidates is equal or higher than the number of final body parts (i.e., after being"
133 " assembled into people). The empty body parts are filled with 0s. Program speed will"
134 " slightly decrease. Not required for OpenPose, enable it only if you intend to explicitly"
135 " use this information.");
136 DEFINE_double(upsampling_ratio, 0.,
"Upsampling ratio between the `net_resolution` and the output net results. A value less"
137 " or equal than 0 (default) will use the network default value (recommended).");
139 DEFINE_bool(face,
false,
"Enables face keypoint detection. It will share some parameters from the body pose, e.g."
140 " `model_folder`. Note that this will considerable slow down the performance and increase"
141 " the required GPU memory. In addition, the greater number of people on the image, the"
142 " slower OpenPose will be.");
143 DEFINE_int32(face_detector, 0,
"Kind of face rectangle detector. Select 0 (default) to select OpenPose body detector (most"
144 " accurate one and fastest one if body is enabled), 1 to select OpenCV face detector (not"
145 " implemented for hands), 2 to indicate that it will be provided by the user, or 3 to"
146 " also apply hand tracking (only for hand). Hand tracking might improve hand keypoint"
147 " detection for webcam (if the frame rate is high enough, i.e., >7 FPS per GPU) and video."
148 " This is not person ID tracking, it simply looks for hands in positions at which hands were"
149 " located in previous frames, but it does not guarantee the same person ID among frames.");
150 DEFINE_string(face_net_resolution,
"368x368",
"Multiples of 16 and squared. Analogous to `net_resolution` but applied to the face keypoint"
151 " detector. 320x320 usually works fine while giving a substantial speed up when multiple"
152 " faces on the image.");
154 DEFINE_bool(hand,
false,
"Enables hand keypoint detection. It will share some parameters from the body pose, e.g."
155 " `model_folder`. Analogously to `--face`, it will also slow down the performance, increase"
156 " the required GPU memory and its speed depends on the number of people.");
157 DEFINE_int32(hand_detector, 0,
"Kind of hand rectangle detector. Analogous to `--face_detector`.");
158 DEFINE_string(hand_net_resolution,
"368x368",
"Multiples of 16 and squared. Analogous to `net_resolution` but applied to the hand keypoint"
160 DEFINE_int32(hand_scale_number, 1,
"Analogous to `scale_number` but applied to the hand keypoint detector. Our best results"
161 " were found with `hand_scale_number` = 6 and `hand_scale_range` = 0.4.");
162 DEFINE_double(hand_scale_range, 0.4,
"Analogous purpose than `scale_gap` but applied to the hand keypoint detector. Total range"
163 " between smallest and biggest scale. The scales will be centered in ratio 1. E.g., if"
164 " scaleRange = 0.4 and scalesNumber = 2, then there will be 2 scales, 0.8 and 1.2.");
166 DEFINE_bool(3d,
false,
"Running OpenPose 3-D reconstruction demo: 1) Reading from a stereo camera system."
167 " 2) Performing 3-D reconstruction from the multiple views. 3) Displaying 3-D reconstruction"
168 " results. Note that it will only display 1 person. If multiple people is present, it will"
170 DEFINE_int32(3d_min_views, -1,
"Minimum number of views required to reconstruct each keypoint. By default (-1), it will"
171 " require max(2, min(4, #cameras-1)) cameras to see the keypoint in order to reconstruct"
173 DEFINE_int32(3d_views, -1,
"Complementary option for `--image_dir` or `--video`. OpenPose will read as many images per"
174 " iteration, allowing tasks such as stereo camera processing (`--3d`). Note that"
175 " `--camera_parameter_path` must be set. OpenPose must find as many `xml` files in the"
176 " parameter folder as this number indicates.");
178 DEFINE_bool(identification,
false,
"Experimental, not available yet. Whether to enable people identification across frames.");
179 DEFINE_int32(tracking, -1,
"Experimental, not available yet. Whether to enable people tracking across frames. The"
180 " value indicates the number of frames where tracking is run between each OpenPose keypoint"
181 " detection. Select -1 (default) to disable it or 0 to run simultaneously OpenPose keypoint"
182 " detector and tracking for potentially higher accuracy than only OpenPose.");
183 DEFINE_int32(ik_threads, 0,
"Experimental, not available yet. Whether to enable inverse kinematics (IK) from 3-D"
184 " keypoints to obtain 3-D joint angles. By default (0 threads), it is disabled. Increasing"
185 " the number of threads will increase the speed but also the global system latency.");
187 DEFINE_int32(part_to_show, 0,
"Prediction channel to visualize: 0 (default) for all the body parts, 1 for the background"
188 " heat map, 2 for the superposition of heatmaps, 3 for the superposition of PAFs,"
189 " 4-(4+#keypoints) for each body part heat map, the following ones for each body part pair"
191 DEFINE_bool(disable_blending,
false,
"If enabled, it will render the results (keypoint skeletons or heatmaps) on a black"
192 " background, instead of being rendered into the original image. Related: `part_to_show`,"
193 " `alpha_pose`, and `alpha_pose`.");
195 DEFINE_double(render_threshold, 0.05,
"Only estimated keypoints whose score confidences are higher than this threshold will be"
196 " rendered. Note: Rendered refers only to visual display in the OpenPose basic GUI, not in"
197 " the saved results. Generally, a high threshold (> 0.5) will only render very clear body"
198 " parts; while small thresholds (~0.1) will also output guessed and occluded keypoints,"
199 " but also more false positives (i.e., wrong detections).");
200 DEFINE_int32(render_pose, -1,
"Set to 0 for no rendering, 1 for CPU rendering (slightly faster), and 2 for GPU rendering"
201 " (slower but greater functionality, e.g., `alpha_X` flags). If -1, it will pick CPU if"
202 " CPU_ONLY is enabled, or GPU if CUDA is enabled. If rendering is enabled, it will render"
203 " both `outputData` and `cvOutputData` with the original image and desired body part to be"
204 " shown (i.e., keypoints, heat maps or PAFs).");
205 DEFINE_double(alpha_pose, 0.6,
"Blending factor (range 0-1) for the body part rendering. 1 will show it completely, 0 will"
206 " hide it. Only valid for GPU rendering.");
207 DEFINE_double(alpha_heatmap, 0.7,
"Blending factor (range 0-1) between heatmap and original frame. 1 will only show the"
208 " heatmap, 0 will only show the frame. Only valid for GPU rendering.");
210 DEFINE_double(face_render_threshold, 0.4,
"Analogous to `render_threshold`, but applied to the face keypoints.");
211 DEFINE_int32(face_render, -1,
"Analogous to `render_pose` but applied to the face. Extra option: -1 to use the same"
212 " configuration that `render_pose` is using.");
213 DEFINE_double(face_alpha_pose, 0.6,
"Analogous to `alpha_pose` but applied to face.");
214 DEFINE_double(face_alpha_heatmap, 0.7,
"Analogous to `alpha_heatmap` but applied to face.");
216 DEFINE_double(hand_render_threshold, 0.2,
"Analogous to `render_threshold`, but applied to the hand keypoints.");
217 DEFINE_int32(hand_render, -1,
"Analogous to `render_pose` but applied to the hand. Extra option: -1 to use the same"
218 " configuration that `render_pose` is using.");
219 DEFINE_double(hand_alpha_pose, 0.6,
"Analogous to `alpha_pose` but applied to hand.");
220 DEFINE_double(hand_alpha_heatmap, 0.7,
"Analogous to `alpha_heatmap` but applied to hand.");
221 #ifndef OPENPOSE_FLAGS_DISABLE_DISPLAY
223 DEFINE_bool(fullscreen,
false,
"Run in full-screen mode (press f during runtime to toggle).");
224 DEFINE_bool(no_gui_verbose,
false,
"Do not write text on output images on GUI (e.g., number of current frame and people). It"
225 " does not affect the pose rendering.");
226 DEFINE_int32(display, -1,
"Display mode: -1 for automatic selection; 0 for no display (useful if there is no X server"
227 " and/or to slightly speed up the processing if visual output is not required); 2 for 2-D"
228 " display; 3 for 3-D display (if `--3d` enabled); and 1 for both 2-D and 3-D display.");
231 DEFINE_double(cli_verbose, -1.f,
"If -1, it will be disabled (default). If it is a positive integer number, it will print on"
232 " the command line every `verbose` frames. If number in the range (0,1), it will print the"
233 " progress every `verbose` times the total of frames.");
235 DEFINE_string(write_images,
"",
"Directory to write rendered frames in `write_images_format` image format.");
236 DEFINE_string(write_images_format,
"png",
"File extension and format for `write_images`, e.g., png, jpg or bmp. Check the OpenCV"
237 " function cv::imwrite for all compatible extensions.");
238 DEFINE_string(write_video,
"",
"Full file path to write rendered frames in motion JPEG video format. It might fail if the"
239 " final path does not finish in `.avi`. It internally uses cv::VideoWriter. Flag"
240 " `write_video_fps` controls FPS. Alternatively, the video extension can be `.mp4`,"
241 " resulting in a file with a much smaller size and allowing `--write_video_with_audio`."
242 " However, that would require: 1) Ubuntu or Mac system, 2) FFmpeg library installed"
243 " (`sudo apt-get install ffmpeg`), 3) the creation temporarily of a folder with the same"
244 " file path than the final video (without the extension) to storage the intermediate frames"
245 " that will later be used to generate the final MP4 video.");
246 DEFINE_double(write_video_fps, -1.,
"Frame rate for the recorded video. By default, it will try to get the input frames producer"
247 " frame rate (e.g., input video or webcam frame rate). If the input frames producer does not"
248 " have a set FPS (e.g., image_dir or webcam if OpenCV not compiled with its support), set"
249 " this value accordingly (e.g., to the frame rate displayed by the OpenPose GUI).");
250 DEFINE_bool(write_video_with_audio,
false,
"If the input is video and the output is so too, it will save the video with audio. It"
251 " requires the output video file path finishing in `.mp4` format (see `write_video` for"
253 DEFINE_string(write_video_3d,
"",
"Analogous to `--write_video`, but applied to the 3D output.");
254 DEFINE_string(write_video_adam,
"",
"Experimental, not available yet. Analogous to `--write_video`, but applied to Adam model.");
255 DEFINE_string(write_json,
"",
"Directory to write OpenPose output in JSON format. It includes body, hand, and face pose"
256 " keypoints (2-D and 3-D), as well as pose candidates (if `--part_candidates` enabled).");
257 DEFINE_string(write_coco_json,
"",
"Full file path to write people pose data with JSON COCO validation format. If foot, face,"
258 " hands, etc. JSON is also desired (`--write_coco_json_variants`), they are saved with"
259 " different file name suffix.");
260 DEFINE_int32(write_coco_json_variants, 1,
"Add 1 for body, add 2 for foot, 4 for face, and/or 8 for hands. Use 0 to use all the"
261 " possible candidates. E.g., 7 would mean body+foot+face COCO JSON.");
262 DEFINE_int32(write_coco_json_variant, 0,
"Currently, this option is experimental and only makes effect on car JSON generation. It"
263 " selects the COCO variant for cocoJsonSaver.");
264 DEFINE_string(write_heatmaps,
"",
"Directory to write body pose heatmaps in PNG format. At least 1 `add_heatmaps_X` flag"
265 " must be enabled.");
266 DEFINE_string(write_heatmaps_format,
"png",
"File extension and format for `write_heatmaps`, analogous to `write_images_format`."
267 " For lossless compression, recommended `png` for integer `heatmaps_scale` and `float` for"
268 " floating values. See `doc/02_output.md` for more details.");
269 DEFINE_string(write_keypoint,
"",
"(Deprecated, use `write_json`) Directory to write the people pose keypoint data. Set format"
270 " with `write_keypoint_format`.");
271 DEFINE_string(write_keypoint_format,
"yml",
"(Deprecated, use `write_json`) File extension and format for `write_keypoint`: json, xml,"
272 " yaml & yml. Json not available for OpenCV < 3.0, use `write_json` instead.");
274 DEFINE_string(write_bvh,
"",
"Experimental, not available yet. E.g., `~/Desktop/mocapResult.bvh`.");
276 DEFINE_string(udp_host,
"",
"Experimental, not available yet. IP for UDP communication. E.g., `192.168.0.1`.");
277 DEFINE_string(udp_port,
"8051",
"Experimental, not available yet. Port number for UDP communication.");
DEFINE_uint64(frame_first, 0, "Start on desired frame number. Indexes are 0-based, i.e., the first frame has index 0.")
DEFINE_int32(logging_level, 3, "The logging level. Integer in the range [0, 255]. 0 will output any opLog() 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_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_double(fps_max, -1., "Maximum processing frame rate. By default (-1), OpenPose will process frames as fast as" " possible. Example usage: If OpenPose is displaying images too quickly, this can reduce" " the speed so the user can analyze better each frame from the GUI.")
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.")