sports2d 0.5.6__py3-none-any.whl → 0.6.2__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: sports2d
3
- Version: 0.5.6
3
+ Version: 0.6.2
4
4
  Summary: Detect pose and compute 2D joint angles from a video.
5
5
  Home-page: https://github.com/davidpagnon/Sports2D
6
6
  Author: David Pagnon
@@ -37,6 +37,7 @@ Requires-Dist: rtmlib
37
37
  Requires-Dist: openvino
38
38
  Requires-Dist: tqdm
39
39
  Requires-Dist: imageio_ffmpeg
40
+ Requires-Dist: deep-sort-realtime
40
41
 
41
42
 
42
43
  [![Continuous integration](https://github.com/davidpagnon/sports2d/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/davidpagnon/sports2d/actions/workflows/continuous-integration.yml)
@@ -96,7 +97,8 @@ If you need 3D research-grade markerless joint kinematics, consider using severa
96
97
  2. [Go further](#go-further)
97
98
  1. [Too slow for you?](#too-slow-for-you)
98
99
  2. [What you need is what you get](#what-you-need-is-what-you-get)
99
- 3. [How it works](#how-it-works)
100
+ 3. [All the parameters](#all-the-parameters)
101
+ 4. [How it works](#how-it-works)
100
102
  3. [How to cite and how to contribute](#how-to-cite-and-how-to-contribute)
101
103
 
102
104
  <br>
@@ -160,12 +162,13 @@ The Demo video is voluntarily challenging to demonstrate the robustness of the p
160
162
  - One person walking in the sagittal plane
161
163
  - One person doing jumping jacks in the frontal plane. This person then performs a flip while being backlit, both of which are challenging for the pose detection algorithm
162
164
  - One tiny person flickering in the background who needs to be ignored
165
+ - The first person is starting high and ending low on the image, which messes up the automatic floor angle calculation. You can set it up manually with the parameter `--floor_angle 0`
163
166
 
164
167
  <br>
165
168
 
166
169
  ### Play with the parameters
167
170
 
168
- For a full list of the available parameters, check the [Config_Demo.toml](https://github.com/davidpagnon/Sports2D/blob/main/Sports2D/Demo/Config_demo.toml) file or type:
171
+ For a full list of the available parameters, see [this section](#all-the-parameters) of the documentation, check the [Config_Demo.toml](https://github.com/davidpagnon/Sports2D/blob/main/Sports2D/Demo/Config_demo.toml) file, or type:
169
172
  ``` cmd
170
173
  sports2d --help
171
174
  ```
@@ -208,7 +211,10 @@ Note that it does not take distortions into account, and that it will be less ac
208
211
  sports2d --show_graphs False --time_range 1.2 2.7 --result_dir path_to_result_dir --slowmo_factor 4
209
212
  ```
210
213
  ``` cmd
211
- sports2d --multiperson false --mode lightweight --det_frequency 50
214
+ sports2d --multiperson false --pose_model Body --mode lightweight --det_frequency 50
215
+ ```
216
+ ``` cmd
217
+ sports2d --tracking_mode deepsort --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}"""
212
218
  ```
213
219
  <br>
214
220
 
@@ -234,10 +240,20 @@ Note that it does not take distortions into account, and that it will be less ac
234
240
 
235
241
  **Quick fixes:**
236
242
  - Use ` --save_vid false --save_img false --show_realtime_results false`: Will not save images or videos, and will not display the results in real time.
237
- - Use `--mode lightweight`: Will use a lighter version of RTMPose, which is faster but less accurate.
243
+ - Use `--mode lightweight`: Will use a lighter version of RTMPose, which is faster but less accurate.\
244
+ Note that any detection and pose models can be used (first [deploy them with MMPose](https://mmpose.readthedocs.io/en/latest/user_guides/how_to_deploy.html#onnx) if you do not have their .onnx or .zip files), with the following formalism:
245
+ ```
246
+ --mode """{'det_class':'YOLOX',
247
+ 'det_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/onnx_sdk/yolox_nano_8xb8-300e_humanart-40f6f0d0.zip',
248
+ 'det_input_size':[416,416],
249
+ 'pose_class':'RTMPose',
250
+ 'pose_model':'https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/onnx_sdk/rtmpose-t_simcc-body7_pt-body7_420e-256x192-026a1439_20230504.zip',
251
+ 'pose_input_size':[192,256]}"""
252
+ ```
238
253
  - Use `--det_frequency 50`: Will detect poses only every 50 frames, and track keypoints in between, which is faster.
239
254
  - Use `--multiperson false`: Can be used if one single person is present in the video. Otherwise, persons' IDs may be mixed up.
240
255
  - Use `--load_trc <path_to_file_px.trc>`: Will use pose estimation results from a file. Useful if you want to use different parameters for pixel to meter conversion or angle calculation without running detection and pose estimation all over.
256
+ - Use `--tracking_mode sports2d`: Will use the default Sports2D tracker. Unlike DeepSort, it is faster, does not require any parametrization, and is as good in non-crowded scenes.
241
257
 
242
258
  <br>
243
259
 
@@ -278,9 +294,9 @@ Will be much faster, with no impact on accuracy. However, the installation takes
278
294
  <br>
279
295
 
280
296
  #### Customize your output:
281
- - Choose whether you want video, images, trc pose file, angle mot file, and real-time display:
297
+ - Choose whether you want video, images, trc pose file, angle mot file, real-time display, and plots:
282
298
  ```cmd
283
- sports2d --save_vid false --save_img true --save_pose false --save_angles true --show_realtime_results false
299
+ sports2d --save_vid false --save_img true --save_pose false --save_angles true --show_realtime_results false --show_graphs false
284
300
  ```
285
301
  - Choose which angles you need:
286
302
  ```cmd
@@ -355,6 +371,85 @@ sports2d --time_range 1.2 2.7 --ik true --person_orientation front none left
355
371
 
356
372
  <br>
357
373
 
374
+
375
+ ### All the parameters
376
+
377
+ For a full list of the available parameters, have a look at the [Config_Demo.toml](https://github.com/davidpagnon/Sports2D/blob/main/Sports2D/Demo/Config_demo.toml) file or type:
378
+
379
+ ``` cmd
380
+ sports2d --help
381
+ ```
382
+
383
+ ```
384
+ ['config': "C", "path to a toml configuration file"],
385
+
386
+ '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"],
387
+ 'person_height': ["H", "height of the person in meters. 1.70 if not specified"],
388
+ 'load_trc': ["", "load trc file to avaid running pose estimation again. false if not specified"],
389
+ 'compare': ["", "visually compare motion with trc file. false if not specified"],
390
+ 'webcam_id': ["w", "webcam ID. 0 if not specified"],
391
+ '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"],
392
+ 'video_dir': ["d", "current directory if not specified"],
393
+ 'result_dir': ["r", "current directory if not specified"],
394
+ 'show_realtime_results': ["R", "show results in real-time. true if not specified"],
395
+ 'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
396
+ 'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
397
+ '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'],
398
+ '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'],
399
+ 'save_vid': ["V", "save processed video. true if not specified"],
400
+ 'save_img': ["I", "save processed images. true if not specified"],
401
+ 'save_pose': ["P", "save pose as trc files. true if not specified"],
402
+ 'calculate_angles': ["c", "calculate joint and segment angles. true if not specified"],
403
+ 'save_angles': ["A", "save angles as mot files. true if not specified"],
404
+ 'slowmo_factor': ["", "slow-motion factor. For a video recorded at 240 fps and exported to 30 fps, it would be 240/30 = 8. 1 if not specified"],
405
+ 'pose_model': ["p", "only body_with_feet is available for now. body_with_feet if not specified"],
406
+ 'mode': ["m", "light, balanced, or performance. balanced if not specified"],
407
+ '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\
408
+ 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"],
409
+ 'to_meters': ["M", "convert pixels to meters. true if not specified"],
410
+
411
+ 'backend': ["", "Backend for pose estimation can be 'auto', 'cpu', 'cuda', 'mps' (for MacOS), or 'rocm' (for AMD GPUs)"],
412
+ 'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
413
+ 'calib_on_person_id': ["", "person ID to calibrate on. 0 if not specified"],
414
+ 'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
415
+ 'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
416
+ 'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
417
+ 'save_calib': ["", "save calibration file. true if not specified"],
418
+ 'do_ik': ["", "do inverse kinematics. false if not specified"],
419
+ 'osim_setup_path': ["", "path to OpenSim setup. '../OpenSim_setup' if not specified"],
420
+ '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."],
421
+ 'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
422
+ 'multiperson': ["", "multiperson involves tracking: will be faster if set to false. true if not specified"],
423
+ 'tracking_mode': ["", "sports2d or rtmlib. sports2d is generally much more accurate and comparable in speed. sports2d if not specified"],
424
+ 'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
425
+ More information there: https://github.com/levan92/deep_sort_realtime/blob/master/deep_sort_realtime/deepsort_tracker.py#L51'],
426
+ 'input_size': ["", "width, height. 1280, 720 if not specified. Lower resolution will be faster but less precise"],
427
+ 'keypoint_likelihood_threshold': ["", "detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"],
428
+ 'average_likelihood_threshold': ["", "detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"],
429
+ '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"],
430
+ 'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
431
+ 'close_to_zero_speed_px': ["", "Sum for all keypoints: about 50 px/frame or 0.2 m/frame. Defaults to 50"],
432
+ 'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise. Defaults to 45"],
433
+ 'trimmed_extrema_percent': ["", "Proportion of the most extreme segment values to remove before calculating their mean. Defaults to 50"],
434
+ 'fontSize': ["", "font size for angle values. 0.3 if not specified"],
435
+ '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"],
436
+ 'correct_segment_angles_with_floor_angle': ["", "true or false. If the camera is tilted, corrects segment angles as regards to the floor angle. Set to false is the floor is tilted instead. True if not specified"],
437
+ 'interpolate': ["", "interpolate missing data. true if not specified"],
438
+ 'interp_gap_smaller_than': ["", "interpolate sequences of missing data if they are less than N frames long. 10 if not specified"],
439
+ 'fill_large_gaps_with': ["", "last_value, nan, or zeros. last_value if not specified"],
440
+ 'filter': ["", "filter results. true if not specified"],
441
+ 'filter_type': ["", "butterworth, gaussian, median, or loess. butterworth if not specified"],
442
+ 'order': ["", "order of the Butterworth filter. 4 if not specified"],
443
+ 'cut_off_frequency': ["", "cut-off frequency of the Butterworth filter. 3 if not specified"],
444
+ 'sigma_kernel': ["", "sigma of the gaussian filter. 1 if not specified"],
445
+ 'nb_values_used': ["", "number of values used for the loess filter. 5 if not specified"],
446
+ 'kernel_size': ["", "kernel size of the median filter. 3 if not specified"],
447
+ 'use_custom_logging': ["", "use custom logging. false if not specified"]
448
+ ```
449
+
450
+ <br>
451
+
452
+
358
453
  ### How it works
359
454
 
360
455
  Sports2D:
@@ -372,7 +467,7 @@ Sports2D:
372
467
 
373
468
  2. **Sets up pose estimation with RTMLib.** It can be run in lightweight, balanced, or performance mode, and for faster inference, keypoints can be tracked instead of detected for a certain number of frames. Any RTMPose model can be used.
374
469
 
375
- 3. **Tracks people** so that their IDs are consistent across frames. A person is associated to another in the next frame when they are at a small distance. IDs remain consistent even if the person disappears from a few frames. This carefully crafted `sports2d` tracker runs at a comparable speed as the RTMlib one but is much more robust. The user can still choose the RTMLib method if they need it by specifying it in the Config.toml file.
470
+ 3. **Tracks people** so that their IDs are consistent across frames. A person is associated to another in the next frame when they are at a small distance. IDs remain consistent even if the person disappears from a few frames. We crafted a 'sports2D' tracker which gives good results and runs in real time, but it is also possible to use `deepsort` in particularly challenging situations.
376
471
 
377
472
  4. **Chooses the right persons to keep.** In single-person mode, only keeps the person with the highest average scores over the sequence. In multi-person mode, only retrieves the keypoints with high enough confidence, and only keeps the persons with high enough average confidence over each frame.
378
473
 
@@ -455,7 +550,11 @@ If you want to contribute to Sports2D, please follow [this guide](https://docs.g
455
550
  - [x] Option to only save one person (with the highest average score, or with the most frames and fastest speed)
456
551
  - [x] Run again without pose estimation with the option `--load_trc` for px .trc file.
457
552
  - [x] **Convert positions to meters** by providing the person height, a calibration file, or 3D points [to click on the image](https://stackoverflow.com/questions/74248955/how-to-display-the-coordinates-of-the-points-clicked-on-the-image-in-google-cola)
553
+ - [x] Support any detection and/or pose estimation model.
554
+
458
555
  - [ ] Perform **Inverse kinematics and dynamics** with OpenSim (cf. [Pose2Sim](https://github.com/perfanalytics/pose2sim), but in 2D). Update [this model](https://github.com/davidpagnon/Sports2D/blob/main/Sports2D/Utilities/2D_gait.osim) (add arms, markers, remove muscles and contact spheres). Add pipeline example.
556
+ - [ ] Optionally let user select the person of interest in single_person mode:\
557
+ `multiperson = true # true, or 'single_auto', or 'single_click'. 'single_auto' selects the person with highest average likelihood, and 'single_click' lets the user manually select the person of interest.`
459
558
  - [ ] Run with the option `--compare_to` to visually compare motion with a trc file. If run with a webcam input, the user can follow the motion of the trc file. Further calculation can then be done to compare specific variables.
460
559
  - [ ] **Colab version**: more user-friendly, usable on a smartphone.
461
560
  - [ ] **GUI applications** for Windows, Mac, and Linux, as well as for Android and iOS.
@@ -0,0 +1,16 @@
1
+ Sports2D/Sports2D.py,sha256=8h8LJiClAPMTrgNyu5MXJaLMk0H3cuCVb5AfjlNqcnQ,27881
2
+ Sports2D/__init__.py,sha256=TyCP7Uuuy6CNklhPf8W84MbYoO1_-1dxowSYAJyk_OI,102
3
+ Sports2D/process.py,sha256=Q2kOkijxT-vxc2bVNHlNmW89G5AMUxUAgR3Ld0_Gbx8,77761
4
+ Sports2D/Demo/Config_demo.toml,sha256=D9DKslAExcjeGyGM96Iergd9GzABbDfkrvIZ6WkR5qA,12039
5
+ Sports2D/Demo/demo.mp4,sha256=2aZkFxhWR7ESMEtXCT8MGA83p2jmoU2sp1ylQfO3gDk,3968304
6
+ Sports2D/Utilities/__init__.py,sha256=TyCP7Uuuy6CNklhPf8W84MbYoO1_-1dxowSYAJyk_OI,102
7
+ Sports2D/Utilities/common.py,sha256=Pmv_meJaQ-H4deWtr3y5paLEq4kc4w1W_L94eQVTtvg,42723
8
+ Sports2D/Utilities/filter.py,sha256=8mVefMjDzxmh9a30eNtIrUuK_mUKoOJ2Nr-OzcQKkKM,4922
9
+ Sports2D/Utilities/skeletons.py,sha256=-EtpcoGxwAtJLr02_svLhdkFoNaQiUGj7cfK_aazgB0,40290
10
+ Sports2D/Utilities/tests.py,sha256=U0uwhPgcDY7HavI5f3HmfWydFi8eOfn_h4FIRCRhFcc,3104
11
+ sports2d-0.6.2.dist-info/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
12
+ sports2d-0.6.2.dist-info/METADATA,sha256=crFUyUqG5CrRZ6RxVZaqnPrgg9QQiX6tPrbg1JX6muo,31884
13
+ sports2d-0.6.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
+ sports2d-0.6.2.dist-info/entry_points.txt,sha256=h2CJTuydtNf8JyaLoWxWl5HTSIxx5Ra_FSiSGQsf7Sk,52
15
+ sports2d-0.6.2.dist-info/top_level.txt,sha256=DoURf9UDB8lQ_9lMUPQMQqhXCvWPFFjJco9NzPlHJ6I,9
16
+ sports2d-0.6.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- Sports2D/Sports2D.py,sha256=dZv4xglguFJZDu9Zv0AZKAGu1TQIW9ynmY8pMsNHw14,26377
2
- Sports2D/__init__.py,sha256=TyCP7Uuuy6CNklhPf8W84MbYoO1_-1dxowSYAJyk_OI,102
3
- Sports2D/process.py,sha256=uX35szjJ6T7tOcqXQsljnS6xD1T9ufo2_hhJFI29cKo,89117
4
- Sports2D/Demo/Config_demo.toml,sha256=CeHY91RXrt26TzvtXnCq7Hp2gMdu3EX-flZxaH0DqyA,6768
5
- Sports2D/Demo/demo.mp4,sha256=2aZkFxhWR7ESMEtXCT8MGA83p2jmoU2sp1ylQfO3gDk,3968304
6
- Sports2D/Utilities/__init__.py,sha256=TyCP7Uuuy6CNklhPf8W84MbYoO1_-1dxowSYAJyk_OI,102
7
- Sports2D/Utilities/common.py,sha256=FEWmlq9HNlHzA2ioV5MPPOeC-5Py4JaDbIIxQgq9hGE,14128
8
- Sports2D/Utilities/filter.py,sha256=8mVefMjDzxmh9a30eNtIrUuK_mUKoOJ2Nr-OzcQKkKM,4922
9
- Sports2D/Utilities/skeletons.py,sha256=44IWpz47zjh_6YDqkwaJnSysaGi7ovgYE25ji-hC-Kw,15660
10
- Sports2D/Utilities/tests.py,sha256=g06HBExGkvZrhZpNXN19G9Shisfgp1cqjAp0kFxiKEc,2574
11
- sports2d-0.5.6.dist-info/LICENSE,sha256=f4qe3nE0Y7ltJho5w-xAR0jI5PUox5Xl-MsYiY7ZRM8,1521
12
- sports2d-0.5.6.dist-info/METADATA,sha256=X6YrqZQnm0k9MG59MJe3pguWBwxR0mJ7-c0SWc-67FY,23221
13
- sports2d-0.5.6.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
14
- sports2d-0.5.6.dist-info/entry_points.txt,sha256=h2CJTuydtNf8JyaLoWxWl5HTSIxx5Ra_FSiSGQsf7Sk,52
15
- sports2d-0.5.6.dist-info/top_level.txt,sha256=DoURf9UDB8lQ_9lMUPQMQqhXCvWPFFjJco9NzPlHJ6I,9
16
- sports2d-0.5.6.dist-info/RECORD,,