sports2d 0.7.3__tar.gz → 0.8.0__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.
Files changed (27) hide show
  1. {sports2d-0.7.3 → sports2d-0.8.0}/PKG-INFO +98 -80
  2. {sports2d-0.7.3 → sports2d-0.8.0}/README.md +56 -36
  3. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Demo/Config_demo.toml +9 -10
  4. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Sports2D.py +24 -21
  5. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Utilities/common.py +0 -1
  6. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Utilities/tests.py +38 -20
  7. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/process.py +533 -140
  8. sports2d-0.8.0/pyproject.toml +59 -0
  9. sports2d-0.8.0/setup.cfg +4 -0
  10. {sports2d-0.7.3 → sports2d-0.8.0}/sports2d.egg-info/PKG-INFO +98 -80
  11. {sports2d-0.7.3 → sports2d-0.8.0}/sports2d.egg-info/SOURCES.txt +0 -4
  12. sports2d-0.8.0/sports2d.egg-info/entry_points.txt +3 -0
  13. {sports2d-0.7.3 → sports2d-0.8.0}/sports2d.egg-info/requires.txt +7 -7
  14. sports2d-0.8.0/sports2d.egg-info/top_level.txt +3 -0
  15. sports2d-0.7.3/Sports2D/Utilities/skeletons.py +0 -1000
  16. sports2d-0.7.3/pyproject.toml +0 -3
  17. sports2d-0.7.3/setup.cfg +0 -62
  18. sports2d-0.7.3/setup.py +0 -8
  19. sports2d-0.7.3/sports2d.egg-info/entry_points.txt +0 -2
  20. sports2d-0.7.3/sports2d.egg-info/not-zip-safe +0 -1
  21. sports2d-0.7.3/sports2d.egg-info/top_level.txt +0 -1
  22. {sports2d-0.7.3 → sports2d-0.8.0}/LICENSE +0 -0
  23. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Demo/demo.mp4 +0 -0
  24. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Utilities/__init__.py +0 -0
  25. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/Utilities/filter.py +0 -0
  26. {sports2d-0.7.3 → sports2d-0.8.0}/Sports2D/__init__.py +0 -0
  27. {sports2d-0.7.3 → sports2d-0.8.0}/sports2d.egg-info/dependency_links.txt +0 -0
@@ -1,14 +1,41 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sports2d
3
- Version: 0.7.3
4
- Summary: Detect pose and compute 2D joint angles from a video.
5
- Home-page: https://github.com/davidpagnon/Sports2D
6
- Author: David Pagnon
7
- Author-email: contact@david-pagnon.com
3
+ Version: 0.8.0
4
+ Summary: Compute 2D human pose and angles from a video or a webcam.
5
+ Author-email: David Pagnon <contact@david-pagnon.com>
8
6
  License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2022, perfanalytics
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice,
18
+ this list of conditions and the following disclaimer in the documentation
19
+ and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ Project-URL: Homepage, https://github.com/davidpagnon/Sports2D
9
37
  Project-URL: Bug Tracker, https://github.com/davidpagnon/Sports2D/issues
10
- Keywords: markerless,kinematics,OpenPose,BlazePose,joint angles,2D,biomechanics,sports,pose estimation,joint angles,sports analytics,kinovea
11
- Platform: any
38
+ Keywords: markerless,kinematics,OpenPose,OpenSim,Mocap,biomechanics,sports coaching,pose estimation,joint angles,sports analytics,kinovea
12
39
  Classifier: Programming Language :: Python :: 3
13
40
  Classifier: Development Status :: 3 - Alpha
14
41
  Classifier: Intended Audience :: Science/Research
@@ -21,22 +48,23 @@ Classifier: Topic :: Scientific/Engineering :: Image Processing
21
48
  Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
22
49
  Classifier: Topic :: Multimedia :: Graphics
23
50
  Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
51
+ Requires-Python: >=3.9
24
52
  Description-Content-Type: text/markdown
25
53
  License-File: LICENSE
26
- Requires-Dist: ipython
27
54
  Requires-Dist: toml
28
- Requires-Dist: numpy
29
- Requires-Dist: pandas>=1.5
30
- Requires-Dist: scipy
31
- Requires-Dist: anytree
32
- Requires-Dist: opencv-python
55
+ Requires-Dist: numpy>=1.19
33
56
  Requires-Dist: matplotlib
34
57
  Requires-Dist: PyQt5
58
+ Requires-Dist: tqdm
59
+ Requires-Dist: anytree
60
+ Requires-Dist: pandas>=1.5
61
+ Requires-Dist: scipy
35
62
  Requires-Dist: statsmodels
63
+ Requires-Dist: ipython
36
64
  Requires-Dist: c3d
37
65
  Requires-Dist: rtmlib
38
66
  Requires-Dist: openvino
39
- Requires-Dist: tqdm
67
+ Requires-Dist: opencv-python
40
68
  Requires-Dist: imageio_ffmpeg
41
69
  Requires-Dist: deep-sort-realtime
42
70
  Requires-Dist: Pose2Sim
@@ -44,15 +72,18 @@ Dynamic: license-file
44
72
 
45
73
 
46
74
  [![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)
47
- [![PyPI version](https://badge.fury.io/py/Sports2D.svg)](https://badge.fury.io/py/Sports2D)\
75
+ [![PyPI version](https://badge.fury.io/py/Sports2D.svg)](https://badge.fury.io/py/Sports2D)
76
+ \
48
77
  [![Downloads](https://static.pepy.tech/badge/sports2d)](https://pepy.tech/project/sports2d)
49
78
  [![Stars](https://img.shields.io/github/stars/davidpagnon/sports2d)](https://github.com/davidpagnon/sports2d/stargazers)
50
79
  [![GitHub issues](https://img.shields.io/github/issues/davidpagnon/sports2d)](https://github.com/davidpagnon/sports2d/issues)
51
- [![GitHub issues-closed](https://img.shields.io/github/issues-closed/davidpagnon/sports2d)](https://GitHub.com/davidpagnon/sports2d/issues?q=is%3Aissue+is%3Aclosed)\
80
+ [![GitHub issues-closed](https://img.shields.io/github/issues-closed/davidpagnon/sports2d)](https://GitHub.com/davidpagnon/sports2d/issues?q=is%3Aissue+is%3Aclosed)
81
+ \
52
82
  [![status](https://joss.theoj.org/papers/1d525bbb2695c88c6ebbf2297bd35897/status.svg)](https://joss.theoj.org/papers/1d525bbb2695c88c6ebbf2297bd35897)
53
83
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10576574.svg)](https://zenodo.org/doi/10.5281/zenodo.7903962)
54
84
  [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
55
-
85
+ \
86
+ [![Discord](https://img.shields.io/discord/1183750225471492206?logo=Discord&label=Discord%20community)](https://discord.com/invite/4mXUdSFjmt)
56
87
 
57
88
  <!-- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://bit.ly/Sports2D_Colab)-->
58
89
 
@@ -64,8 +95,8 @@ Dynamic: license-file
64
95
 
65
96
  </br>
66
97
 
67
- > **`Announcement:`\
68
- > Complete rewriting of the code!** Run `pip install sports2d -U` to get the latest version.
98
+ > **`Announcements:`**
99
+ > - Select only the persons you want to analyze **New in v0.8!**
69
100
  > - MarkerAugmentation and Inverse Kinematics for accurate 3D motion with OpenSim. **New in v0.7!**
70
101
  > - Any detector and pose estimation model can be used. **New in v0.6!**
71
102
  > - Results in meters rather than pixels. **New in v0.5!**
@@ -73,6 +104,8 @@ Dynamic: license-file
73
104
  > - Works from a webcam
74
105
  > - Better visualization output
75
106
  > - More flexible, easier to run
107
+ >
108
+ > Run `pip install sports2d -U` to get the latest version.
76
109
 
77
110
  ***N.B.:*** As always, I am more than happy to welcome contributions (see [How to contribute](#how-to-contribute-and-to-do-list))!
78
111
  <!--User-friendly Colab version released! (and latest issues fixed, too)\
@@ -108,14 +141,15 @@ If you need 3D research-grade markerless joint kinematics, consider using severa
108
141
  3. [Play with the parameters](#play-with-the-parameters)
109
142
  1. [Run on a custom video or on a webcam](#run-on-a-custom-video-or-on-a-webcam)
110
143
  2. [Run for a specific time range](#run-for-a-specific-time-range)
111
- 3. [Get coordinates in meters](#get-coordinates-in-meters)
112
- 4. [Run inverse kinematics](#run-inverse-kinematics)
113
- 5. [Run on several videos at once](#run-on-several-videos-at-once)
114
- 6. [Use the configuration file or run within Python](#use-the-configuration-file-or-run-within-python)
115
- 7. [Get the angles the way you want](#get-the-angles-the-way-you-want)
116
- 8. [Customize your output](#customize-your-output)
117
- 9. [Use a custom pose estimation model](#use-a-custom-pose-estimation-model)
118
- 10. [All the parameters](#all-the-parameters)
144
+ 3. [Select the persons you are interested in](#select-the-persons-you-are-interested-in)
145
+ 4. [Get coordinates in meters](#get-coordinates-in-meters)
146
+ 5. [Run inverse kinematics](#run-inverse-kinematics)
147
+ 6. [Run on several videos at once](#run-on-several-videos-at-once)
148
+ 7. [Use the configuration file or run within Python](#use-the-configuration-file-or-run-within-python)
149
+ 8. [Get the angles the way you want](#get-the-angles-the-way-you-want)
150
+ 9. [Customize your output](#customize-your-output)
151
+ 10. [Use a custom pose estimation model](#use-a-custom-pose-estimation-model)
152
+ 11. [All the parameters](#all-the-parameters)
119
153
  2. [Go further](#go-further)
120
154
  1. [Too slow for you?](#too-slow-for-you)
121
155
  3. [Run inverse kinematics](#run-inverse-kinematics)
@@ -263,7 +297,6 @@ sports2d --video_input webcam
263
297
 
264
298
  <br>
265
299
 
266
-
267
300
  #### Run for a specific time range:
268
301
  ```cmd
269
302
  sports2d --time_range 1.2 2.7
@@ -272,6 +305,28 @@ sports2d --time_range 1.2 2.7
272
305
  <br>
273
306
 
274
307
 
308
+ #### Select the persons you are interested in:
309
+ If you only want to analyze a subset of the detected persons, you can use the `--nb_persons_to_detect` and `--person_ordering_method` parameters. The order matters if you want to [convert coordinates in meters](#get-coordinates-in-meters) or [run inverse kinematics](#run-inverse-kinematics).
310
+
311
+
312
+ ``` cmd
313
+ sports2d --nb_persons_to_detect 2 --person_ordering_method highest_likelihood
314
+ ```
315
+
316
+ We recommend to use the `on_click` method if you can afford a manual input. This lets the user handle both the person number and their order in the same stage. When prompted, select the persons you are interested in in the desired order. In our case, lets slide to a frame where both people are visible, and select the woman first, then the man.
317
+
318
+ ``` cmd
319
+ sports2d --person_ordering_method on_click
320
+ ```
321
+
322
+
323
+
324
+ <img src="Content/Person_selection.png" width="760">
325
+
326
+
327
+ <br>
328
+
329
+
275
330
  #### Get coordinates in meters:
276
331
  > **N.B.:** Depth is estimated from a neutral pose.
277
332
 
@@ -288,11 +343,12 @@ Also note that distortions are not taken into account, and that results will be
288
343
  sports2d --to_meters True --calib_file calib_demo.toml
289
344
  ``` -->
290
345
  ``` cmd
291
- sports2d --to_meters True --px_to_m_person_height 1.65 --px_to_m_from_person_id 2
346
+ sports2d --to_meters True --first_person_height 1.65 --visible_side auto front none
292
347
  ```
293
348
  ``` cmd
294
- sports2d --to_meters True --px_to_m_person_height 1.65 --px_to_m_from_person_id 2 `
295
- --visible_side front none auto --floor_angle 0 --xy_origin 0 940
349
+ sports2d --to_meters True --first_person_height 1.65 --visible_side auto front none `
350
+ --person_ordering_method on_click `
351
+ --floor_angle 0 --xy_origin 0 940
296
352
  ```
297
353
 
298
354
  <br>
@@ -310,9 +366,7 @@ Model scaling is done according to the mean of the segment lengths, across a sub
310
366
 
311
367
  ```cmd
312
368
  sports2d --time_range 1.2 2.7 `
313
- --do_ik true `
314
- --px_to_m_from_person_id 1 --px_to_m_person_height 1.65 `
315
- --visible_side front auto
369
+ --do_ik true --first_person_height 1.65 --visible_side auto front
316
370
  ```
317
371
 
318
372
  You can optionally use the LSTM marker augmentation to improve the quality of the output motion.\
@@ -320,9 +374,8 @@ You can also optionally give the participants proper masses. Mass has no influen
320
374
 
321
375
  ```cmd
322
376
  sports2d --time_range 1.2 2.7 `
323
- --do_ik true --use_augmentation True `
324
- --px_to_m_from_person_id 1 --px_to_m_person_height 1.65 `
325
- --visible_side front left --participant_mass 67.0 55.0
377
+ --do_ik true --first_person_height 1.65 --visible_side left front `
378
+ --use_augmentation True --participant_mass 55.0 67.0
326
379
  ```
327
380
 
328
381
  <br>
@@ -382,10 +435,6 @@ sports2d --video_input demo.mp4 other_video.mp4 --time_range 1.2 2.7 0 3.5
382
435
 
383
436
 
384
437
  #### Customize your output:
385
- - Only analyze the most prominent person:
386
- ``` cmd
387
- sports2d --multiperson false
388
- ```
389
438
  - Choose whether you want video, images, trc pose file, angle mot file, real-time display, and plots:
390
439
  ```cmd
391
440
  sports2d --save_vid false --save_img true `
@@ -431,8 +480,10 @@ sports2d --help
431
480
  'config': ["C", "path to a toml configuration file"],
432
481
 
433
482
  '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"],
434
- 'px_to_m_person_height': ["H", "height of the person in meters. 1.70 if not specified"],
435
- 'visible_side': ["", "front, back, left, right, auto, or none. 'front none 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"],
483
+ 'nb_persons_to_detect': ["n", "number of persons to detect. int or 'all'. 'all' if not specified"],
484
+ 'person_ordering_method': ["", "'on_click', 'highest_likelihood', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'. 'on_click' if not specified"],
485
+ '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
+ '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"],
436
487
  'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
437
488
  'compare': ["", "visually compare motion with trc file. false if not specified"],
438
489
  'webcam_id': ["w", "webcam ID. 0 if not specified"],
@@ -458,7 +509,6 @@ sports2d --help
458
509
  'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
459
510
  'to_meters': ["M", "convert pixels to meters. true if not specified"],
460
511
  'make_c3d': ["", "Convert trc to c3d file. true if not specified"],
461
- 'px_to_m_from_person_id': ["", "person ID to calibrate on. 0 if not specified"],
462
512
  'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
463
513
  'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
464
514
  'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
@@ -468,7 +518,6 @@ sports2d --help
468
518
  'use_contacts_muscles': ["", "Use model with contact spheres and muscles. false if not specified"],
469
519
  '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)"],
470
520
  'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
471
- 'multiperson': ["", "multiperson involves tracking: will be faster if set to false. true if not specified"],
472
521
  'tracking_mode': ["", "'sports2d' or 'deepsort'. 'deepsort' is slower, harder to parametrize but can be more robust if correctly tuned"],
473
522
  'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
474
523
  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\
@@ -500,7 +549,8 @@ sports2d --help
500
549
  'remove_individual_scaling_setup': ["", "remove individual scaling setup files generated during scaling. true if not specified"],
501
550
  'remove_individual_ik_setup': ["", "remove individual IK setup files generated during IK. true if not specified"],
502
551
  'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
503
- 'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
552
+ 'close_to_zero_speed_m': ["","Sum for all keypoints: about 0.2 m/frame. Defaults to 0.2"],
553
+ 'close_to_zero_speed_px': ["", "Sum for all keypoints: about 50 px/frame. Defaults to 50"],
504
554
  'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise and ignored. Defaults to 45"],
505
555
  'trimmed_extrema_percent': ["", "Proportion of the most extreme segment values to remove before calculating their mean. Defaults to 50"],
506
556
  'use_custom_logging': ["", "use custom logging. false if not specified"]
@@ -526,7 +576,6 @@ Note that any detection and pose models can be used (first [deploy them with MMP
526
576
  'pose_input_size':[192,256]}"""
527
577
  ```
528
578
  - Use `--det_frequency 50`: Will detect poses only every 50 frames, and track keypoints in between, which is faster.
529
- - Use `--multiperson false`: Can be used if one single person is present in the video. Otherwise, persons' IDs may be mixed up.
530
579
  - Use `--load_trc_px <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.
531
580
  - Make sure you 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.
532
581
 
@@ -680,10 +729,9 @@ You will be proposed a to-do list, but please feel absolutely free to propose yo
680
729
  - [x] Run again without pose estimation with the option `--load_trc_px` for px .trc file.
681
730
  - [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)
682
731
  - [x] Support any detection and/or pose estimation model.
732
+ - [x] Optionally let user select the persons of interest.
733
+ - [x] 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.
683
734
 
684
- - [ ] 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.
685
- - [ ] Optionally let user select the person of interest in single_person mode:\
686
- `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.`
687
735
  - [ ] 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.
688
736
  - [ ] **Colab version**: more user-friendly, usable on a smartphone.
689
737
  - [ ] **GUI applications** for Windows, Mac, and Linux, as well as for Android and iOS.
@@ -694,33 +742,3 @@ You will be proposed a to-do list, but please feel absolutely free to propose yo
694
742
  - [ ] **Pose refinement**. Click and move badly estimated 2D points. See [DeepLabCut](https://www.youtube.com/watch?v=bEuBKB7eqmk) for inspiration.
695
743
  - [ ] Add tools for annotating images, undistort them, take perspective into account, etc. (cf. [Kinovea](https://www.kinovea.org/features.html)).
696
744
 
697
-
698
- BSD 3-Clause License
699
-
700
- Copyright (c) 2022, perfanalytics
701
- All rights reserved.
702
-
703
- Redistribution and use in source and binary forms, with or without
704
- modification, are permitted provided that the following conditions are met:
705
-
706
- 1. Redistributions of source code must retain the above copyright notice, this
707
- list of conditions and the following disclaimer.
708
-
709
- 2. Redistributions in binary form must reproduce the above copyright notice,
710
- this list of conditions and the following disclaimer in the documentation
711
- and/or other materials provided with the distribution.
712
-
713
- 3. Neither the name of the copyright holder nor the names of its
714
- contributors may be used to endorse or promote products derived from
715
- this software without specific prior written permission.
716
-
717
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
718
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
719
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
720
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
721
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
722
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
723
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
724
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
725
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
726
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,14 +1,17 @@
1
1
 
2
2
  [![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)
3
- [![PyPI version](https://badge.fury.io/py/Sports2D.svg)](https://badge.fury.io/py/Sports2D)\
3
+ [![PyPI version](https://badge.fury.io/py/Sports2D.svg)](https://badge.fury.io/py/Sports2D)
4
+ \
4
5
  [![Downloads](https://static.pepy.tech/badge/sports2d)](https://pepy.tech/project/sports2d)
5
6
  [![Stars](https://img.shields.io/github/stars/davidpagnon/sports2d)](https://github.com/davidpagnon/sports2d/stargazers)
6
7
  [![GitHub issues](https://img.shields.io/github/issues/davidpagnon/sports2d)](https://github.com/davidpagnon/sports2d/issues)
7
- [![GitHub issues-closed](https://img.shields.io/github/issues-closed/davidpagnon/sports2d)](https://GitHub.com/davidpagnon/sports2d/issues?q=is%3Aissue+is%3Aclosed)\
8
+ [![GitHub issues-closed](https://img.shields.io/github/issues-closed/davidpagnon/sports2d)](https://GitHub.com/davidpagnon/sports2d/issues?q=is%3Aissue+is%3Aclosed)
9
+ \
8
10
  [![status](https://joss.theoj.org/papers/1d525bbb2695c88c6ebbf2297bd35897/status.svg)](https://joss.theoj.org/papers/1d525bbb2695c88c6ebbf2297bd35897)
9
11
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10576574.svg)](https://zenodo.org/doi/10.5281/zenodo.7903962)
10
12
  [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
11
-
13
+ \
14
+ [![Discord](https://img.shields.io/discord/1183750225471492206?logo=Discord&label=Discord%20community)](https://discord.com/invite/4mXUdSFjmt)
12
15
 
13
16
  <!-- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://bit.ly/Sports2D_Colab)-->
14
17
 
@@ -20,8 +23,8 @@
20
23
 
21
24
  </br>
22
25
 
23
- > **`Announcement:`\
24
- > Complete rewriting of the code!** Run `pip install sports2d -U` to get the latest version.
26
+ > **`Announcements:`**
27
+ > - Select only the persons you want to analyze **New in v0.8!**
25
28
  > - MarkerAugmentation and Inverse Kinematics for accurate 3D motion with OpenSim. **New in v0.7!**
26
29
  > - Any detector and pose estimation model can be used. **New in v0.6!**
27
30
  > - Results in meters rather than pixels. **New in v0.5!**
@@ -29,6 +32,8 @@
29
32
  > - Works from a webcam
30
33
  > - Better visualization output
31
34
  > - More flexible, easier to run
35
+ >
36
+ > Run `pip install sports2d -U` to get the latest version.
32
37
 
33
38
  ***N.B.:*** As always, I am more than happy to welcome contributions (see [How to contribute](#how-to-contribute-and-to-do-list))!
34
39
  <!--User-friendly Colab version released! (and latest issues fixed, too)\
@@ -64,14 +69,15 @@ If you need 3D research-grade markerless joint kinematics, consider using severa
64
69
  3. [Play with the parameters](#play-with-the-parameters)
65
70
  1. [Run on a custom video or on a webcam](#run-on-a-custom-video-or-on-a-webcam)
66
71
  2. [Run for a specific time range](#run-for-a-specific-time-range)
67
- 3. [Get coordinates in meters](#get-coordinates-in-meters)
68
- 4. [Run inverse kinematics](#run-inverse-kinematics)
69
- 5. [Run on several videos at once](#run-on-several-videos-at-once)
70
- 6. [Use the configuration file or run within Python](#use-the-configuration-file-or-run-within-python)
71
- 7. [Get the angles the way you want](#get-the-angles-the-way-you-want)
72
- 8. [Customize your output](#customize-your-output)
73
- 9. [Use a custom pose estimation model](#use-a-custom-pose-estimation-model)
74
- 10. [All the parameters](#all-the-parameters)
72
+ 3. [Select the persons you are interested in](#select-the-persons-you-are-interested-in)
73
+ 4. [Get coordinates in meters](#get-coordinates-in-meters)
74
+ 5. [Run inverse kinematics](#run-inverse-kinematics)
75
+ 6. [Run on several videos at once](#run-on-several-videos-at-once)
76
+ 7. [Use the configuration file or run within Python](#use-the-configuration-file-or-run-within-python)
77
+ 8. [Get the angles the way you want](#get-the-angles-the-way-you-want)
78
+ 9. [Customize your output](#customize-your-output)
79
+ 10. [Use a custom pose estimation model](#use-a-custom-pose-estimation-model)
80
+ 11. [All the parameters](#all-the-parameters)
75
81
  2. [Go further](#go-further)
76
82
  1. [Too slow for you?](#too-slow-for-you)
77
83
  3. [Run inverse kinematics](#run-inverse-kinematics)
@@ -219,7 +225,6 @@ sports2d --video_input webcam
219
225
 
220
226
  <br>
221
227
 
222
-
223
228
  #### Run for a specific time range:
224
229
  ```cmd
225
230
  sports2d --time_range 1.2 2.7
@@ -228,6 +233,28 @@ sports2d --time_range 1.2 2.7
228
233
  <br>
229
234
 
230
235
 
236
+ #### Select the persons you are interested in:
237
+ If you only want to analyze a subset of the detected persons, you can use the `--nb_persons_to_detect` and `--person_ordering_method` parameters. The order matters if you want to [convert coordinates in meters](#get-coordinates-in-meters) or [run inverse kinematics](#run-inverse-kinematics).
238
+
239
+
240
+ ``` cmd
241
+ sports2d --nb_persons_to_detect 2 --person_ordering_method highest_likelihood
242
+ ```
243
+
244
+ We recommend to use the `on_click` method if you can afford a manual input. This lets the user handle both the person number and their order in the same stage. When prompted, select the persons you are interested in in the desired order. In our case, lets slide to a frame where both people are visible, and select the woman first, then the man.
245
+
246
+ ``` cmd
247
+ sports2d --person_ordering_method on_click
248
+ ```
249
+
250
+
251
+
252
+ <img src="Content/Person_selection.png" width="760">
253
+
254
+
255
+ <br>
256
+
257
+
231
258
  #### Get coordinates in meters:
232
259
  > **N.B.:** Depth is estimated from a neutral pose.
233
260
 
@@ -244,11 +271,12 @@ Also note that distortions are not taken into account, and that results will be
244
271
  sports2d --to_meters True --calib_file calib_demo.toml
245
272
  ``` -->
246
273
  ``` cmd
247
- sports2d --to_meters True --px_to_m_person_height 1.65 --px_to_m_from_person_id 2
274
+ sports2d --to_meters True --first_person_height 1.65 --visible_side auto front none
248
275
  ```
249
276
  ``` cmd
250
- sports2d --to_meters True --px_to_m_person_height 1.65 --px_to_m_from_person_id 2 `
251
- --visible_side front none auto --floor_angle 0 --xy_origin 0 940
277
+ sports2d --to_meters True --first_person_height 1.65 --visible_side auto front none `
278
+ --person_ordering_method on_click `
279
+ --floor_angle 0 --xy_origin 0 940
252
280
  ```
253
281
 
254
282
  <br>
@@ -266,9 +294,7 @@ Model scaling is done according to the mean of the segment lengths, across a sub
266
294
 
267
295
  ```cmd
268
296
  sports2d --time_range 1.2 2.7 `
269
- --do_ik true `
270
- --px_to_m_from_person_id 1 --px_to_m_person_height 1.65 `
271
- --visible_side front auto
297
+ --do_ik true --first_person_height 1.65 --visible_side auto front
272
298
  ```
273
299
 
274
300
  You can optionally use the LSTM marker augmentation to improve the quality of the output motion.\
@@ -276,9 +302,8 @@ You can also optionally give the participants proper masses. Mass has no influen
276
302
 
277
303
  ```cmd
278
304
  sports2d --time_range 1.2 2.7 `
279
- --do_ik true --use_augmentation True `
280
- --px_to_m_from_person_id 1 --px_to_m_person_height 1.65 `
281
- --visible_side front left --participant_mass 67.0 55.0
305
+ --do_ik true --first_person_height 1.65 --visible_side left front `
306
+ --use_augmentation True --participant_mass 55.0 67.0
282
307
  ```
283
308
 
284
309
  <br>
@@ -338,10 +363,6 @@ sports2d --video_input demo.mp4 other_video.mp4 --time_range 1.2 2.7 0 3.5
338
363
 
339
364
 
340
365
  #### Customize your output:
341
- - Only analyze the most prominent person:
342
- ``` cmd
343
- sports2d --multiperson false
344
- ```
345
366
  - Choose whether you want video, images, trc pose file, angle mot file, real-time display, and plots:
346
367
  ```cmd
347
368
  sports2d --save_vid false --save_img true `
@@ -387,8 +408,10 @@ sports2d --help
387
408
  'config': ["C", "path to a toml configuration file"],
388
409
 
389
410
  '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"],
390
- 'px_to_m_person_height': ["H", "height of the person in meters. 1.70 if not specified"],
391
- 'visible_side': ["", "front, back, left, right, auto, or none. 'front none 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"],
411
+ 'nb_persons_to_detect': ["n", "number of persons to detect. int or 'all'. 'all' if not specified"],
412
+ 'person_ordering_method': ["", "'on_click', 'highest_likelihood', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'. 'on_click' if not specified"],
413
+ 'first_person_height': ["H", "height of the reference person in meters. 1.65 if not specified. Not used if a calibration file is provided"],
414
+ '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"],
392
415
  'load_trc_px': ["", "load trc file to avaid running pose estimation again. false if not specified"],
393
416
  'compare': ["", "visually compare motion with trc file. false if not specified"],
394
417
  'webcam_id': ["w", "webcam ID. 0 if not specified"],
@@ -414,7 +437,6 @@ sports2d --help
414
437
  'device': ["", "Device for pose estimatino can be 'auto', 'openvino', 'onnxruntime', 'opencv'"],
415
438
  'to_meters': ["M", "convert pixels to meters. true if not specified"],
416
439
  'make_c3d': ["", "Convert trc to c3d file. true if not specified"],
417
- 'px_to_m_from_person_id': ["", "person ID to calibrate on. 0 if not specified"],
418
440
  'floor_angle': ["", "angle of the floor. 'auto' if not specified"],
419
441
  'xy_origin': ["", "origin of the xy plane. 'auto' if not specified"],
420
442
  'calib_file': ["", "path to calibration file. '' if not specified, eg no calibration file"],
@@ -424,7 +446,6 @@ sports2d --help
424
446
  'use_contacts_muscles': ["", "Use model with contact spheres and muscles. false if not specified"],
425
447
  '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)"],
426
448
  'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
427
- 'multiperson': ["", "multiperson involves tracking: will be faster if set to false. true if not specified"],
428
449
  'tracking_mode': ["", "'sports2d' or 'deepsort'. 'deepsort' is slower, harder to parametrize but can be more robust if correctly tuned"],
429
450
  'deepsort_params': ["", 'Deepsort tracking parameters: """{dictionary between 3 double quotes}""". \n\
430
451
  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\
@@ -456,7 +477,8 @@ sports2d --help
456
477
  'remove_individual_scaling_setup': ["", "remove individual scaling setup files generated during scaling. true if not specified"],
457
478
  'remove_individual_ik_setup': ["", "remove individual IK setup files generated during IK. true if not specified"],
458
479
  'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
459
- 'close_to_zero_speed_m': ["","Sum for all keypoints: about 50 px/frame or 0.2 m/frame"],
480
+ 'close_to_zero_speed_m': ["","Sum for all keypoints: about 0.2 m/frame. Defaults to 0.2"],
481
+ 'close_to_zero_speed_px': ["", "Sum for all keypoints: about 50 px/frame. Defaults to 50"],
460
482
  'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise and ignored. Defaults to 45"],
461
483
  'trimmed_extrema_percent': ["", "Proportion of the most extreme segment values to remove before calculating their mean. Defaults to 50"],
462
484
  'use_custom_logging': ["", "use custom logging. false if not specified"]
@@ -482,7 +504,6 @@ Note that any detection and pose models can be used (first [deploy them with MMP
482
504
  'pose_input_size':[192,256]}"""
483
505
  ```
484
506
  - Use `--det_frequency 50`: Will detect poses only every 50 frames, and track keypoints in between, which is faster.
485
- - Use `--multiperson false`: Can be used if one single person is present in the video. Otherwise, persons' IDs may be mixed up.
486
507
  - Use `--load_trc_px <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.
487
508
  - Make sure you 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.
488
509
 
@@ -636,10 +657,9 @@ You will be proposed a to-do list, but please feel absolutely free to propose yo
636
657
  - [x] Run again without pose estimation with the option `--load_trc_px` for px .trc file.
637
658
  - [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)
638
659
  - [x] Support any detection and/or pose estimation model.
660
+ - [x] Optionally let user select the persons of interest.
661
+ - [x] 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.
639
662
 
640
- - [ ] 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.
641
- - [ ] Optionally let user select the person of interest in single_person mode:\
642
- `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.`
643
663
  - [ ] 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.
644
664
  - [ ] **Colab version**: more user-friendly, usable on a smartphone.
645
665
  - [ ] **GUI applications** for Windows, Mac, and Linux, as well as for Android and iOS.
@@ -11,15 +11,18 @@
11
11
  # Sports2D.process('Config_demo.toml')
12
12
 
13
13
 
14
- [project]
14
+ [base]
15
15
  video_input = 'demo.mp4' # 'webcam' or '<video_path.ext>', or ['video1_path.mp4', 'video2_path.avi>', ...]
16
16
  # On Windows, replace '\' with '/'
17
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.
18
+
19
+ nb_persons_to_detect = 'all' # int or 'all' # Limiting or not the number of persons to be analyzed
20
+ person_ordering_method = 'highest_likelihood' # 'on_click', 'highest_likelihood', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'
21
+ first_person_height = 1.65 # Height of the reference person in meters (for pixels -> meters conversion: not used if a calibration file is provided)
22
+ visible_side = ['auto', 'front', 'none'] # Choose visible side among ['right', 'left', 'front', 'back', 'auto', 'none']. String or list of strings.
21
23
  # if 'auto', will be either 'left', 'right', or 'front' depending on the direction of the motion
22
24
  # if 'none', coordinates will be left in 2D rather than 3D
25
+
23
26
  load_trc_px = '' # If you do not want to recalculate pose, load it from a trc file (in px, not in m)
24
27
  compare = false # Not implemented yet
25
28
 
@@ -32,10 +35,6 @@ video_dir = '' # If empty, video dir is current dir
32
35
  webcam_id = 0 # your webcam id (0 is default)
33
36
  input_size = [1280, 720] # [W, H]. Lower resolution will be faster but less precise.
34
37
 
35
-
36
- [process]
37
- multiperson = true # Saving the motions of all the persons detected and tracked in the video.
38
- # If false, the person saved will be the one with the highest sum of keypoint scores over the video
39
38
  show_realtime_results = true
40
39
  save_vid = true
41
40
  save_img = true
@@ -107,7 +106,7 @@ to_meters = true
107
106
  make_c3d = true
108
107
  save_calib = true # Coming soon!
109
108
 
110
- # If conversion from px_to_m_person_height
109
+ # If conversion from first_person_height
111
110
  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)
112
111
  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
113
112
 
@@ -154,7 +153,7 @@ filter_type = 'butterworth' # butterworth, gaussian, LOESS, median
154
153
  do_ik = false # Do scaling and inverse kinematics?
155
154
  use_augmentation = false # true or false (lowercase) # Set to true if you want to use the model with augmented markers
156
155
  use_contacts_muscles = true # true or false (lowercase) # If true, contact spheres and muscles are added to the model
157
- participant_mass = [67.0, 55.0] # kg # defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)
156
+ participant_mass = [55.0, 67.0] # kg # defaults to 70 if not provided. No influence on kinematics (motion), only on kinetics (forces)
158
157
  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)
159
158
 
160
159
  # Choosing best frames to scale the model