sports2d 0.8.20__tar.gz → 0.8.22__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.20 → sports2d-0.8.22}/PKG-INFO +67 -37
- {sports2d-0.8.20 → sports2d-0.8.22}/README.md +65 -35
- sports2d-0.8.22/Sports2D/Demo/Calib_demo.toml +12 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Demo/Config_demo.toml +7 -6
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Sports2D.py +17 -4
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Utilities/tests.py +30 -8
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/process.py +308 -237
- {sports2d-0.8.20 → sports2d-0.8.22}/pyproject.toml +1 -1
- {sports2d-0.8.20 → sports2d-0.8.22}/sports2d.egg-info/PKG-INFO +67 -37
- {sports2d-0.8.20 → sports2d-0.8.22}/sports2d.egg-info/SOURCES.txt +1 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/sports2d.egg-info/requires.txt +1 -1
- {sports2d-0.8.20 → sports2d-0.8.22}/.github/workflows/continuous-integration.yml +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/.github/workflows/joss_pdf.yml +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/.github/workflows/publish-on-release.yml +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/.gitignore +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/CITATION.cff +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/Demo_plots.png +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/Demo_results.png +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/Demo_terminal.png +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/Person_selection.png +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/Video_tuto_Sports2D_Colab.png +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/joint_convention.png +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/paper.bib +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/paper.md +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/sports2d_blender.gif +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Content/sports2d_opensim.gif +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/LICENSE +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Demo/demo.mp4 +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Sports2D.ipynb +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Utilities/__init__.py +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/Utilities/common.py +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/Sports2D/__init__.py +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/setup.cfg +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/sports2d.egg-info/dependency_links.txt +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/sports2d.egg-info/entry_points.txt +0 -0
- {sports2d-0.8.20 → sports2d-0.8.22}/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.22
|
|
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>
|
|
@@ -38,7 +38,7 @@ Requires-Dist: openvino
|
|
|
38
38
|
Requires-Dist: opencv-python<4.12
|
|
39
39
|
Requires-Dist: imageio_ffmpeg
|
|
40
40
|
Requires-Dist: deep-sort-realtime
|
|
41
|
-
Requires-Dist: Pose2Sim>=0.10.
|
|
41
|
+
Requires-Dist: Pose2Sim>=0.10.38
|
|
42
42
|
Dynamic: license-file
|
|
43
43
|
|
|
44
44
|
|
|
@@ -67,6 +67,7 @@ Dynamic: license-file
|
|
|
67
67
|
</br>
|
|
68
68
|
|
|
69
69
|
> **`Announcements:`**
|
|
70
|
+
> - Generate or import a calibration file, OpenSim skeleton overlay **New in v0.9!**
|
|
70
71
|
> - Select only the persons you want to analyze **New in v0.8!**
|
|
71
72
|
> - MarkerAugmentation and Inverse Kinematics for accurate 3D motion with OpenSim. **New in v0.7!**
|
|
72
73
|
> - Any detector and pose estimation model can be used. **New in v0.6!**
|
|
@@ -218,16 +219,19 @@ The Demo video is voluntarily challenging to demonstrate the robustness of the p
|
|
|
218
219
|
|
|
219
220
|
1. **Install the Pose2Sim_Blender add-on.**\
|
|
220
221
|
Follow instructions on the [Pose2Sim_Blender](https://github.com/davidpagnon/Pose2Sim_Blender) add-on page.
|
|
222
|
+
2. **Import the camera and video.**
|
|
223
|
+
- **Cameras -> Import**: Open your `demo_calib.toml` file from your `result_dir` folder.
|
|
224
|
+
- **Images/Videos -> Show**: open your video file (e.g., `demo_Sports2D.mp4`).\
|
|
225
|
+
-> **Other tools -> See through camera**
|
|
221
226
|
2. **Open your point coordinates.**\
|
|
222
|
-
**
|
|
223
|
-
|
|
227
|
+
**OpenSim data -> Markers**: Open your trc file(e.g., `demo_Sports2D_m_person00.trc`) from your `result_dir` folder.\
|
|
224
228
|
This will optionally create **an animated rig** based on the motion of the captured person.
|
|
225
229
|
3. **Open your animated skeleton:**\
|
|
226
230
|
Make sure you first set `--do_ik True` ([full install](#full-install) required). See [inverse kinematics](#run-inverse-kinematics) section for more details.
|
|
227
|
-
- **
|
|
228
|
-
- **
|
|
231
|
+
- **OpenSim data -> Model**: Open your scaled model (e.g., `demo_Sports2D_m_person00_LSTM.osim`).
|
|
232
|
+
- **OpenSim data -> Motion**: Open your motion file (e.g., `demo_Sports2D_m_person00_LSTM_ik.mot`).
|
|
229
233
|
|
|
230
|
-
The OpenSim skeleton is not rigged yet. **[Feel free to contribute!](https://github.com/perfanalytics/pose2sim/issues/40)**
|
|
234
|
+
The OpenSim skeleton is not rigged yet. **[Feel free to contribute!](https://github.com/perfanalytics/pose2sim/issues/40)** [](https://discord.com/invite/4mXUdSFjmt)
|
|
231
235
|
|
|
232
236
|
<img src="Content/sports2d_blender.gif" width="760">
|
|
233
237
|
|
|
@@ -284,7 +288,7 @@ If you only want to analyze a subset of the detected persons, you can use the `-
|
|
|
284
288
|
sports2d --nb_persons_to_detect 2 --person_ordering_method highest_likelihood
|
|
285
289
|
```
|
|
286
290
|
|
|
287
|
-
We recommend
|
|
291
|
+
We recommend using 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.
|
|
288
292
|
|
|
289
293
|
Otherwise, if you want to run Sports2D automatically for example, you can choose other ordering methods such as 'highest_likelihood', 'largest_size', 'smallest_size', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'.
|
|
290
294
|
|
|
@@ -301,28 +305,32 @@ sports2d --person_ordering_method on_click
|
|
|
301
305
|
|
|
302
306
|
|
|
303
307
|
#### Get coordinates in meters:
|
|
304
|
-
> **N.B.:**
|
|
308
|
+
> **N.B.:** The Z coordinate (depth) should not be overly trusted.
|
|
305
309
|
|
|
306
|
-
|
|
307
|
-
You may need to convert pixel coordinates to meters.\
|
|
308
|
-
Just provide the height of the reference person (and their ID in case of multiple person detection).
|
|
310
|
+
You may want coordinates in meters rather than pixels. 2 options to do so:
|
|
309
311
|
|
|
310
|
-
|
|
312
|
+
1. **Just provide the height of a reference person**:
|
|
313
|
+
- Their height in meters is be compared with their height in pixels to get a pixel-to-meter conversion factor.
|
|
314
|
+
- To estimate the depth coordinates, specify which side of the person is visible: `left`, `right`, `front`, or `back`. Use `auto` if you want it to be automatically determined (only works for motions in the sagittal plane), or `none` if you want to keep 2D coordinates instead of 3D (if the person turns around, for example).
|
|
315
|
+
- The floor angle is automatically estimated from gait, as well as the origin of the xy axis. The person trajectory is corrected accordingly. You can use the `--floor_angle` and `--xy_origin` parameters to manually specify them if your subject is not travelling horizontally or if you want the origin not to be under their feet (note that the `y` axis points down).
|
|
316
|
+
|
|
317
|
+
**N.B.: A calibration file will be generated.** By convention, the camera-to-subject distance is set to 10 meters.
|
|
311
318
|
|
|
312
|
-
|
|
313
|
-
|
|
319
|
+
``` cmd
|
|
320
|
+
sports2d --first_person_height 1.65 --visible_side auto front none
|
|
321
|
+
```
|
|
322
|
+
``` cmd
|
|
323
|
+
sports2d --first_person_height 1.65 --visible_side auto front none `
|
|
324
|
+
--person_ordering_method on_click `
|
|
325
|
+
--floor_angle 0 --xy_origin 0 940
|
|
326
|
+
```
|
|
314
327
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
``` cmd
|
|
319
|
-
sports2d --
|
|
320
|
-
```
|
|
321
|
-
``` cmd
|
|
322
|
-
sports2d --to_meters True --first_person_height 1.65 --visible_side auto front none `
|
|
323
|
-
--person_ordering_method on_click `
|
|
324
|
-
--floor_angle 0 --xy_origin 0 940
|
|
325
|
-
```
|
|
328
|
+
2. **Or use a calibration file**:\
|
|
329
|
+
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.
|
|
330
|
+
|
|
331
|
+
``` cmd
|
|
332
|
+
sports2d --calib_file Calib_demo.toml --visible_side auto front none
|
|
333
|
+
```
|
|
326
334
|
|
|
327
335
|
<br>
|
|
328
336
|
|
|
@@ -337,18 +345,22 @@ OpenSim inverse kinematics allows you to set joint constraints, joint angle limi
|
|
|
337
345
|
This is done via [Pose2Sim](https://github.com/perfanalytics/pose2sim).\
|
|
338
346
|
Model scaling is done according to the mean of the segment lengths, across a subset of frames. We remove the 10% fastest frames (potential outliers), the frames where the speed is 0 (person probably out of frame), the frames where the average knee and hip flexion angles are above 45° (pose estimation is not precise when the person is crouching) and the 20% most extreme segment values after the previous operations (potential outliers). All these parameters can be edited in your Config.toml file.
|
|
339
347
|
|
|
348
|
+
**N.B.: This will not work on sections where the person is not moving in a single plane. You can split your video into several time ranges if needed.**
|
|
349
|
+
|
|
340
350
|
```cmd
|
|
341
351
|
sports2d --time_range 1.2 2.7 `
|
|
342
352
|
--do_ik true --first_person_height 1.65 --visible_side auto front
|
|
343
353
|
```
|
|
344
354
|
|
|
345
355
|
You can optionally use the LSTM marker augmentation to improve the quality of the output motion.\
|
|
346
|
-
You can also optionally give the participants proper masses. Mass has no influence on motion, only on forces (if you decide to further pursue kinetics analysis)
|
|
356
|
+
You can also optionally give the participants proper masses. Mass has no influence on motion, only on forces (if you decide to further pursue kinetics analysis).\
|
|
357
|
+
Optionally again, you can [visualize the overlaid results in Blender](#visualize-in-blender). The automatic calibration won't be accurate with such a small time range, so you need to use the provided calibration file (or one that has been generated from the full walk).
|
|
347
358
|
|
|
348
359
|
```cmd
|
|
349
360
|
sports2d --time_range 1.2 2.7 `
|
|
350
361
|
--do_ik true --first_person_height 1.65 --visible_side left front `
|
|
351
|
-
--use_augmentation True --participant_mass 55.0 67.0
|
|
362
|
+
--use_augmentation True --participant_mass 55.0 67.0 `
|
|
363
|
+
--calib_file Calib_demo.toml
|
|
352
364
|
```
|
|
353
365
|
|
|
354
366
|
<br>
|
|
@@ -376,14 +388,31 @@ sports2d --video_input demo.mp4 other_video.mp4 --time_range 1.2 2.7 0 3.5
|
|
|
376
388
|
``` cmd
|
|
377
389
|
sports2d --config Config_demo.toml
|
|
378
390
|
```
|
|
379
|
-
- Run within Python
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
391
|
+
- Run within Python, for example:\
|
|
392
|
+
- Edit `Demo/Config_demo.toml` and run:
|
|
393
|
+
```python
|
|
394
|
+
from Sports2D import Sports2D
|
|
395
|
+
from pathlib import Path
|
|
396
|
+
import toml
|
|
397
|
+
|
|
398
|
+
config_path = Path(Sports2D.__file__).parent / 'Demo'/'Config_demo.toml'
|
|
399
|
+
config_dict = toml.load(config_path)
|
|
400
|
+
Sports2D.process(config_dict)
|
|
401
|
+
```
|
|
402
|
+
- Or you can pass the non default values only:
|
|
403
|
+
```python
|
|
404
|
+
from Sports2D import Sports2D
|
|
405
|
+
config_dict = {
|
|
406
|
+
'base': {
|
|
407
|
+
'nb_persons_to_detect': 1,
|
|
408
|
+
'person_ordering_method': 'greatest_displacement'
|
|
409
|
+
},
|
|
410
|
+
'pose': {
|
|
411
|
+
'mode': 'lightweight',
|
|
412
|
+
'det_frequency': 50
|
|
413
|
+
}}
|
|
414
|
+
Sports2D.process(config_dict)
|
|
415
|
+
```
|
|
387
416
|
|
|
388
417
|
<br>
|
|
389
418
|
|
|
@@ -407,7 +436,7 @@ sports2d --video_input demo.mp4 other_video.mp4 --time_range 1.2 2.7 0 3.5
|
|
|
407
436
|
```cmd
|
|
408
437
|
sports2d --flip_left_right true # Default
|
|
409
438
|
```
|
|
410
|
-
- Correct segment angles according to the estimated camera
|
|
439
|
+
- Correct segment angles according to the estimated camera tilt angle.\
|
|
411
440
|
**N.B.:** *The camera tilt angle is automatically estimated. Set to false if it is actually the floor which is tilted rather than the camera.*
|
|
412
441
|
```cmd
|
|
413
442
|
sports2d --correct_segment_angles_with_floor_angle true # Default
|
|
@@ -477,6 +506,7 @@ sports2d --help
|
|
|
477
506
|
'show_realtime_results': ["R", "show results in real-time. true if not specified"],
|
|
478
507
|
'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
|
|
479
508
|
'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
|
|
509
|
+
'save_graphs': ["", "save position and angle plots of raw and processed results. false if not specified"],
|
|
480
510
|
'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'],
|
|
481
511
|
'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'],
|
|
482
512
|
'save_vid': ["V", "save processed video. true if not specified"],
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
</br>
|
|
25
25
|
|
|
26
26
|
> **`Announcements:`**
|
|
27
|
+
> - Generate or import a calibration file, OpenSim skeleton overlay **New in v0.9!**
|
|
27
28
|
> - Select only the persons you want to analyze **New in v0.8!**
|
|
28
29
|
> - MarkerAugmentation and Inverse Kinematics for accurate 3D motion with OpenSim. **New in v0.7!**
|
|
29
30
|
> - Any detector and pose estimation model can be used. **New in v0.6!**
|
|
@@ -175,16 +176,19 @@ The Demo video is voluntarily challenging to demonstrate the robustness of the p
|
|
|
175
176
|
|
|
176
177
|
1. **Install the Pose2Sim_Blender add-on.**\
|
|
177
178
|
Follow instructions on the [Pose2Sim_Blender](https://github.com/davidpagnon/Pose2Sim_Blender) add-on page.
|
|
179
|
+
2. **Import the camera and video.**
|
|
180
|
+
- **Cameras -> Import**: Open your `demo_calib.toml` file from your `result_dir` folder.
|
|
181
|
+
- **Images/Videos -> Show**: open your video file (e.g., `demo_Sports2D.mp4`).\
|
|
182
|
+
-> **Other tools -> See through camera**
|
|
178
183
|
2. **Open your point coordinates.**\
|
|
179
|
-
**
|
|
180
|
-
|
|
184
|
+
**OpenSim data -> Markers**: Open your trc file(e.g., `demo_Sports2D_m_person00.trc`) from your `result_dir` folder.\
|
|
181
185
|
This will optionally create **an animated rig** based on the motion of the captured person.
|
|
182
186
|
3. **Open your animated skeleton:**\
|
|
183
187
|
Make sure you first set `--do_ik True` ([full install](#full-install) required). See [inverse kinematics](#run-inverse-kinematics) section for more details.
|
|
184
|
-
- **
|
|
185
|
-
- **
|
|
188
|
+
- **OpenSim data -> Model**: Open your scaled model (e.g., `demo_Sports2D_m_person00_LSTM.osim`).
|
|
189
|
+
- **OpenSim data -> Motion**: Open your motion file (e.g., `demo_Sports2D_m_person00_LSTM_ik.mot`).
|
|
186
190
|
|
|
187
|
-
The OpenSim skeleton is not rigged yet. **[Feel free to contribute!](https://github.com/perfanalytics/pose2sim/issues/40)**
|
|
191
|
+
The OpenSim skeleton is not rigged yet. **[Feel free to contribute!](https://github.com/perfanalytics/pose2sim/issues/40)** [](https://discord.com/invite/4mXUdSFjmt)
|
|
188
192
|
|
|
189
193
|
<img src="Content/sports2d_blender.gif" width="760">
|
|
190
194
|
|
|
@@ -241,7 +245,7 @@ If you only want to analyze a subset of the detected persons, you can use the `-
|
|
|
241
245
|
sports2d --nb_persons_to_detect 2 --person_ordering_method highest_likelihood
|
|
242
246
|
```
|
|
243
247
|
|
|
244
|
-
We recommend
|
|
248
|
+
We recommend using 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
249
|
|
|
246
250
|
Otherwise, if you want to run Sports2D automatically for example, you can choose other ordering methods such as 'highest_likelihood', 'largest_size', 'smallest_size', 'greatest_displacement', 'least_displacement', 'first_detected', or 'last_detected'.
|
|
247
251
|
|
|
@@ -258,28 +262,32 @@ sports2d --person_ordering_method on_click
|
|
|
258
262
|
|
|
259
263
|
|
|
260
264
|
#### Get coordinates in meters:
|
|
261
|
-
> **N.B.:**
|
|
265
|
+
> **N.B.:** The Z coordinate (depth) should not be overly trusted.
|
|
262
266
|
|
|
263
|
-
|
|
264
|
-
You may need to convert pixel coordinates to meters.\
|
|
265
|
-
Just provide the height of the reference person (and their ID in case of multiple person detection).
|
|
267
|
+
You may want coordinates in meters rather than pixels. 2 options to do so:
|
|
266
268
|
|
|
267
|
-
|
|
269
|
+
1. **Just provide the height of a reference person**:
|
|
270
|
+
- Their height in meters is be compared with their height in pixels to get a pixel-to-meter conversion factor.
|
|
271
|
+
- To estimate the depth coordinates, specify which side of the person is visible: `left`, `right`, `front`, or `back`. Use `auto` if you want it to be automatically determined (only works for motions in the sagittal plane), or `none` if you want to keep 2D coordinates instead of 3D (if the person turns around, for example).
|
|
272
|
+
- The floor angle is automatically estimated from gait, as well as the origin of the xy axis. The person trajectory is corrected accordingly. You can use the `--floor_angle` and `--xy_origin` parameters to manually specify them if your subject is not travelling horizontally or if you want the origin not to be under their feet (note that the `y` axis points down).
|
|
273
|
+
|
|
274
|
+
**N.B.: A calibration file will be generated.** By convention, the camera-to-subject distance is set to 10 meters.
|
|
268
275
|
|
|
269
|
-
|
|
270
|
-
|
|
276
|
+
``` cmd
|
|
277
|
+
sports2d --first_person_height 1.65 --visible_side auto front none
|
|
278
|
+
```
|
|
279
|
+
``` cmd
|
|
280
|
+
sports2d --first_person_height 1.65 --visible_side auto front none `
|
|
281
|
+
--person_ordering_method on_click `
|
|
282
|
+
--floor_angle 0 --xy_origin 0 940
|
|
283
|
+
```
|
|
271
284
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
``` cmd
|
|
276
|
-
sports2d --
|
|
277
|
-
```
|
|
278
|
-
``` cmd
|
|
279
|
-
sports2d --to_meters True --first_person_height 1.65 --visible_side auto front none `
|
|
280
|
-
--person_ordering_method on_click `
|
|
281
|
-
--floor_angle 0 --xy_origin 0 940
|
|
282
|
-
```
|
|
285
|
+
2. **Or use a calibration file**:\
|
|
286
|
+
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.
|
|
287
|
+
|
|
288
|
+
``` cmd
|
|
289
|
+
sports2d --calib_file Calib_demo.toml --visible_side auto front none
|
|
290
|
+
```
|
|
283
291
|
|
|
284
292
|
<br>
|
|
285
293
|
|
|
@@ -294,18 +302,22 @@ OpenSim inverse kinematics allows you to set joint constraints, joint angle limi
|
|
|
294
302
|
This is done via [Pose2Sim](https://github.com/perfanalytics/pose2sim).\
|
|
295
303
|
Model scaling is done according to the mean of the segment lengths, across a subset of frames. We remove the 10% fastest frames (potential outliers), the frames where the speed is 0 (person probably out of frame), the frames where the average knee and hip flexion angles are above 45° (pose estimation is not precise when the person is crouching) and the 20% most extreme segment values after the previous operations (potential outliers). All these parameters can be edited in your Config.toml file.
|
|
296
304
|
|
|
305
|
+
**N.B.: This will not work on sections where the person is not moving in a single plane. You can split your video into several time ranges if needed.**
|
|
306
|
+
|
|
297
307
|
```cmd
|
|
298
308
|
sports2d --time_range 1.2 2.7 `
|
|
299
309
|
--do_ik true --first_person_height 1.65 --visible_side auto front
|
|
300
310
|
```
|
|
301
311
|
|
|
302
312
|
You can optionally use the LSTM marker augmentation to improve the quality of the output motion.\
|
|
303
|
-
You can also optionally give the participants proper masses. Mass has no influence on motion, only on forces (if you decide to further pursue kinetics analysis)
|
|
313
|
+
You can also optionally give the participants proper masses. Mass has no influence on motion, only on forces (if you decide to further pursue kinetics analysis).\
|
|
314
|
+
Optionally again, you can [visualize the overlaid results in Blender](#visualize-in-blender). The automatic calibration won't be accurate with such a small time range, so you need to use the provided calibration file (or one that has been generated from the full walk).
|
|
304
315
|
|
|
305
316
|
```cmd
|
|
306
317
|
sports2d --time_range 1.2 2.7 `
|
|
307
318
|
--do_ik true --first_person_height 1.65 --visible_side left front `
|
|
308
|
-
--use_augmentation True --participant_mass 55.0 67.0
|
|
319
|
+
--use_augmentation True --participant_mass 55.0 67.0 `
|
|
320
|
+
--calib_file Calib_demo.toml
|
|
309
321
|
```
|
|
310
322
|
|
|
311
323
|
<br>
|
|
@@ -333,14 +345,31 @@ sports2d --video_input demo.mp4 other_video.mp4 --time_range 1.2 2.7 0 3.5
|
|
|
333
345
|
``` cmd
|
|
334
346
|
sports2d --config Config_demo.toml
|
|
335
347
|
```
|
|
336
|
-
- Run within Python
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
348
|
+
- Run within Python, for example:\
|
|
349
|
+
- Edit `Demo/Config_demo.toml` and run:
|
|
350
|
+
```python
|
|
351
|
+
from Sports2D import Sports2D
|
|
352
|
+
from pathlib import Path
|
|
353
|
+
import toml
|
|
354
|
+
|
|
355
|
+
config_path = Path(Sports2D.__file__).parent / 'Demo'/'Config_demo.toml'
|
|
356
|
+
config_dict = toml.load(config_path)
|
|
357
|
+
Sports2D.process(config_dict)
|
|
358
|
+
```
|
|
359
|
+
- Or you can pass the non default values only:
|
|
360
|
+
```python
|
|
361
|
+
from Sports2D import Sports2D
|
|
362
|
+
config_dict = {
|
|
363
|
+
'base': {
|
|
364
|
+
'nb_persons_to_detect': 1,
|
|
365
|
+
'person_ordering_method': 'greatest_displacement'
|
|
366
|
+
},
|
|
367
|
+
'pose': {
|
|
368
|
+
'mode': 'lightweight',
|
|
369
|
+
'det_frequency': 50
|
|
370
|
+
}}
|
|
371
|
+
Sports2D.process(config_dict)
|
|
372
|
+
```
|
|
344
373
|
|
|
345
374
|
<br>
|
|
346
375
|
|
|
@@ -364,7 +393,7 @@ sports2d --video_input demo.mp4 other_video.mp4 --time_range 1.2 2.7 0 3.5
|
|
|
364
393
|
```cmd
|
|
365
394
|
sports2d --flip_left_right true # Default
|
|
366
395
|
```
|
|
367
|
-
- Correct segment angles according to the estimated camera
|
|
396
|
+
- Correct segment angles according to the estimated camera tilt angle.\
|
|
368
397
|
**N.B.:** *The camera tilt angle is automatically estimated. Set to false if it is actually the floor which is tilted rather than the camera.*
|
|
369
398
|
```cmd
|
|
370
399
|
sports2d --correct_segment_angles_with_floor_angle true # Default
|
|
@@ -434,6 +463,7 @@ sports2d --help
|
|
|
434
463
|
'show_realtime_results': ["R", "show results in real-time. true if not specified"],
|
|
435
464
|
'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
|
|
436
465
|
'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
|
|
466
|
+
'save_graphs': ["", "save position and angle plots of raw and processed results. false if not specified"],
|
|
437
467
|
'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'],
|
|
438
468
|
'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'],
|
|
439
469
|
'save_vid': ["V", "save processed video. true if not specified"],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[demo]
|
|
2
|
+
name = "demo"
|
|
3
|
+
size = [ 1768, 994]
|
|
4
|
+
matrix = [ [ 2520.0897058227038, 0.0, 884.0], [ 0.0, 2520.0897058227038, 497.0], [ 0.0, 0.0, 1.0]]
|
|
5
|
+
distortions = [ 0.0, 0.0, 0.0, 0.0]
|
|
6
|
+
rotation = [ 1.2082126924727719, 1.2098328575850605, -1.2082126924727719]
|
|
7
|
+
translation = [ -3.510103521992233, 1.7079310029359385, 10.0]
|
|
8
|
+
fisheye = false
|
|
9
|
+
|
|
10
|
+
[metadata]
|
|
11
|
+
adjusted = false
|
|
12
|
+
error = 0.0
|
|
@@ -97,13 +97,13 @@ 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
|
-
|
|
100
|
+
max_distance = 100 # in px or None # If a person is detected further than max_distance from its position on the previous frame, it will be considered as a new one
|
|
101
101
|
|
|
102
102
|
[px_to_meters_conversion]
|
|
103
103
|
# Pixel to meters conversion
|
|
104
104
|
to_meters = true
|
|
105
105
|
make_c3d = true
|
|
106
|
-
save_calib =
|
|
106
|
+
save_calib = false
|
|
107
107
|
|
|
108
108
|
# If conversion from first_person_height
|
|
109
109
|
floor_angle = 'auto' # 'auto' or a value in degrees, eg 2.3. If 'auto', estimated from the line formed by the toes when they are on the ground (where speed = 0)
|
|
@@ -131,15 +131,16 @@ correct_segment_angles_with_floor_angle = true # If the camera is tilted, correc
|
|
|
131
131
|
|
|
132
132
|
[post-processing]
|
|
133
133
|
interpolate = true
|
|
134
|
-
interp_gap_smaller_than = 10 #
|
|
134
|
+
interp_gap_smaller_than = 10 # Do not interpolate larger gaps
|
|
135
135
|
fill_large_gaps_with = 'last_value' # 'last_value', 'nan', or 'zeros'
|
|
136
136
|
sections_to_keep = 'all' # 'all', 'largest', 'first', 'last'
|
|
137
|
-
#
|
|
138
|
-
|
|
137
|
+
# 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
|
|
138
|
+
min_chunk_size = 10 # Minimum number of valid frames in a row to keep a chunk of data for a person
|
|
139
|
+
reject_outliers = true # Hampel filter for outlier rejection before other filtering methods. Rejects outliers that are outside of a 95% confidence interal from the median in a sliding window of size 7.
|
|
139
140
|
|
|
140
141
|
filter = true
|
|
141
142
|
show_graphs = true # Show plots of raw and processed results
|
|
142
|
-
save_graphs =
|
|
143
|
+
save_graphs = true # Save position and angle plots of raw and processed results
|
|
143
144
|
filter_type = 'butterworth' # butterworth, kalman, gcv_spline, gaussian, loess, median, butterworth_on_speed
|
|
144
145
|
|
|
145
146
|
# Most intuitive and standard filter in biomechanics
|
|
@@ -152,6 +152,7 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
|
|
|
152
152
|
'keypoint_likelihood_threshold': 0.3,
|
|
153
153
|
'average_likelihood_threshold': 0.5,
|
|
154
154
|
'keypoint_number_threshold': 0.3,
|
|
155
|
+
'max_distance': 100,
|
|
155
156
|
'CUSTOM': { 'name': 'Hip',
|
|
156
157
|
'id': 19,
|
|
157
158
|
'children': [{'name': 'RHip',
|
|
@@ -196,7 +197,7 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
|
|
|
196
197
|
'calib_file': '',
|
|
197
198
|
'floor_angle': 'auto',
|
|
198
199
|
'xy_origin': ['auto'],
|
|
199
|
-
'save_calib':
|
|
200
|
+
'save_calib': False
|
|
200
201
|
},
|
|
201
202
|
'angles': {'display_angle_values_on': ['body', 'list'],
|
|
202
203
|
'fontSize': 0.3,
|
|
@@ -233,10 +234,11 @@ DEFAULT_CONFIG = {'base': {'video_input': ['demo.mp4'],
|
|
|
233
234
|
'interp_gap_smaller_than': 10,
|
|
234
235
|
'fill_large_gaps_with': 'last_value',
|
|
235
236
|
'sections_to_keep':'all',
|
|
237
|
+
'min_chunk_size': 10,
|
|
236
238
|
'reject_outliers': True,
|
|
237
239
|
'filter': True,
|
|
238
240
|
'show_graphs': True,
|
|
239
|
-
'save_graphs':
|
|
241
|
+
'save_graphs': True,
|
|
240
242
|
'filter_type': 'butterworth',
|
|
241
243
|
'butterworth': {'order': 4, 'cut_off_frequency': 6.0},
|
|
242
244
|
'kalman': {'trust_ratio': 500.0, 'smooth':True},
|
|
@@ -280,7 +282,7 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
280
282
|
'show_realtime_results': ["R", "show results in real-time. true if not specified"],
|
|
281
283
|
'display_angle_values_on': ["a", '"body", "list", "body" "list", or "none". body list if not specified'],
|
|
282
284
|
'show_graphs': ["G", "show plots of raw and processed results. true if not specified"],
|
|
283
|
-
'save_graphs': ["", "save position and angle plots of raw and processed results.
|
|
285
|
+
'save_graphs': ["", "save position and angle plots of raw and processed results. true if not specified"],
|
|
284
286
|
'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'],
|
|
285
287
|
'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'],
|
|
286
288
|
'save_vid': ["V", "save processed video. true if not specified"],
|
|
@@ -315,6 +317,7 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
315
317
|
'keypoint_likelihood_threshold': ["", "detected keypoints are not retained if likelihood is below this threshold. 0.3 if not specified"],
|
|
316
318
|
'average_likelihood_threshold': ["", "detected persons are not retained if average keypoint likelihood is below this threshold. 0.5 if not specified"],
|
|
317
319
|
'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"],
|
|
320
|
+
'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."],
|
|
318
321
|
'fastest_frames_to_remove_percent': ["", "Frames with high speed are considered as outliers. Defaults to 0.1"],
|
|
319
322
|
'close_to_zero_speed_px': ["", "Sum for all keypoints: about 50 px/frame or 0.2 m/frame. Defaults to 50"],
|
|
320
323
|
'large_hip_knee_angles': ["", "Hip and knee angles below this value are considered as imprecise. Defaults to 45"],
|
|
@@ -326,6 +329,7 @@ CONFIG_HELP = {'config': ["C", "path to a toml configuration file"],
|
|
|
326
329
|
'interp_gap_smaller_than': ["", "interpolate sequences of missing data if they are less than N frames long. 10 if not specified"],
|
|
327
330
|
'fill_large_gaps_with': ["", "last_value, nan, or zeros. last_value if not specified"],
|
|
328
331
|
'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"],
|
|
332
|
+
'min_chunk_size': ["", "Minimum number of valid frames in a row to keep a chunk of data for a person. 10 if not specified"],
|
|
329
333
|
'reject_outliers': ["", "reject outliers with Hampel filter before other filtering methods. true if not specified"],
|
|
330
334
|
'filter': ["", "filter results. true if not specified"],
|
|
331
335
|
'filter_type': ["", "butterworth, kalman, gcv_spline, gaussian, median, or loess. butterworth if not specified"],
|
|
@@ -473,6 +477,14 @@ def set_nested_value(config, flat_key, value):
|
|
|
473
477
|
d[keys[-1]] = value
|
|
474
478
|
|
|
475
479
|
|
|
480
|
+
def merge_dicts(original, overrides):
|
|
481
|
+
for key, value in overrides.items():
|
|
482
|
+
if isinstance(value, dict) and isinstance(original.get(key), dict):
|
|
483
|
+
merge_dicts(original[key], value)
|
|
484
|
+
else:
|
|
485
|
+
original[key] = value
|
|
486
|
+
|
|
487
|
+
|
|
476
488
|
def str2bool(v):
|
|
477
489
|
'''
|
|
478
490
|
Convert a string to a boolean value.
|
|
@@ -500,7 +512,8 @@ def process(config='Config_demo.toml'):
|
|
|
500
512
|
from Sports2D.process import process_fun
|
|
501
513
|
|
|
502
514
|
if type(config) == dict:
|
|
503
|
-
config_dict =
|
|
515
|
+
config_dict = DEFAULT_CONFIG.copy()
|
|
516
|
+
merge_dicts(config_dict, config)
|
|
504
517
|
else:
|
|
505
518
|
config_dict = read_config_file(config)
|
|
506
519
|
video_dir, video_files, frame_rates, time_ranges, result_dir = base_params(config_dict)
|
|
@@ -45,7 +45,7 @@ def test_workflow():
|
|
|
45
45
|
## From Python ##
|
|
46
46
|
#############################
|
|
47
47
|
|
|
48
|
-
# Default
|
|
48
|
+
# Default from the demo config file
|
|
49
49
|
config_path = Path(__file__).resolve().parent.parent / 'Demo' / 'Config_demo.toml'
|
|
50
50
|
config_dict = toml.load(config_path)
|
|
51
51
|
video_dir = Path(__file__).resolve().parent.parent / 'Demo'
|
|
@@ -53,6 +53,28 @@ def test_workflow():
|
|
|
53
53
|
config_dict.get("base").update({"person_ordering_method": "highest_likelihood"})
|
|
54
54
|
config_dict.get("base").update({"show_realtime_results":False})
|
|
55
55
|
config_dict.get("post-processing").update({"show_graphs":False})
|
|
56
|
+
config_dict.get("post-processing").update({"save_graphs":False})
|
|
57
|
+
|
|
58
|
+
Sports2D.process(config_dict)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Only passing the updated values
|
|
62
|
+
video_dir = Path(__file__).resolve().parent.parent / 'Demo'
|
|
63
|
+
config_dict = {
|
|
64
|
+
'base': {
|
|
65
|
+
'nb_persons_to_detect': 1,
|
|
66
|
+
'person_ordering_method': 'greatest_displacement',
|
|
67
|
+
"show_realtime_results":False
|
|
68
|
+
},
|
|
69
|
+
'pose': {
|
|
70
|
+
'mode': 'lightweight',
|
|
71
|
+
'det_frequency': 50
|
|
72
|
+
},
|
|
73
|
+
'post-processing': {
|
|
74
|
+
'show_graphs':False,
|
|
75
|
+
'save_graphs':False
|
|
76
|
+
}
|
|
77
|
+
}
|
|
56
78
|
|
|
57
79
|
Sports2D.process(config_dict)
|
|
58
80
|
|
|
@@ -62,28 +84,28 @@ def test_workflow():
|
|
|
62
84
|
#############################
|
|
63
85
|
|
|
64
86
|
# Default
|
|
65
|
-
demo_cmd = ["sports2d", "--person_ordering_method", "highest_likelihood", "--show_realtime_results", "False", "--show_graphs", "False"]
|
|
87
|
+
demo_cmd = ["sports2d", "--person_ordering_method", "highest_likelihood", "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False"]
|
|
66
88
|
subprocess.run(demo_cmd, check=True, capture_output=True, text=True, encoding='utf-8', errors='replace')
|
|
67
89
|
|
|
68
90
|
# With loading a trc file, visible_side 'front', first_person_height '1.76", floor_angle 0, xy_origin [0, 928]
|
|
69
|
-
demo_cmd2 = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False",
|
|
91
|
+
demo_cmd2 = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False",
|
|
70
92
|
"--load_trc_px", os.path.join(root_dir, "demo_Sports2D", "demo_Sports2D_px_person01.trc"),
|
|
71
93
|
"--visible_side", "front", "--first_person_height", "1.76", "--time_range", "1.2", "2.7",
|
|
72
94
|
"--floor_angle", "0", "--xy_origin", "0", "928"]
|
|
73
95
|
subprocess.run(demo_cmd2, check=True, capture_output=True, text=True, encoding='utf-8', errors='replace')
|
|
74
96
|
|
|
75
97
|
# With no pixels to meters conversion, one person to select, lightweight mode, detection frequency, slowmo factor, gaussian filter, RTMO body pose model
|
|
76
|
-
demo_cmd3 = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False",
|
|
77
|
-
|
|
98
|
+
demo_cmd3 = ["sports2d", "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False",
|
|
99
|
+
# "--calib_file", "calib_demo.toml",
|
|
78
100
|
"--nb_persons_to_detect", "1", "--person_ordering_method", "greatest_displacement",
|
|
79
101
|
"--mode", "lightweight", "--det_frequency", "50",
|
|
80
102
|
"--slowmo_factor", "4",
|
|
81
|
-
"--filter_type", "gaussian",
|
|
103
|
+
"--filter_type", "gaussian", "--use_augmentation", "False",
|
|
82
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]}"""]
|
|
83
105
|
subprocess.run(demo_cmd3, check=True, capture_output=True, text=True, encoding='utf-8', errors='replace')
|
|
84
106
|
|
|
85
107
|
# With a time range, inverse kinematics, marker augmentation
|
|
86
|
-
demo_cmd4 = ["sports2d", "--person_ordering_method", "greatest_displacement", "--show_realtime_results", "False", "--show_graphs", "False",
|
|
108
|
+
demo_cmd4 = ["sports2d", "--person_ordering_method", "greatest_displacement", "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False",
|
|
87
109
|
"--time_range", "1.2", "2.7",
|
|
88
110
|
"--do_ik", "True", "--use_augmentation", "True",
|
|
89
111
|
"--nb_persons_to_detect", "all", "--first_person_height", "1.65",
|
|
@@ -97,7 +119,7 @@ def test_workflow():
|
|
|
97
119
|
config_dict.get("base").update({"video_dir": str(video_dir)})
|
|
98
120
|
config_dict.get("base").update({"person_ordering_method": "highest_likelihood"})
|
|
99
121
|
with open(config_path, 'w') as f: toml.dump(config_dict, f)
|
|
100
|
-
demo_cmd5 = ["sports2d", "--config", str(config_path), "--show_realtime_results", "False", "--show_graphs", "False"]
|
|
122
|
+
demo_cmd5 = ["sports2d", "--config", str(config_path), "--show_realtime_results", "False", "--show_graphs", "False", "--save_graphs", "False",]
|
|
101
123
|
subprocess.run(demo_cmd5, check=True, capture_output=True, text=True, encoding='utf-8', errors='replace')
|
|
102
124
|
|
|
103
125
|
|