Skip to content

Commit 3a0e67c

Browse files
authored
Merge pull request #21 from davidpagnon/ik
- trc Z values not set to zeros but to coherent values based on visible side - c3d export - renamed a bunch of parameters
2 parents 0cc9120 + 06801e2 commit 3a0e67c

File tree

8 files changed

+612
-281
lines changed

8 files changed

+612
-281
lines changed

README.md

Lines changed: 297 additions & 182 deletions
Large diffs are not rendered by default.

Sports2D/Demo/Config_demo.toml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212

1313

1414
[project]
15-
video_input = 'demo.mp4' # 'webcam' or '<video_path.ext>', or ['video1_path.mp4', 'video2_path.avi>', ...]
16-
# On Windows, replace '\' with '/'
17-
# Beware that images won't be saved if paths contain non ASCII characters.
18-
person_height = 1.70 # Height of the person in meters (for pixels -> meters conversion)
19-
load_trc = '' # If you do not want to recalculate pose, load it from a trc file (in px, not in m)
20-
compare = false # Not implemented yet
15+
video_input = 'demo.mp4' # 'webcam' or '<video_path.ext>', or ['video1_path.mp4', 'video2_path.avi>', ...]
16+
# On Windows, replace '\' with '/'
17+
# Beware that images won't be saved if paths contain non ASCII characters.
18+
px_to_m_from_person_id = 2 # Person to use for pixels to meters conversion (not used if a calibration file is provided)
19+
px_to_m_person_height = 1.65 # Height of the reference person in meters (for pixels -> meters conversion).
20+
visible_side = ['front', 'none', 'auto'] # Choose visible side among ['right', 'left', 'front', 'back', 'auto', 'none']. String or list of strings.
21+
# if 'auto', will be either 'left', 'right', or 'front' depending on the direction of the motion
22+
# if 'none', no processing will be performed on the corresponding person
23+
load_trc_px = '' # If you do not want to recalculate pose, load it from a trc file (in px, not in m)
24+
compare = false # Not implemented yet
2125

2226
# Video parameters
2327
time_range = [] # [] for the whole video, or [start_time, end_time] (in seconds), or [[start_time1, end_time1], [start_time2, end_time2], ...]
@@ -67,15 +71,19 @@ mode = 'balanced' # 'lightweight', 'balanced', 'performance', or """{dictionary}
6771
# mode = """{'pose_class':'RTMO',
6872
# 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmo/onnx_sdk/rtmo-m_16xb16-600e_body7-640x640-39e78cc4_20231211.zip',
6973
# 'pose_input_size':[640, 640]}"""
74+
# Example with animal pose estimation:
75+
# mode = """{'pose_class':'RTMPose',
76+
# 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/onnx_sdk/rtmpose-m_simcc-ap10k_pt-aic-coco_210e-256x256-7a041aa1_20230206.zip',
77+
# 'pose_input_size':[256,256]}"""
7078

7179
det_frequency = 4 # Run person detection only every N frames, and inbetween track previously detected bounding boxes (keypoint detection is still run on all frames).
7280
# Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
7381
device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
7482
backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'
7583
tracking_mode = 'sports2d' # 'sports2d' or 'deepsort'. 'deepsort' is slower but more robust in difficult configurations
76-
deepsort_params = """{'max_age':30, 'n_init':3, 'nms_max_overlap':0.8, 'max_cosine_distance':0.3, 'nn_budget':200, 'max_iou_distance':0.8, 'embedder_gpu': True}""" # """{dictionary between 3 double quotes}"""
77-
# More robust in crowded scenes but Can be tricky to parametrize. More information there: https://github.com/levan92/deep_sort_realtime/blob/master/deep_sort_realtime/deepsort_tracker.py#L51
78-
# Note: For faster and more robust tracking, use {'embedder_gpu': True, embedder':'torchreid'}, which uses the GPU and runs osnet_ain_x1_0 by default. requires `pip install torch torchvision torchreid gdown tensorboard`
84+
deepsort_params = """{'max_age':30, 'n_init':3, 'max_cosine_distance':0.3, 'max_iou_distance':0.8, 'embedder_gpu': True, embedder':'torchreid'}""" # """{dictionary between 3 double quotes}"""
85+
# More robust in crowded scenes but tricky to parametrize. More information there: https://github.com/levan92/deep_sort_realtime/blob/master/deep_sort_realtime/deepsort_tracker.py#L51
86+
# Requires `pip install torch torchvision torchreid gdown tensorboard`
7987

8088

8189
# Processing parameters
@@ -87,13 +95,15 @@ keypoint_number_threshold = 0.3 # Person will be ignored if the number of go
8795
[px_to_meters_conversion]
8896
# Pixel to meters conversion
8997
to_meters = true
90-
# If conversion from a calibration file
91-
calib_file = '' # Calibration in the Pose2Sim format. 'calib_demo.toml', or '' if not available
92-
# If conversion from person_height
93-
calib_on_person_id = 0 # Person to use for calibration
98+
make_c3d = true
99+
save_calib = true # Coming soon!
100+
101+
# If conversion from px_to_m_person_height
94102
floor_angle = 'auto' # 'auto' or a value in degrees, eg 2.3. If 'auto', estimated from the line formed by the toes when they are on the ground (where speed = 0)
95103
xy_origin = ['auto'] # ['auto'] or [px_x,px_y]. N.B.: px_y points downwards. If ['auto'], direction estimated from the start to the end of the line formed by the toes when they are on the ground
96-
save_calib = true
104+
105+
# If conversion from a calibration file
106+
calib_file = '' # Calibration in the Pose2Sim format. 'calib_demo.toml', or '' if not available
97107

98108
fastest_frames_to_remove_percent = 0.1 # Frames with high speed are considered as outliers
99109
close_to_zero_speed_px = 50 # Sum for all keypoints: about 50 px/frame or 0.2 m/frame
@@ -136,15 +146,20 @@ filter_type = 'butterworth' # butterworth, gaussian, LOESS, median
136146
kernel_size = 3
137147

138148

139-
[inverse-kinematics]
149+
[kinematics]
140150
do_ik = false # Do scaling and inverse kinematics?
141-
person_orientation = ['front', 'none', 'left'] # Choose among 'auto', 'none', 'front', 'back', 'left', 'right'
142-
# if 'none', no IK will be performed on the corresponding person
143-
# if 'auto', will be either 'left' or 'right' depending on the direction of the motion
144-
# Example with one person on one video: ['front']
145-
# Or ['front', 'none', 'left'] with 3 persons on one video
151+
use_augmentation = true # true or false (lowercase) # Set to true if you want to use the model with augmented markers
152+
use_contacts_muscles = true # true or false (lowercase) # If true, contact spheres and muscles are added to the model
153+
146154
osim_setup_path = '../OpenSim_setup' # Path to the OpenSim setup folder
147-
close_to_zero_speed_m = 0.2 # Sum for all keypoints: about 50 px/frame or 0.2 m/frame
155+
right_left_symmetry = true # true or false (lowercase) # Set to false only if you have good reasons to think the participant is not symmetrical (e.g. prosthetic limb)
156+
# default_height = 1.7 # meters # If automatic height calculation did not work, this value is used to scale the model
157+
remove_individual_scaling_setup = true # true or false (lowercase) # If true, the individual scaling setup files are removed to avoid cluttering
158+
remove_individual_ik_setup = true # true or false (lowercase) # If true, the individual IK setup files are removed to avoid cluttering
159+
fastest_frames_to_remove_percent = 0.1 # Frames with high speed are considered as outliers
160+
close_to_zero_speed_m = 0.2 # Sum for all keypoints: about 50 px/frame or 0.2 m/frame
161+
large_hip_knee_angles = 45 # Hip and knee angles below this value are considered as imprecise
162+
trimmed_extrema_percent = 0.5 # Proportion of the most extreme segment values to remove before calculating their mean)
148163

149164

150165
[logging]

Sports2D/Sports2D.py

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@
122122

123123
## CONSTANTS
124124
DEFAULT_CONFIG = {'project': {'video_input': ['demo.mp4'],
125-
'person_height': 1.70,
126-
'load_trc': '',
125+
'px_to_m_from_person_id': 2,
126+
'px_to_m_person_height': 1.65,
127+
'visible_side': ['front', 'auto'],
128+
'load_trc_px': '',
127129
'compare': False,
128130
'time_range': [],
129131
'video_dir': '',
@@ -153,8 +155,8 @@
153155
},
154156
'px_to_meters_conversion': {
155157
'to_meters': True,
158+
'make_c3d': True,
156159
'calib_file': '',
157-
'calib_on_person_id': 0,
158160
'floor_angle': 'auto',
159161
'xy_origin': ['auto'],
160162
'save_calib': True,
@@ -205,18 +207,27 @@
205207
'loess': {'nb_values_used': 5},
206208
'median': {'kernel_size': 3}
207209
},
208-
'inverse-kinematics':{'do_ik': False,
209-
'person_orientation': ['front', '', 'left'],
210-
'osim_setup_path': '../OpenSim_setup',
211-
'close_to_zero_speed_m': 0.2
210+
'kinematics':{'do_ik': False,
211+
'use_augmentation': False,
212+
'use_contacts_muscles': False,
213+
'right_left_symmetry': True,
214+
'default_height': 1.70,
215+
'remove_individual_scaling_setup': True,
216+
'remove_individual_ik_setup': True,
217+
'fastest_frames_to_remove_percent': 0.1,
218+
'close_to_zero_speed_m': 0.2,
219+
'large_hip_knee_angles': 45,
220+
'trimmed_extrema_percent': 0.5,
221+
'osim_setup_path': '../OpenSim_setup'
212222
},
213223
'logging': {'use_custom_logging': False}
214224
}
215225

216226
CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
217227
'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"],
218-
'person_height': ["H", "height of the person in meters. 1.70 if not specified"],
219-
'load_trc': ["", "load trc file to avaid running pose estimation again. false if not specified"],
228+
'px_to_m_person_height': ["H", "height of the person in meters. 1.70 if not specified"],
229+
'visible_side': ["", "front, back, left, right, auto, or none. 'front auto' if not specified. If 'auto', will be either left or right depending on the direction of the motion. If 'none', no IK for this person"],
230+
'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
220231
'compare': ["", "visually compare motion with trc file. false if not specified"],
221232
'webcam_id': ["w", "webcam ID. 0 if not specified"],
222233
'time_range': ["t", "start_time end_time. In seconds. Whole video if not specified. start_time1 end_time1 start_time2 end_time2 ... if multiple videos with different time ranges"],
@@ -240,19 +251,21 @@
240251
'backend': ["", "Backend for pose estimation can be 'auto', 'cpu', 'cuda', 'mps' (for MacOS), or 'rocm' (for AMD GPUs)"],
241252
'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
242253
'to_meters': ["M", "convert pixels to meters. true if not specified"],
243-
'calib_on_person_id': ["", "person ID to calibrate on. 0 if not specified"],
254+
'make_c3d': ["", "Convert trc to c3d file. true if not specified"],
255+
'px_to_m_from_person_id': ["", "person ID to calibrate on. 0 if not specified"],
244256
'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
245257
'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
246258
'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
247259
'save_calib': ["", "save calibration file. true if not specified"],
248260
'do_ik': ["", "do inverse kinematics. false if not specified"],
249-
'osim_setup_path': ["", "path to OpenSim setup. '../OpenSim_setup' if not specified"],
250-
'person_orientation': ["", "front, back, left, right, auto, or none. 'front none left' if not specified. If 'auto', will be either left or right depending on the direction of the motion."],
261+
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
262+
'use_contacts_muscles': ["", "Use model with contact spheres and muscles. false if not specified"],
251263
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
252264
'multiperson': ["", "multiperson involves tracking: will be faster if set to false. true if not specified"],
253265
'tracking_mode': ["", "sports2d or rtmlib. sports2d is generally much more accurate and comparable in speed. sports2d if not specified"],
254266
'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
255-
More information there: https://github.com/levan92/deep_sort_realtime/blob/master/deep_sort_realtime/deepsort_tracker.py#L51'], #
267+
Default: max_age:30, n_init:3, nms_max_overlap:0.8, max_cosine_distance:0.3, nn_budget:200, max_iou_distance:0.8, embedder_gpu: True\n\
268+
More information there: https://github.com/levan92/deep_sort_realtime/blob/master/deep_sort_realtime/deepsort_tracker.py#L51'],
256269
'input_size': ["", "width, height. 1280, 720 if not specified. Lower resolution will be faster but less precise"],
257270
'keypoint_likelihood_threshold': ["", "detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"],
258271
'average_likelihood_threshold': ["", "detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"],
@@ -274,6 +287,15 @@
274287
'sigma_kernel': ["", "sigma of the gaussian filter. 1 if not specified"],
275288
'nb_values_used': ["", "number of values used for the loess filter. 5 if not specified"],
276289
'kernel_size': ["", "kernel size of the median filter. 3 if not specified"],
290+
'osim_setup_path': ["", "path to OpenSim setup. '../OpenSim_setup' if not specified"],
291+
'right_left_symmetry': ["", "right left symmetry. true if not specified"],
292+
'default_height': ["", "default height for scaling. 1.70 if not specified"],
293+
'remove_individual_scaling_setup': ["", "remove individual scaling setup files generated during scaling. true if not specified"],
294+
'remove_individual_ik_setup': ["", "remove individual IK setup files generated during IK. true if not specified"],
295+
'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
296+
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
297+
'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise and ignored. Defaults to 45"],
298+
'trimmed_extrema_percent': ["", "Proportion of the most extreme segment values to remove before calculating their mean. Defaults to 50"],
277299
'use_custom_logging': ["", "use custom logging. false if not specified"]
278300
}
279301

0 commit comments

Comments
 (0)