|
175 | 175 | 'interp_gap_smaller_than': 10,
|
176 | 176 | 'fill_large_gaps_with': 'last_value',
|
177 | 177 | 'filter': True,
|
178 |
| - 'show_plots': True, |
| 178 | + 'show_graphs': True, |
179 | 179 | 'filter_type': 'butterworth',
|
180 | 180 | 'butterworth': {'order': 4, 'cut_off_frequency': 3},
|
181 | 181 | 'gaussian': {'sigma_kernel': 1},
|
|
184 | 184 | }
|
185 | 185 | }
|
186 | 186 |
|
187 |
| -CONFIG_HELP = {'config': "Path to a toml configuration file", |
188 |
| - 'video_input': "webcam, or video_path.mp4, or video1_path.avi video2_path.mp4 ... Beware that images won't be saved if paths contain non ASCII characters", |
189 |
| - 'time_range': "start_time, end_time. In seconds. Whole video if not specified", |
190 |
| - 'video_dir': "Current directory if not specified", |
191 |
| - 'webcam_id': "webcam ID. 0 if not specified", |
192 |
| - 'input_size': "width, height. 1280, 720 if not specified. Lower resolution will be faster but less precise", |
193 |
| - 'multiperson': "Multiperson involves tracking: will be faster if set to false. true if not specified", |
194 |
| - 'show_realtime_results': "show results in real-time. true if not specified", |
195 |
| - 'save_vid': "save processed video. true if not specified", |
196 |
| - 'save_img': "save processed images. true if not specified", |
197 |
| - 'save_pose': "save pose as trc files. true if not specified", |
198 |
| - 'save_angles': "save angles as mot files. true if not specified", |
199 |
| - 'result_dir': "Current directory if not specified", |
200 |
| - 'pose_model': "Only body_with_feet is available for now. body_with_feet if not specified", |
201 |
| - 'mode': "light, balanced, or performance. balanced if not specified", |
202 |
| - 'det_frequency': "Run person detection only every N frames, and inbetween track previously detected bounding boxes. keypoint detection is still run on all frames.\n\ |
203 |
| - Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate. 1 if not specified: detection runs on all frames", |
204 |
| - 'tracking_mode': "sports2d or rtmlib. sports2d is generally much more accurate and comparable in speed. sports2d if not specified", |
205 |
| - 'keypoint_likelihood_threshold': "Detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified", |
206 |
| - 'average_likelihood_threshold': "Detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified", |
207 |
| - 'keypoint_number_threshold': "Detected persons are not retained if number of detected keypoints is below this threshold. 0.3 if not specified, i.e., i.e., 30 percent", |
208 |
| - 'display_angle_values_on': "body, list, or body list. body list if not specified", |
209 |
| - 'fontSize': "Font size for angle values. 0.3 if not specified", |
210 |
| - 'joint_angles': '"Right ankle" "Left ankle" "Right knee" "Left knee" "Right hip" "Left hip" "Right shoulder" "Left shoulder" "Right elbow" "Left elbow" if not specified', |
211 |
| - 'segment_angles': '"Right foot" "Left foot" "Right shank" "Left shank" "Right thigh" "Left thigh" "Pelvis" "Trunk" "Shoulders" "Head" "Right arm" "Left arm" "Right forearm" "Left forearm" if not specified', |
212 |
| - 'flip_left_right': "true or false. true to get consistent angles with people facing both left and right sides. Set it to false if you want timeseries to be continuous even when the participent switches their stance. true if not specified", |
213 |
| - 'interpolate': "Interpolate missing data. true if not specified", |
214 |
| - 'interp_gap_smaller_than': "Interpolate sequences of missing data if they are less than N frames long. 10 if not specified", |
215 |
| - 'fill_large_gaps_with': "last_value, nan, or zeros. last_value if not specified", |
216 |
| - 'filter': "Filter results. true if not specified", |
217 |
| - 'show_plots': "Show plots. true if not specified", |
218 |
| - 'filter_type': "butterworth, gaussian, median, or loess. butterworth if not specified", |
219 |
| - 'order': "Order of the Butterworth filter. 4 if not specified", |
220 |
| - 'cut_off_frequency': "Cut-off frequency of the Butterworth filter. 3 if not specified", |
221 |
| - 'sigma_kernel': "Sigma of the gaussian filter. 1 if not specified", |
222 |
| - 'nb_values_used': "Number of values used for the loess filter. 5 if not specified", |
223 |
| - 'kernel_size': "Kernel size of the median filter. 3 if not specified" |
| 187 | +CONFIG_HELP = {'config': ["c", "Path to a toml configuration file"], |
| 188 | + 'video_input': ["i", "webcam, or video_path.mp4, or video1_path.avi video2_path.mp4 ... Beware that images won't be saved if paths contain non ASCII characters"], |
| 189 | + 'webcam_id': ["w", "webcam ID. 0 if not specified"], |
| 190 | + 'time_range': ["t", "start_time, end_time. In seconds. Whole video if not specified"], |
| 191 | + 'video_dir': ["d", "Current directory if not specified"], |
| 192 | + 'result_dir': ["r", "Current directory if not specified"], |
| 193 | + 'show_realtime_results': ["R", "show results in real-time. true if not specified"], |
| 194 | + 'display_angle_values_on': ["a", '"body", "list", "body" "list", or "None". body list if not specified'], |
| 195 | + 'show_graphs': ["G", "Show plots of raw and processed results. true if not specified"], |
| 196 | + 'joint_angles': ["j", '"Right ankle" "Left ankle" "Right knee" "Left knee" "Right hip" "Left hip" "Right shoulder" "Left shoulder" "Right elbow" "Left elbow" if not specified'], |
| 197 | + 'segment_angles': ["s", '"Right foot" "Left foot" "Right shank" "Left shank" "Right thigh" "Left thigh" "Pelvis" "Trunk" "Shoulders" "Head" "Right arm" "Left arm" "Right forearm" "Left forearm" if not specified'], |
| 198 | + 'save_vid': ["V", "save processed video. true if not specified"], |
| 199 | + 'save_img': ["I", "save processed images. true if not specified"], |
| 200 | + 'save_pose': ["P", "save pose as trc files. true if not specified"], |
| 201 | + 'save_angles': ["A", "save angles as mot files. true if not specified"], |
| 202 | + 'pose_model': ["p", "Only body_with_feet is available for now. body_with_feet if not specified"], |
| 203 | + 'mode': ["m", "light, balanced, or performance. balanced if not specified"], |
| 204 | + 'det_frequency': ["f", "Run person detection only every N frames, and inbetween track previously detected bounding boxes. keypoint detection is still run on all frames.\n\ |
| 205 | + Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate. 1 if not specified: detection runs on all frames"], |
| 206 | + 'multiperson': ["M", "Multiperson involves tracking: will be faster if set to false. true if not specified"], |
| 207 | + 'tracking_mode': ["", "sports2d or rtmlib. sports2d is generally much more accurate and comparable in speed. sports2d if not specified"], |
| 208 | + 'input_size': ["", "width, height. 1280, 720 if not specified. Lower resolution will be faster but less precise"], |
| 209 | + 'keypoint_likelihood_threshold': ["", "Detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"], |
| 210 | + 'average_likelihood_threshold': ["", "Detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"], |
| 211 | + 'keypoint_number_threshold': ["", "Detected persons are not retained if number of detected keypoints is below this threshold. 0.3 if not specified, i.e., i.e., 30 percent"], |
| 212 | + 'fontSize': ["", "Font size for angle values. 0.3 if not specified"], |
| 213 | + 'flip_left_right': ["", "true or false. true to get consistent angles with people facing both left and right sides. Set it to false if you want timeseries to be continuous even when the participent switches their stance. true if not specified"], |
| 214 | + 'interpolate': ["", "Interpolate missing data. true if not specified"], |
| 215 | + 'interp_gap_smaller_than': ["", "Interpolate sequences of missing data if they are less than N frames long. 10 if not specified"], |
| 216 | + 'fill_large_gaps_with': ["", "last_value, nan, or zeros. last_value if not specified"], |
| 217 | + 'filter': ["", "Filter results. true if not specified"], |
| 218 | + 'filter_type': ["", "butterworth, gaussian, median, or loess. butterworth if not specified"], |
| 219 | + 'order': ["", "Order of the Butterworth filter. 4 if not specified"], |
| 220 | + 'cut_off_frequency': ["", "Cut-off frequency of the Butterworth filter. 3 if not specified"], |
| 221 | + 'sigma_kernel': ["", "Sigma of the gaussian filter. 1 if not specified"], |
| 222 | + 'nb_values_used': ["", "Number of values used for the loess filter. 5 if not specified"], |
| 223 | + 'kernel_size': ["", "Kernel size of the median filter. 3 if not specified"] |
224 | 224 | }
|
225 | 225 |
|
226 | 226 |
|
@@ -415,16 +415,19 @@ def main():
|
415 | 415 |
|
416 | 416 | # Dynamically add arguments for each leaf key in the DEFAULT_CONFIG
|
417 | 417 | parser = argparse.ArgumentParser(description="Use sports2d to compute your athlete's pose, joint, and segment angles. See https://github.com/davidpagnon/Sports2D")
|
418 |
| - parser.add_argument('--config', type=str, required=False, help='Path to a toml configuration file') |
| 418 | + parser.add_argument('-C', '--config', type=str, required=False, help='Path to a toml configuration file') |
| 419 | + |
419 | 420 | leaf_keys = get_leaf_keys(DEFAULT_CONFIG)
|
420 |
| - for key in leaf_keys: |
421 |
| - leaf_name = key.split('.')[-1] |
422 |
| - if type(leaf_keys[key]) == bool: |
423 |
| - parser.add_argument(f'--{leaf_name}', type=str2bool, help=CONFIG_HELP[leaf_name]) |
424 |
| - elif type(leaf_keys[key]) == list: |
425 |
| - parser.add_argument(f'--{leaf_name}', type=type(leaf_keys[key][0]), nargs='*', help=CONFIG_HELP[leaf_name]) |
| 421 | + leaf_keys = {k.split('.')[-1]:v for k,v in leaf_keys.items()} |
| 422 | + for leaf_name in list(CONFIG_HELP.keys())[1:]: |
| 423 | + short_key = CONFIG_HELP[leaf_name][0] |
| 424 | + arg_str = [f'-{short_key}', f'--{leaf_name}'] if short_key else [f'--{leaf_name}'] |
| 425 | + if type(leaf_keys[leaf_name]) == bool: |
| 426 | + parser.add_argument(*arg_str, type=str2bool, help=CONFIG_HELP[leaf_name][1]) |
| 427 | + elif type(leaf_keys[leaf_name]) == list: |
| 428 | + parser.add_argument(*arg_str, type=type(leaf_keys[leaf_name][0]), nargs='*', help=CONFIG_HELP[leaf_name][1]) |
426 | 429 | else:
|
427 |
| - parser.add_argument(f'--{leaf_name}', type=type(leaf_keys[key]), help=CONFIG_HELP[leaf_name]) |
| 430 | + parser.add_argument(*arg_str, type=type(leaf_keys[leaf_name]), help=CONFIG_HELP[leaf_name][1]) |
428 | 431 | args = parser.parse_args()
|
429 | 432 |
|
430 | 433 | # If config.toml file is provided, load it, else, use default config
|
|
0 commit comments