sports2d 0.6.1__py3-none-any.whl → 0.6.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Sports2D/Demo/Config_demo.toml +40 -22
- Sports2D/Sports2D.py +39 -13
- Sports2D/Utilities/common.py +477 -20
- Sports2D/Utilities/skeletons.py +7 -8
- Sports2D/Utilities/tests.py +3 -3
- Sports2D/process.py +162 -326
- {sports2d-0.6.1.dist-info → sports2d-0.6.3.dist-info}/METADATA +306 -182
- sports2d-0.6.3.dist-info/RECORD +16 -0
- sports2d-0.6.1.dist-info/RECORD +0 -16
- {sports2d-0.6.1.dist-info → sports2d-0.6.3.dist-info}/LICENSE +0 -0
- {sports2d-0.6.1.dist-info → sports2d-0.6.3.dist-info}/WHEEL +0 -0
- {sports2d-0.6.1.dist-info → sports2d-0.6.3.dist-info}/entry_points.txt +0 -0
- {sports2d-0.6.1.dist-info → sports2d-0.6.3.dist-info}/top_level.txt +0 -0
Sports2D/Demo/Config_demo.toml
CHANGED
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
[project]
|
|
15
|
-
video_input = 'demo.mp4'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
21
25
|
|
|
22
26
|
# Video parameters
|
|
23
27
|
time_range = [] # [] for the whole video, or [start_time, end_time] (in seconds), or [[start_time1, end_time1], [start_time2, end_time2], ...]
|
|
@@ -54,7 +58,7 @@ mode = 'balanced' # 'lightweight', 'balanced', 'performance', or """{dictionary}
|
|
|
54
58
|
|
|
55
59
|
# A dictionary (WITHIN THREE DOUBLE QUOTES) allows you to manually select the person detection (if top_down approach) and/or pose estimation models (see https://github.com/Tau-J/rtmlib).
|
|
56
60
|
# Models can be local paths or URLs.
|
|
57
|
-
# Make sure the input_sizes are within
|
|
61
|
+
# Make sure the input_sizes are within square brackets, and that they are in the opposite order from the one in the model path (for example, it would be [192,256] for rtmpose-m_simcc-body7_pt-body7-halpe26_700e-256x192-4d3e73dd_20230605.zip).
|
|
58
62
|
# If your pose_model is not provided in skeletons.py, you may have to create your own one (see example at the end of the file).
|
|
59
63
|
# Example, equivalent to mode='balanced':
|
|
60
64
|
# mode = """{'det_class':'YOLOX',
|
|
@@ -67,30 +71,39 @@ mode = 'balanced' # 'lightweight', 'balanced', 'performance', or """{dictionary}
|
|
|
67
71
|
# mode = """{'pose_class':'RTMO',
|
|
68
72
|
# 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmo/onnx_sdk/rtmo-m_16xb16-600e_body7-640x640-39e78cc4_20231211.zip',
|
|
69
73
|
# '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]}"""
|
|
70
78
|
|
|
71
|
-
det_frequency =
|
|
79
|
+
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).
|
|
72
80
|
# Equal to or greater than 1, can be as high as you want in simple uncrowded cases. Much faster, but might be less accurate.
|
|
73
81
|
device = 'auto' # 'auto', 'CPU', 'CUDA', 'MPS', 'ROCM'
|
|
74
82
|
backend = 'auto' # 'auto', 'openvino', 'onnxruntime', 'opencv'
|
|
75
|
-
tracking_mode = 'sports2d' # '
|
|
83
|
+
tracking_mode = 'sports2d' # 'sports2d' or 'deepsort'. 'deepsort' is slower but more robust in difficult configurations
|
|
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`
|
|
76
87
|
|
|
77
88
|
|
|
78
89
|
# Processing parameters
|
|
79
90
|
keypoint_likelihood_threshold = 0.3 # Keypoints whose likelihood is lower will not be taken into account
|
|
80
91
|
average_likelihood_threshold = 0.5 # Person will be ignored if average likelihood of good keypoints is lower than this value
|
|
81
|
-
keypoint_number_threshold = 0.3 # Person will be ignored if the number of good keypoints is less than this fraction
|
|
92
|
+
keypoint_number_threshold = 0.3 # Person will be ignored if the number of good keypoints (above keypoint_likelihood_threshold) is less than this fraction
|
|
82
93
|
|
|
83
94
|
|
|
84
95
|
[px_to_meters_conversion]
|
|
85
96
|
# Pixel to meters conversion
|
|
86
97
|
to_meters = true
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
make_c3d = true
|
|
99
|
+
save_calib = true # Coming soon!
|
|
100
|
+
|
|
101
|
+
# If conversion from px_to_m_person_height
|
|
91
102
|
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)
|
|
92
103
|
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
|
|
93
|
-
|
|
104
|
+
|
|
105
|
+
# If conversion from a calibration file
|
|
106
|
+
calib_file = '' # Calibration in the Pose2Sim format. 'calib_demo.toml', or '' if not available
|
|
94
107
|
|
|
95
108
|
fastest_frames_to_remove_percent = 0.1 # Frames with high speed are considered as outliers
|
|
96
109
|
close_to_zero_speed_px = 50 # Sum for all keypoints: about 50 px/frame or 0.2 m/frame
|
|
@@ -133,15 +146,20 @@ filter_type = 'butterworth' # butterworth, gaussian, LOESS, median
|
|
|
133
146
|
kernel_size = 3
|
|
134
147
|
|
|
135
148
|
|
|
136
|
-
[
|
|
149
|
+
[kinematics]
|
|
137
150
|
do_ik = false # Do scaling and inverse kinematics?
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
# Example with one person on one video: ['front']
|
|
142
|
-
# 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
|
+
|
|
143
154
|
osim_setup_path = '../OpenSim_setup' # Path to the OpenSim setup folder
|
|
144
|
-
|
|
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)
|
|
145
163
|
|
|
146
164
|
|
|
147
165
|
[logging]
|
Sports2D/Sports2D.py
CHANGED
|
@@ -122,8 +122,10 @@ from Sports2D import Sports2D
|
|
|
122
122
|
|
|
123
123
|
## CONSTANTS
|
|
124
124
|
DEFAULT_CONFIG = {'project': {'video_input': ['demo.mp4'],
|
|
125
|
-
'
|
|
126
|
-
'
|
|
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': '',
|
|
127
129
|
'compare': False,
|
|
128
130
|
'time_range': [],
|
|
129
131
|
'video_dir': '',
|
|
@@ -146,14 +148,15 @@ DEFAULT_CONFIG = {'project': {'video_input': ['demo.mp4'],
|
|
|
146
148
|
'device': 'auto',
|
|
147
149
|
'backend': 'auto',
|
|
148
150
|
'tracking_mode': 'sports2d',
|
|
151
|
+
'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}""",
|
|
149
152
|
'keypoint_likelihood_threshold': 0.3,
|
|
150
153
|
'average_likelihood_threshold': 0.5,
|
|
151
154
|
'keypoint_number_threshold': 0.3
|
|
152
155
|
},
|
|
153
156
|
'px_to_meters_conversion': {
|
|
154
157
|
'to_meters': True,
|
|
158
|
+
'make_c3d': True,
|
|
155
159
|
'calib_file': '',
|
|
156
|
-
'calib_on_person_id': 0,
|
|
157
160
|
'floor_angle': 'auto',
|
|
158
161
|
'xy_origin': ['auto'],
|
|
159
162
|
'save_calib': True,
|
|
@@ -204,18 +207,27 @@ DEFAULT_CONFIG = {'project': {'video_input': ['demo.mp4'],
|
|
|
204
207
|
'loess': {'nb_values_used': 5},
|
|
205
208
|
'median': {'kernel_size': 3}
|
|
206
209
|
},
|
|
207
|
-
'
|
|
208
|
-
'
|
|
209
|
-
'
|
|
210
|
-
'
|
|
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'
|
|
211
222
|
},
|
|
212
223
|
'logging': {'use_custom_logging': False}
|
|
213
224
|
}
|
|
214
225
|
|
|
215
226
|
CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
216
227
|
'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"],
|
|
217
|
-
'
|
|
218
|
-
'
|
|
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"],
|
|
219
231
|
'compare': ["", "visually compare motion with trc file. false if not specified"],
|
|
220
232
|
'webcam_id': ["w", "webcam ID. 0 if not specified"],
|
|
221
233
|
'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"],
|
|
@@ -239,16 +251,21 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
239
251
|
'backend': ["", "Backend for pose estimation can be 'auto', 'cpu', 'cuda', 'mps' (for MacOS), or 'rocm' (for AMD GPUs)"],
|
|
240
252
|
'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
|
|
241
253
|
'to_meters': ["M", "convert pixels to meters. true if not specified"],
|
|
242
|
-
'
|
|
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"],
|
|
243
256
|
'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
|
|
244
257
|
'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
|
|
245
258
|
'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
|
|
246
259
|
'save_calib': ["", "save calibration file. true if not specified"],
|
|
247
260
|
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
248
|
-
'
|
|
249
|
-
'
|
|
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"],
|
|
250
263
|
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
|
|
251
|
-
'multiperson': ["", "multiperson involves tracking: will be faster if set to false. true if not specified"],
|
|
264
|
+
'multiperson': ["", "multiperson involves tracking: will be faster if set to false. true if not specified"],
|
|
265
|
+
'tracking_mode': ["", "sports2d or rtmlib. sports2d is generally much more accurate and comparable in speed. sports2d if not specified"],
|
|
266
|
+
'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
|
|
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'],
|
|
252
269
|
'input_size': ["", "width, height. 1280, 720 if not specified. Lower resolution will be faster but less precise"],
|
|
253
270
|
'keypoint_likelihood_threshold': ["", "detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"],
|
|
254
271
|
'average_likelihood_threshold': ["", "detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"],
|
|
@@ -270,6 +287,15 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
270
287
|
'sigma_kernel': ["", "sigma of the gaussian filter. 1 if not specified"],
|
|
271
288
|
'nb_values_used': ["", "number of values used for the loess filter. 5 if not specified"],
|
|
272
289
|
'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"],
|
|
273
299
|
'use_custom_logging': ["", "use custom logging. false if not specified"]
|
|
274
300
|
}
|
|
275
301
|
|