sports2d 0.8.24__py3-none-any.whl → 0.8.26__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.
Binary file
@@ -97,7 +97,8 @@ tracking_mode = 'sports2d' # 'sports2d' or 'deepsort'. 'deepsort' is slower, har
97
97
  keypoint_likelihood_threshold = 0.3 # Keypoints whose likelihood is lower will not be taken into account
98
98
  average_likelihood_threshold = 0.5 # Person will be ignored if average likelihood of good keypoints is lower than this value
99
99
  keypoint_number_threshold = 0.3 # Person will be ignored if the number of good keypoints (above keypoint_likelihood_threshold) is less than this fraction
100
- max_distance = 100 # in px or None # If a person is detected further than max_distance from its position on the previous frame, it will be considered as a new one
100
+ max_distance = 250 # in px or None # If a person is detected further than max_distance from its position on the previous frame, it will be considered as a new one
101
+
101
102
 
102
103
  [px_to_meters_conversion]
103
104
  # Pixel to meters conversion
@@ -105,15 +106,20 @@ to_meters = true
105
106
  make_c3d = true
106
107
  save_calib = true
107
108
 
108
- # If conversion from first_person_height
109
- 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)
110
- 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
109
+ # Compensate for camera horizon
110
+ floor_angle = 'auto' # float, 'from_kinematics', 'from_calib', or 'auto' # 'auto' is equivalent to 'from_kinematics', ie angle calculated from foot contacts. 'from_calib' calculates it from a toml calibration file. Use float to manually specify it in degrees
111
+ xy_origin = ['auto'] # [px_x,px_y], or ['from kinematics'], ['from_calib'], or ['auto']. # BETWEEN BRACKETS! # ['auto'] is equivalent to ['from_kinematics'], ie origin estimated at first foot contact, direction is direction of motion. ['from_calib'] calculates it from a calibration file. Use [px_x,px_y] to manually specify it in pixels (px_y points downwards)
112
+
113
+ # Compensate for perspective effects, which make the further limb look smaller. 1-2% coordinate error at 10 m, less if the camera is further away
114
+ perspective_value = 10 # Either camera-to-person distance (m), or focal length (px), or field-of-view (degrees or radians), or '' if perspective_unit=='from_calib'
115
+ perspective_unit = 'distance_m' # 'distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib'
116
+
117
+ # Optional distortion coefficients
118
+ distortions = [0.0, 0.0, 0.0, 0.0, 0.0] # [k1, k2, p1, p2, k3] or 'from_calib' (not implemented yet)
119
+
120
+ # Optional calibration file
121
+ calib_file = '' # Calibration file in the Pose2Sim toml format, or '' if not available
111
122
 
112
- # If conversion from a calibration file
113
- calib_file = '' # Calibration in the Pose2Sim format. 'calib_demo.toml', or '' if not available
114
- # subject_distance
115
- # focal_distance
116
- # recalculate_extrinsics
117
123
 
118
124
  [angles]
119
125
  display_angle_values_on = ['body', 'list'] # 'body', 'list', ['body', 'list'], 'none'. Display angle values on the body, as a list in the upper left of the image, both, or do not display them.
@@ -127,7 +133,7 @@ joint_angles = ['Right ankle', 'Left ankle', 'Right knee', 'Left knee', 'Right h
127
133
  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']
128
134
 
129
135
  # Processing parameters
130
- flip_left_right = true # Same angles whether the participant faces left/right. Set it to false if you want timeseries to be continuous even when the participant switches their stance.
136
+ flip_left_right = false # Same angles whether the participant faces left/right. Set it to false if you want timeseries to be continuous even when the participant switches their stance.
131
137
  correct_segment_angles_with_floor_angle = true # If the camera is tilted, corrects segment angles as regards to the floor angle. Set to false if it is the floor which is actually tilted
132
138
 
133
139
 
@@ -209,7 +215,7 @@ use_custom_logging = false # if integrated in an API that already has logging
209
215
  #
210
216
  # Check your model hierarchy with: for pre, _, node in RenderTree(model):
211
217
  # print(f'{pre}{node.name} id={node.id}')
212
- [pose.CUSTOM]
218
+ [[pose.CUSTOM]]
213
219
  name = "Hip"
214
220
  id = 19
215
221
  [[pose.CUSTOM.children]]
Sports2D/Sports2D.py CHANGED
@@ -152,7 +152,7 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
152
152
  'keypoint_likelihood_threshold': 0.3,
153
153
  'average_likelihood_threshold': 0.5,
154
154
  'keypoint_number_threshold': 0.3,
155
- 'max_distance': 100,
155
+ 'max_distance': 250,
156
156
  'CUSTOM': { 'name': 'Hip',
157
157
  'id': 19,
158
158
  'children': [{'name': 'RHip',
@@ -194,10 +194,13 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
194
194
  'px_to_meters_conversion': {
195
195
  'to_meters': True,
196
196
  'make_c3d': True,
197
- 'calib_file': '',
197
+ 'save_calib': True,
198
+ 'perspective_value': 10.0,
199
+ 'perspective_unit': 'distance_m',
200
+ 'distortions': [0.0, 0.0, 0.0, 0.0, 0.0],
198
201
  'floor_angle': 'auto',
199
202
  'xy_origin': ['auto'],
200
- 'save_calib': True
203
+ 'calib_file': '',
201
204
  },
202
205
  'angles': {'display_angle_values_on': ['body', 'list'],
203
206
  'fontSize': 0.3,
@@ -269,16 +272,21 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
269
272
 
270
273
  CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
271
274
  '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"],
275
+ '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"],
272
276
  'nb_persons_to_detect': ["n", "number of persons to detect. int or 'all'. 'all' if not specified"],
273
277
  'person_ordering_method': ["", "'on_click', 'highest_likelihood', 'largest_size', 'smallest_size', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'. 'on_click' if not specified"],
274
278
  'first_person_height': ["H", "height of the reference person in meters. 1.65 if not specified. Not used if a calibration file is provided"],
275
279
  'visible_side': ["", "front, back, left, right, auto, or none. 'auto front none' 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"],
280
+ 'participant_mass': ["", "mass of the participant in kg or none. Defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)"],
281
+ 'perspective_value': ["", "Either camera-to-person distance (m), or focal length (px), or field-of-view (degrees or radians), or '' if perspective_unit=='from_calib'"],
282
+ 'perspective_unit': ["", "'distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib'"],
283
+ 'do_ik': ["", "do inverse kinematics. false if not specified"],
284
+ 'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
276
285
  'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
277
286
  'compare': ["", "visually compare motion with trc file. false if not specified"],
278
- 'webcam_id': ["w", "webcam ID. 0 if not specified"],
279
- '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"],
280
287
  'video_dir': ["d", "current directory if not specified"],
281
288
  'result_dir': ["r", "current directory if not specified"],
289
+ 'webcam_id': ["w", "webcam ID. 0 if not specified"],
282
290
  'show_realtime_results': ["R", "show results in real-time. true if not specified"],
283
291
  'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
284
292
  'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
@@ -303,11 +311,9 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
303
311
  'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
304
312
  'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
305
313
  'save_calib': ["", "save calibration file. true if not specified"],
306
- 'do_ik': ["", "do inverse kinematics. false if not specified"],
307
- 'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
308
314
  'feet_on_floor': ["", "offset marker augmentation results so that feet are at floor level. true if not specified"],
315
+ 'distortions': ["", "camera distortion coefficients [k1, k2, p1, p2, k3] or 'from_calib'. [0.0, 0.0, 0.0, 0.0, 0.0] if not specified"],
309
316
  'use_simple_model': ["", "IK 10+ times faster, but no muscles or flexible spine, no patella. false if not specified"],
310
- 'participant_mass': ["", "mass of the participant in kg or none. Defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)"],
311
317
  'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
312
318
  'tracking_mode': ["", "'sports2d' or 'deepsort'. 'deepsort' is slower, harder to parametrize but can be more robust if correctly tuned"],
313
319
  'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
@@ -36,6 +36,9 @@ __status__ = "Development"
36
36
 
37
37
 
38
38
  ## CONSTANTS
39
+ # 4 points joint angle: between knee and ankle, and toe and heel. Add 90° offset and multiply by 1
40
+ # 3 points joint angle: between ankle, knee, hip. -180° offset, multiply by -1
41
+ # 2 points segment angle: between horizontal and ankle and knee, 0° offset, multiply by -1
39
42
  angle_dict = { # lowercase!
40
43
  # joint angles
41
44
  'right ankle': [['RKnee', 'RAnkle', 'RBigToe', 'RHeel'], 'dorsiflexion', 90, 1],
@@ -96,7 +96,7 @@ def test_workflow():
96
96
 
97
97
  # With no pixels to meters conversion, one person to select, lightweight mode, detection frequency, slowmo factor, gaussian filter, RTMO body pose model
98
98
  demo_cmd3 = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False",
99
- # "--calib_file", "calib_demo.toml",
99
+ "--floor_angle", "from_calib", "--xy_origin", "from_calib", "--perspective_unit", "from_calib", "--calib_file", os.path.join(root_dir, "demo_Sports2D", "demo_Sports2D_calib.toml"),
100
100
  "--nb_persons_to_detect", "1", "--person_ordering_method", "greatest_displacement",
101
101
  "--mode", "lightweight", "--det_frequency", "50",
102
102
  "--slowmo_factor", "4",
@@ -104,9 +104,10 @@ def test_workflow():
104
104
  "--pose_model", "body", "--mode", """{'pose_class':'RTMO', 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmo/onnx_sdk/rtmo-m_16xb16-600e_body7-640x640-39e78cc4_20231211.zip', 'pose_input_size':[640, 640]}"""]
105
105
  subprocess.run(demo_cmd3, check=True, capture_output=True, text=True, encoding='utf-8', errors='replace')
106
106
 
107
- # With a time range, inverse kinematics, marker augmentation
107
+ # With a time range, inverse kinematics, marker augmentation, perspective value in fov
108
108
  demo_cmd4 = ["sports2d", "--person_ordering_method", "greatest_displacement", "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False",
109
109
  "--time_range", "1.2", "2.7",
110
+ "--perspective_value", "40", "--perspective_unit", "fov_deg",
110
111
  "--do_ik", "True", "--use_augmentation", "True",
111
112
  "--nb_persons_to_detect", "all", "--first_person_height", "1.65",
112
113
  "--visible_side", "auto", "front", "--participant_mass", "55.0", "67.0"]