sports2d 0.8.24__tar.gz → 0.8.25__tar.gz
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-0.8.24/sports2d.egg-info → sports2d-0.8.25}/PKG-INFO +43 -34
- {sports2d-0.8.24 → sports2d-0.8.25}/README.md +42 -33
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Demo/Config_demo.toml +12 -9
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Sports2D.py +12 -8
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Utilities/common.py +3 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Utilities/tests.py +3 -2
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/process.py +278 -114
- {sports2d-0.8.24 → sports2d-0.8.25/sports2d.egg-info}/PKG-INFO +43 -34
- {sports2d-0.8.24 → sports2d-0.8.25}/.github/workflows/continuous-integration.yml +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/.github/workflows/joss_pdf.yml +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/.github/workflows/publish-on-release.yml +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/.gitignore +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/CITATION.cff +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/Demo_plots.png +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/Demo_results.png +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/Demo_terminal.png +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/Person_selection.png +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/Video_tuto_Sports2D_Colab.png +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/joint_convention.png +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/paper.bib +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/paper.md +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/sports2d_blender.gif +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Content/sports2d_opensim.gif +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/LICENSE +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Demo/Calib_demo.toml +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Demo/demo.mp4 +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Sports2D.ipynb +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/Utilities/__init__.py +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/Sports2D/__init__.py +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/pyproject.toml +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/setup.cfg +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/sports2d.egg-info/SOURCES.txt +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/sports2d.egg-info/dependency_links.txt +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/sports2d.egg-info/entry_points.txt +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/sports2d.egg-info/requires.txt +0 -0
- {sports2d-0.8.24 → sports2d-0.8.25}/sports2d.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sports2d
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.25
|
|
4
4
|
Summary: Compute 2D human pose and angles from a video or a webcam.
|
|
5
5
|
Author-email: David Pagnon <contact@david-pagnon.com>
|
|
6
6
|
Maintainer-email: David Pagnon <contact@david-pagnon.com>
|
|
@@ -52,7 +52,7 @@ Dynamic: license-file
|
|
|
52
52
|
</br>
|
|
53
53
|
|
|
54
54
|
> **`Announcements:`**
|
|
55
|
-
> -
|
|
55
|
+
> - Compensate for floor angle, floor height, depth perspective effects, generate a calibration file **New in v0.9!**
|
|
56
56
|
> - Select only the persons you want to analyze **New in v0.8!**
|
|
57
57
|
> - MarkerAugmentation and Inverse Kinematics for accurate 3D motion with OpenSim. **New in v0.7!**
|
|
58
58
|
> - Any detector and pose estimation model can be used. **New in v0.6!**
|
|
@@ -294,30 +294,35 @@ sports2d --person_ordering_method on_click
|
|
|
294
294
|
#### Get coordinates in meters:
|
|
295
295
|
> **N.B.:** The Z coordinate (depth) should not be overly trusted.
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
To convert from pixels to meters, you need a minima the height of a participant. Better results can be obtained by also providing an information on depth. The camera horizon angle and the floor height are generally automatically estimated. **N.B.: A calibration file will be generated.**
|
|
298
298
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
**N.B.: A calibration file will be generated.** By convention, the camera-to-subject distance is set to 10 meters.
|
|
299
|
+
- The pixel-to-meters scale is computed from the ratio between the height of the participant in meters and in pixels. The height in pixels is automatically calculated; use the `--first_person_height` parameter to specify the height in meters.
|
|
300
|
+
- Depth perspective effects can be compensated either with the camera-to-person distance (m), or focal length (px), or field-of-view (degrees or radians), or from a calibration file. Use the `--perspective_unit` ('distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib') and `--perspective_value` parameters (resp. in m, px, deg, rad, or '').
|
|
301
|
+
- The camera horizon angle can be estimated from kinematics (`auto`), from a calibration file (`from_calib`), or manually (float). Use the `--floor_angle` parameter.
|
|
302
|
+
- Likewise for the floor level. Use the `--xy_origin` parameter.
|
|
305
303
|
|
|
306
|
-
|
|
307
|
-
sports2d --first_person_height 1.65 --visible_side auto front none
|
|
308
|
-
```
|
|
309
|
-
``` cmd
|
|
310
|
-
sports2d --first_person_height 1.65 --visible_side auto front none `
|
|
311
|
-
--person_ordering_method on_click `
|
|
312
|
-
--floor_angle 0 --xy_origin 0 940
|
|
313
|
-
```
|
|
304
|
+
If one of these parameters is set to `from_calib`, then use `--calib_file`.
|
|
314
305
|
|
|
315
|
-
2. **Or use a calibration file**:\
|
|
316
|
-
It can either be a `.toml` calibration file previously generated by Sports2D, or a more accurate one coming from another system. For example, [Pose2Sim](https://github.com/perfanalytics/pose2sim) can be used to accurately calculate calibration, or to convert calibration files from Qualisys, Vicon, OpenCap, FreeMoCap, etc.
|
|
317
306
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
307
|
+
``` cmd
|
|
308
|
+
sports2d --first_person_height 1.65
|
|
309
|
+
```
|
|
310
|
+
``` cmd
|
|
311
|
+
sports2d --first_person_height 1.65 `
|
|
312
|
+
--floor_angle auto `
|
|
313
|
+
--xy_origin auto`
|
|
314
|
+
--perspective_unit distance_m --perspective_value 10
|
|
315
|
+
```
|
|
316
|
+
``` cmd
|
|
317
|
+
sports2d --first_person_height 1.65 `
|
|
318
|
+
--floor_angle 0 `
|
|
319
|
+
--xy_origin from_calib`
|
|
320
|
+
--perspective_unit from_calib --calib_file Sports2D\Demo\Calib_demo.toml
|
|
321
|
+
```
|
|
322
|
+
``` cmd
|
|
323
|
+
sports2d --first_person_height 1.65 `
|
|
324
|
+
--perspective_unit f_px --perspective_value 2520
|
|
325
|
+
```
|
|
321
326
|
|
|
322
327
|
<br>
|
|
323
328
|
|
|
@@ -480,20 +485,25 @@ sports2d --help
|
|
|
480
485
|
'config': ["C", "path to a toml configuration file"],
|
|
481
486
|
|
|
482
487
|
'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"],
|
|
488
|
+
'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"],
|
|
483
489
|
'nb_persons_to_detect': ["n", "number of persons to detect. int or 'all'. 'all' if not specified"],
|
|
484
490
|
'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"],
|
|
485
491
|
'first_person_height': ["H", "height of the reference person in meters. 1.65 if not specified. Not used if a calibration file is provided"],
|
|
486
492
|
'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"],
|
|
493
|
+
'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)"],
|
|
494
|
+
'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'"],
|
|
495
|
+
'perspective_unit': ["", "'distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib'"],
|
|
496
|
+
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
497
|
+
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
487
498
|
'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
|
|
488
499
|
'compare': ["", "visually compare motion with trc file. false if not specified"],
|
|
489
|
-
'webcam_id': ["w", "webcam ID. 0 if not specified"],
|
|
490
|
-
'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"],
|
|
491
500
|
'video_dir': ["d", "current directory if not specified"],
|
|
492
501
|
'result_dir': ["r", "current directory if not specified"],
|
|
502
|
+
'webcam_id': ["w", "webcam ID. 0 if not specified"],
|
|
493
503
|
'show_realtime_results': ["R", "show results in real-time. true if not specified"],
|
|
494
504
|
'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
|
|
495
505
|
'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
|
|
496
|
-
'save_graphs': ["", "save position and angle plots of raw and processed results.
|
|
506
|
+
'save_graphs': ["", "save position and angle plots of raw and processed results. true if not specified"],
|
|
497
507
|
'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'],
|
|
498
508
|
'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'],
|
|
499
509
|
'save_vid': ["V", "save processed video. true if not specified"],
|
|
@@ -514,11 +524,8 @@ sports2d --help
|
|
|
514
524
|
'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
|
|
515
525
|
'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
|
|
516
526
|
'save_calib': ["", "save calibration file. true if not specified"],
|
|
517
|
-
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
518
|
-
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
519
527
|
'feet_on_floor': ["", "offset marker augmentation results so that feet are at floor level. true if not specified"],
|
|
520
|
-
'use_simple_model': ["", "IK 10+ times faster, but no muscles or flexible spine. false if not specified"],
|
|
521
|
-
'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)"],
|
|
528
|
+
'use_simple_model': ["", "IK 10+ times faster, but no muscles or flexible spine, no patella. false if not specified"],
|
|
522
529
|
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
|
|
523
530
|
'tracking_mode': ["", "'sports2d' or 'deepsort'. 'deepsort' is slower, harder to parametrize but can be more robust if correctly tuned"],
|
|
524
531
|
'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
|
|
@@ -528,6 +535,7 @@ sports2d --help
|
|
|
528
535
|
'keypoint_likelihood_threshold': ["", "detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"],
|
|
529
536
|
'average_likelihood_threshold': ["", "detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"],
|
|
530
537
|
'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"],
|
|
538
|
+
'max_distance': ["", "If a person is detected further than max_distance from its position on the previous frame, it will be considered as a new one. in px or None, 100 by default."],
|
|
531
539
|
'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
|
|
532
540
|
'close_to_zero_speed_px': ["", "Sum for all keypoints: about 50 px/frame or 0.2 m/frame. Defaults to 50"],
|
|
533
541
|
'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise. Defaults to 45"],
|
|
@@ -539,15 +547,16 @@ sports2d --help
|
|
|
539
547
|
'interp_gap_smaller_than': ["", "interpolate sequences of missing data if they are less than N frames long. 10 if not specified"],
|
|
540
548
|
'fill_large_gaps_with': ["", "last_value, nan, or zeros. last_value if not specified"],
|
|
541
549
|
'sections_to_keep': ["", "all, largest, first, or last. Keep 'all' valid sections even when they are interspersed with undetected chunks, or the 'largest' valid section, or the 'first' one, or the 'last' one"],
|
|
550
|
+
'min_chunk_size': ["", "Minimum number of valid frames in a row to keep a chunk of data for a person. 10 if not specified"],
|
|
542
551
|
'reject_outliers': ["", "reject outliers with Hampel filter before other filtering methods. true if not specified"],
|
|
543
552
|
'filter': ["", "filter results. true if not specified"],
|
|
544
553
|
'filter_type': ["", "butterworth, kalman, gcv_spline, gaussian, median, or loess. butterworth if not specified"],
|
|
554
|
+
'cut_off_frequency': ["", "cut-off frequency of the Butterworth filter. 6 if not specified"],
|
|
545
555
|
'order': ["", "order of the Butterworth filter. 4 if not specified"],
|
|
546
|
-
'
|
|
556
|
+
'gcv_cut_off_frequency': ["", "cut-off frequency of the GCV spline filter. 'auto' is usually better, unless the signal is too short (noise can then be considered as signal -> trajectories not filtered). 'auto' if not specified"],
|
|
557
|
+
'gcv_smoothing_factor': ["", "smoothing factor of the GCV spline filter (>=0). Ignored if cut_off_frequency != 'auto'. Biases results towards more smoothing (>1) or more fidelity to data (<1). 1.0 if not specified"],
|
|
547
558
|
'trust_ratio': ["", "trust ratio of the Kalman filter: How much more do you trust triangulation results (measurements), than the assumption of constant acceleration(process)? 500 if not specified"],
|
|
548
559
|
'smooth': ["", "dual Kalman smoothing. true if not specified"],
|
|
549
|
-
'gcv_cut_off_frequency': ["", "cut-off frequency of the GCV spline filter. 'auto' if not specified"],
|
|
550
|
-
'smoothing_factor': ["", "smoothing factor of the GCV spline filter (>=0). Ignored if cut_off_frequency != 'auto'. Biases results towards more smoothing (>1) or more fidelity to data (<1). 0.1 if not specified"],
|
|
551
560
|
'sigma_kernel': ["", "sigma of the gaussian filter. 1 if not specified"],
|
|
552
561
|
'nb_values_used': ["", "number of values used for the loess filter. 5 if not specified"],
|
|
553
562
|
'kernel_size': ["", "kernel size of the median filter. 3 if not specified"],
|
|
@@ -656,11 +665,11 @@ Sports2D:
|
|
|
656
665
|
|
|
657
666
|
2. **Sets up pose estimation with RTMLib.** It can be run in lightweight, balanced, or performance mode, and for faster inference, the person bounding boxes can be tracked instead of detected every frame. Any RTMPose model can be used.
|
|
658
667
|
|
|
659
|
-
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
|
|
668
|
+
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, thanks to the 'sports2D' tracker. [See Release notes of v0.8.22 for more information](https://github.com/davidpagnon/Sports2D/releases/tag/v0.8.22).
|
|
660
669
|
|
|
661
670
|
4. **Chooses which persons to analyze.** In single-person mode, only keeps the person with the highest average scores over the sequence. In multi-person mode, you can choose the number of persons to analyze (`nb_persons_to_detect`), and how to order them (`person_ordering_method`). The ordering method can be 'on_click', 'highest_likelihood', 'largest_size', 'smallest_size', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'. `on_click` is default and lets the user click on the persons they are interested in, in the desired order.
|
|
662
671
|
|
|
663
|
-
4. **Converts the pixel coordinates to meters.** The user can provide the size of a specified person to scale results accordingly. The
|
|
672
|
+
4. **Converts the pixel coordinates to meters.** The user can provide the size of a specified person to scale results accordingly. The camera horizon angle and the floor level can either be detected automatically from the gait sequence, be manually specified, or obtained frmm a calibration file. The depth perspective effects are compensated thanks with the distance from the camera to the subject, the focal length, the field of view, or from a calibration file. [See Release notes of v0.8.25 for more information](https://github.com/davidpagnon/Sports2D/releases/tag/v0.8.25).
|
|
664
673
|
|
|
665
674
|
5. **Computes the selected joint and segment angles**, and flips them on the left/right side if the respective foot is pointing to the left/right.
|
|
666
675
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</br>
|
|
25
25
|
|
|
26
26
|
> **`Announcements:`**
|
|
27
|
-
> -
|
|
27
|
+
> - Compensate for floor angle, floor height, depth perspective effects, generate a calibration file **New in v0.9!**
|
|
28
28
|
> - Select only the persons you want to analyze **New in v0.8!**
|
|
29
29
|
> - MarkerAugmentation and Inverse Kinematics for accurate 3D motion with OpenSim. **New in v0.7!**
|
|
30
30
|
> - Any detector and pose estimation model can be used. **New in v0.6!**
|
|
@@ -266,30 +266,35 @@ sports2d --person_ordering_method on_click
|
|
|
266
266
|
#### Get coordinates in meters:
|
|
267
267
|
> **N.B.:** The Z coordinate (depth) should not be overly trusted.
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
To convert from pixels to meters, you need a minima the height of a participant. Better results can be obtained by also providing an information on depth. The camera horizon angle and the floor height are generally automatically estimated. **N.B.: A calibration file will be generated.**
|
|
270
270
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
**N.B.: A calibration file will be generated.** By convention, the camera-to-subject distance is set to 10 meters.
|
|
271
|
+
- The pixel-to-meters scale is computed from the ratio between the height of the participant in meters and in pixels. The height in pixels is automatically calculated; use the `--first_person_height` parameter to specify the height in meters.
|
|
272
|
+
- Depth perspective effects can be compensated either with the camera-to-person distance (m), or focal length (px), or field-of-view (degrees or radians), or from a calibration file. Use the `--perspective_unit` ('distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib') and `--perspective_value` parameters (resp. in m, px, deg, rad, or '').
|
|
273
|
+
- The camera horizon angle can be estimated from kinematics (`auto`), from a calibration file (`from_calib`), or manually (float). Use the `--floor_angle` parameter.
|
|
274
|
+
- Likewise for the floor level. Use the `--xy_origin` parameter.
|
|
277
275
|
|
|
278
|
-
|
|
279
|
-
sports2d --first_person_height 1.65 --visible_side auto front none
|
|
280
|
-
```
|
|
281
|
-
``` cmd
|
|
282
|
-
sports2d --first_person_height 1.65 --visible_side auto front none `
|
|
283
|
-
--person_ordering_method on_click `
|
|
284
|
-
--floor_angle 0 --xy_origin 0 940
|
|
285
|
-
```
|
|
276
|
+
If one of these parameters is set to `from_calib`, then use `--calib_file`.
|
|
286
277
|
|
|
287
|
-
2. **Or use a calibration file**:\
|
|
288
|
-
It can either be a `.toml` calibration file previously generated by Sports2D, or a more accurate one coming from another system. For example, [Pose2Sim](https://github.com/perfanalytics/pose2sim) can be used to accurately calculate calibration, or to convert calibration files from Qualisys, Vicon, OpenCap, FreeMoCap, etc.
|
|
289
278
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
279
|
+
``` cmd
|
|
280
|
+
sports2d --first_person_height 1.65
|
|
281
|
+
```
|
|
282
|
+
``` cmd
|
|
283
|
+
sports2d --first_person_height 1.65 `
|
|
284
|
+
--floor_angle auto `
|
|
285
|
+
--xy_origin auto`
|
|
286
|
+
--perspective_unit distance_m --perspective_value 10
|
|
287
|
+
```
|
|
288
|
+
``` cmd
|
|
289
|
+
sports2d --first_person_height 1.65 `
|
|
290
|
+
--floor_angle 0 `
|
|
291
|
+
--xy_origin from_calib`
|
|
292
|
+
--perspective_unit from_calib --calib_file Sports2D\Demo\Calib_demo.toml
|
|
293
|
+
```
|
|
294
|
+
``` cmd
|
|
295
|
+
sports2d --first_person_height 1.65 `
|
|
296
|
+
--perspective_unit f_px --perspective_value 2520
|
|
297
|
+
```
|
|
293
298
|
|
|
294
299
|
<br>
|
|
295
300
|
|
|
@@ -452,20 +457,25 @@ sports2d --help
|
|
|
452
457
|
'config': ["C", "path to a toml configuration file"],
|
|
453
458
|
|
|
454
459
|
'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"],
|
|
460
|
+
'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"],
|
|
455
461
|
'nb_persons_to_detect': ["n", "number of persons to detect. int or 'all'. 'all' if not specified"],
|
|
456
462
|
'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"],
|
|
457
463
|
'first_person_height': ["H", "height of the reference person in meters. 1.65 if not specified. Not used if a calibration file is provided"],
|
|
458
464
|
'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"],
|
|
465
|
+
'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)"],
|
|
466
|
+
'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'"],
|
|
467
|
+
'perspective_unit': ["", "'distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib'"],
|
|
468
|
+
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
469
|
+
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
459
470
|
'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
|
|
460
471
|
'compare': ["", "visually compare motion with trc file. false if not specified"],
|
|
461
|
-
'webcam_id': ["w", "webcam ID. 0 if not specified"],
|
|
462
|
-
'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"],
|
|
463
472
|
'video_dir': ["d", "current directory if not specified"],
|
|
464
473
|
'result_dir': ["r", "current directory if not specified"],
|
|
474
|
+
'webcam_id': ["w", "webcam ID. 0 if not specified"],
|
|
465
475
|
'show_realtime_results': ["R", "show results in real-time. true if not specified"],
|
|
466
476
|
'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
|
|
467
477
|
'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
|
|
468
|
-
'save_graphs': ["", "save position and angle plots of raw and processed results.
|
|
478
|
+
'save_graphs': ["", "save position and angle plots of raw and processed results. true if not specified"],
|
|
469
479
|
'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'],
|
|
470
480
|
'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'],
|
|
471
481
|
'save_vid': ["V", "save processed video. true if not specified"],
|
|
@@ -486,11 +496,8 @@ sports2d --help
|
|
|
486
496
|
'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
|
|
487
497
|
'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
|
|
488
498
|
'save_calib': ["", "save calibration file. true if not specified"],
|
|
489
|
-
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
490
|
-
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
491
499
|
'feet_on_floor': ["", "offset marker augmentation results so that feet are at floor level. true if not specified"],
|
|
492
|
-
'use_simple_model': ["", "IK 10+ times faster, but no muscles or flexible spine. false if not specified"],
|
|
493
|
-
'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)"],
|
|
500
|
+
'use_simple_model': ["", "IK 10+ times faster, but no muscles or flexible spine, no patella. false if not specified"],
|
|
494
501
|
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
|
|
495
502
|
'tracking_mode': ["", "'sports2d' or 'deepsort'. 'deepsort' is slower, harder to parametrize but can be more robust if correctly tuned"],
|
|
496
503
|
'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
|
|
@@ -500,6 +507,7 @@ sports2d --help
|
|
|
500
507
|
'keypoint_likelihood_threshold': ["", "detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"],
|
|
501
508
|
'average_likelihood_threshold': ["", "detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"],
|
|
502
509
|
'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"],
|
|
510
|
+
'max_distance': ["", "If a person is detected further than max_distance from its position on the previous frame, it will be considered as a new one. in px or None, 100 by default."],
|
|
503
511
|
'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
|
|
504
512
|
'close_to_zero_speed_px': ["", "Sum for all keypoints: about 50 px/frame or 0.2 m/frame. Defaults to 50"],
|
|
505
513
|
'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise. Defaults to 45"],
|
|
@@ -511,15 +519,16 @@ sports2d --help
|
|
|
511
519
|
'interp_gap_smaller_than': ["", "interpolate sequences of missing data if they are less than N frames long. 10 if not specified"],
|
|
512
520
|
'fill_large_gaps_with': ["", "last_value, nan, or zeros. last_value if not specified"],
|
|
513
521
|
'sections_to_keep': ["", "all, largest, first, or last. Keep 'all' valid sections even when they are interspersed with undetected chunks, or the 'largest' valid section, or the 'first' one, or the 'last' one"],
|
|
522
|
+
'min_chunk_size': ["", "Minimum number of valid frames in a row to keep a chunk of data for a person. 10 if not specified"],
|
|
514
523
|
'reject_outliers': ["", "reject outliers with Hampel filter before other filtering methods. true if not specified"],
|
|
515
524
|
'filter': ["", "filter results. true if not specified"],
|
|
516
525
|
'filter_type': ["", "butterworth, kalman, gcv_spline, gaussian, median, or loess. butterworth if not specified"],
|
|
526
|
+
'cut_off_frequency': ["", "cut-off frequency of the Butterworth filter. 6 if not specified"],
|
|
517
527
|
'order': ["", "order of the Butterworth filter. 4 if not specified"],
|
|
518
|
-
'
|
|
528
|
+
'gcv_cut_off_frequency': ["", "cut-off frequency of the GCV spline filter. 'auto' is usually better, unless the signal is too short (noise can then be considered as signal -> trajectories not filtered). 'auto' if not specified"],
|
|
529
|
+
'gcv_smoothing_factor': ["", "smoothing factor of the GCV spline filter (>=0). Ignored if cut_off_frequency != 'auto'. Biases results towards more smoothing (>1) or more fidelity to data (<1). 1.0 if not specified"],
|
|
519
530
|
'trust_ratio': ["", "trust ratio of the Kalman filter: How much more do you trust triangulation results (measurements), than the assumption of constant acceleration(process)? 500 if not specified"],
|
|
520
531
|
'smooth': ["", "dual Kalman smoothing. true if not specified"],
|
|
521
|
-
'gcv_cut_off_frequency': ["", "cut-off frequency of the GCV spline filter. 'auto' if not specified"],
|
|
522
|
-
'smoothing_factor': ["", "smoothing factor of the GCV spline filter (>=0). Ignored if cut_off_frequency != 'auto'. Biases results towards more smoothing (>1) or more fidelity to data (<1). 0.1 if not specified"],
|
|
523
532
|
'sigma_kernel': ["", "sigma of the gaussian filter. 1 if not specified"],
|
|
524
533
|
'nb_values_used': ["", "number of values used for the loess filter. 5 if not specified"],
|
|
525
534
|
'kernel_size': ["", "kernel size of the median filter. 3 if not specified"],
|
|
@@ -628,11 +637,11 @@ Sports2D:
|
|
|
628
637
|
|
|
629
638
|
2. **Sets up pose estimation with RTMLib.** It can be run in lightweight, balanced, or performance mode, and for faster inference, the person bounding boxes can be tracked instead of detected every frame. Any RTMPose model can be used.
|
|
630
639
|
|
|
631
|
-
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
|
|
640
|
+
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, thanks to the 'sports2D' tracker. [See Release notes of v0.8.22 for more information](https://github.com/davidpagnon/Sports2D/releases/tag/v0.8.22).
|
|
632
641
|
|
|
633
642
|
4. **Chooses which persons to analyze.** In single-person mode, only keeps the person with the highest average scores over the sequence. In multi-person mode, you can choose the number of persons to analyze (`nb_persons_to_detect`), and how to order them (`person_ordering_method`). The ordering method can be 'on_click', 'highest_likelihood', 'largest_size', 'smallest_size', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'. `on_click` is default and lets the user click on the persons they are interested in, in the desired order.
|
|
634
643
|
|
|
635
|
-
4. **Converts the pixel coordinates to meters.** The user can provide the size of a specified person to scale results accordingly. The
|
|
644
|
+
4. **Converts the pixel coordinates to meters.** The user can provide the size of a specified person to scale results accordingly. The camera horizon angle and the floor level can either be detected automatically from the gait sequence, be manually specified, or obtained frmm a calibration file. The depth perspective effects are compensated thanks with the distance from the camera to the subject, the focal length, the field of view, or from a calibration file. [See Release notes of v0.8.25 for more information](https://github.com/davidpagnon/Sports2D/releases/tag/v0.8.25).
|
|
636
645
|
|
|
637
646
|
5. **Computes the selected joint and segment angles**, and flips them on the left/right side if the respective foot is pointing to the left/right.
|
|
638
647
|
|
|
@@ -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
|
+
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,17 @@ to_meters = true
|
|
|
105
106
|
make_c3d = true
|
|
106
107
|
save_calib = true
|
|
107
108
|
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
# 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
|
|
110
|
+
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'
|
|
111
|
+
perspective_unit = 'distance_m' # 'distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib'
|
|
112
|
+
|
|
113
|
+
# Compensate for camera horizon
|
|
114
|
+
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
|
|
115
|
+
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)
|
|
116
|
+
|
|
117
|
+
# Optional calibration file
|
|
118
|
+
calib_file = '' # Calibration file in the Pose2Sim toml format, or '' if not available
|
|
111
119
|
|
|
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
120
|
|
|
118
121
|
[angles]
|
|
119
122
|
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.
|
|
@@ -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':
|
|
155
|
+
'max_distance': 250,
|
|
156
156
|
'CUSTOM': { 'name': 'Hip',
|
|
157
157
|
'id': 19,
|
|
158
158
|
'children': [{'name': 'RHip',
|
|
@@ -194,10 +194,12 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
|
|
|
194
194
|
'px_to_meters_conversion': {
|
|
195
195
|
'to_meters': True,
|
|
196
196
|
'make_c3d': True,
|
|
197
|
-
'
|
|
197
|
+
'save_calib': True,
|
|
198
|
+
'perspective_value': 10.0,
|
|
199
|
+
'perspective_unit': 'distance_m',
|
|
198
200
|
'floor_angle': 'auto',
|
|
199
201
|
'xy_origin': ['auto'],
|
|
200
|
-
'
|
|
202
|
+
'calib_file': '',
|
|
201
203
|
},
|
|
202
204
|
'angles': {'display_angle_values_on': ['body', 'list'],
|
|
203
205
|
'fontSize': 0.3,
|
|
@@ -269,16 +271,21 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
|
|
|
269
271
|
|
|
270
272
|
CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
271
273
|
'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"],
|
|
274
|
+
'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
275
|
'nb_persons_to_detect': ["n", "number of persons to detect. int or 'all'. 'all' if not specified"],
|
|
273
276
|
'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
277
|
'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
278
|
'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"],
|
|
279
|
+
'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)"],
|
|
280
|
+
'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'"],
|
|
281
|
+
'perspective_unit': ["", "'distance_m', 'f_px', 'fov_deg', 'fov_rad', or 'from_calib'"],
|
|
282
|
+
'do_ik': ["", "do inverse kinematics. false if not specified"],
|
|
283
|
+
'use_augmentation': ["", "Use LSTM marker augmentation. false if not specified"],
|
|
276
284
|
'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
|
|
277
285
|
'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
286
|
'video_dir': ["d", "current directory if not specified"],
|
|
281
287
|
'result_dir': ["r", "current directory if not specified"],
|
|
288
|
+
'webcam_id': ["w", "webcam ID. 0 if not specified"],
|
|
282
289
|
'show_realtime_results': ["R", "show results in real-time. true if not specified"],
|
|
283
290
|
'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
|
|
284
291
|
'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
|
|
@@ -303,11 +310,8 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
303
310
|
'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
|
|
304
311
|
'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
|
|
305
312
|
'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
313
|
'feet_on_floor': ["", "offset marker augmentation results so that feet are at floor level. true if not specified"],
|
|
309
314
|
'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
315
|
'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
|
|
312
316
|
'tracking_mode': ["", "'sports2d' or 'deepsort'. 'deepsort' is slower, harder to parametrize but can be more robust if correctly tuned"],
|
|
313
317
|
'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
|
-
|
|
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"]
|