Skip to content

Commit c2e17c5

Browse files
authored
Merge pull request #12 from hunminkim98/main
Support webcam and advanced visualization.
2 parents a84f2a6 + 5315c24 commit c2e17c5

18 files changed

+4378
-2704
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ jobs:
5555
- name: Test with pytest
5656
run: |
5757
cd Sports2D/Utilities
58-
pytest -v test_with_blazepose.py
58+
pytest -v test_with_RTMPose.py

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,25 @@ If you need research-grade markerless joint kinematics, consider using several c
8888
cd sports2d
8989
pip install .
9090
```
91+
- **Optional**\
92+
*For faster inference, you can run on the GPU. Install pyTorch with CUDA and cuDNN support, and ONNX Runtime with GPU support (not available on MacOS).*\
93+
Be aware that GPU support takes an additional 6 GB on disk.
94+
95+
Go to the [ONNXruntime requirement page](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements), check the latest CUDA and cuDNN requirements. Then go to the [pyTorch website]( https://pytorch.org/get-started/locally) and install the latest version that satisfies these requirements (beware that torch 2.4 ships with cuDNN 9, while torch 2.3 installs cuDNN 8). For example:
96+
``` cmd
97+
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
98+
```
99+
100+
***Note:*** issues reported with the default command. However, this has been tested and works:
101+
`pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu118`
102+
91103
92104
105+
Then install ONNX Runtime with GPU support:
106+
```
107+
pip install onnxruntime-gpu
108+
```
109+
93110
### Demonstration: Detect pose and compute 2D angles
94111
95112
If you did the conda install, type `conda activate Sports2D` in the Anaconda prompt. Otherwise, skip to the next line.\

Sports2D/Demo/Config_demo.toml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,12 @@
1414

1515
[project]
1616
video_dir = '' # BETWEEN SINGLE QUOTES! # If empty, result dir is current dir
17-
video_files = 'demo.mp4' # video file (e.g.: 'demo.mp4') or list of video files (e.g.: ['demo.mp4', 'other.mov'])
17+
video_input = 'webcam' # 'webcam' or 'your_video_name.extenstion'
1818
result_dir = '' # BETWEEN SINGLE QUOTES! # If empty, project dir is current dir
1919

20-
2120
[pose]
22-
pose_algo = 'BLAZEPOSE' # 'OPENPOSE' or 'BLAZEPOSE'
23-
# OpenPose is more accurate and supports multi-person detection, but needs to be installed separately
24-
# Coming soon: 'deeplabcut', 'alphapose'
25-
26-
[pose.BLAZEPOSE]
27-
# 0,1,2. 2 is slightly slower but more accurate
28-
model_complexity = 2
29-
30-
[pose.OPENPOSE]
31-
# Install OpenPose from https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/doc/installation/0_index.md
32-
# BODY_25 is standard, BODY_25B is more accurate but requires downloading the model from
33-
# https://github.com/CMU-Perceptual-Computing-Lab/openpose_train/blob/master/experimental_models/README.md
34-
openpose_model = 'BODY_25'
35-
36-
# Installation path of openpose (between single quotes)
37-
openpose_path = 'D:\softs\openpose-1.6.0-binaries-win64-gpu-flir-3d_recommended\openpose'
38-
21+
display_detection = true
22+
time_range = []
3923

4024
[compute_angles]
4125
# Select joint angles among
@@ -47,34 +31,38 @@ joint_angles = ['Right ankle', 'Left ankle', 'Right knee', 'Left knee', 'Right h
4731
segment_angles = ['Right foot', 'Left foot', 'Right shank', 'Left shank', 'Right thigh', 'Left thigh', 'Trunk', 'Right arm', 'Left arm', 'Right forearm', 'Left forearm']
4832

4933

50-
51-
5234
# ADVANCED CONFIGURATION
5335

54-
[pose_advanced] # only for OPENPOSE
55-
overwrite_pose = false # If false, don't run openpose again if json pose files are found.
36+
[pose_advanced]
37+
webcam_id = 0 # your webcam id (0 is default)
38+
input_size = [1980, 1080] # 'auto' or [W, H]. Full image resolution: 'auto'. Custom resolution: list of two integers. Lower resolution will be faster but less precise.
39+
overwrite_pose = true # If false, don't run openpose again if json pose files are found.
40+
det_frequency = 1 # detect person every det_frequency (1 = 1 frame)
41+
mode = "lightweight" # # lightweight, balanced, performance
42+
keypoints_threshold = 0.5 #If only part of a person is on screen, increase this number to ensure that only correctly detected keypoints are used.
43+
min_detection_time = 1 # If lower than this, person will be ignored(sec)
44+
#For webcams, it is possible to detect the wrong person if the person is only partially detected (usually less than a second).
5645
save_vid = true
5746
save_img = true
5847
interp_gap_smaller_than = 5 # do not interpolate bigger gaps
5948
filter = true
60-
show_plots = false
49+
show_plots = true
6150
filter_type = 'butterworth' # butterworth, gaussian, LOESS, median
6251
[pose_advanced.butterworth]
6352
order = 4
64-
cut_off_frequency = 6 # Hz
53+
cut_off_frequency = 3 # Hz
6554
[pose_advanced.gaussian]
6655
sigma_kernel = 1 #px
6756
[pose_advanced.loess]
6857
nb_values_used = 5 # = fraction of data used * nb frames
6958
[pose_advanced.median]
7059
kernel_size = 3
7160

72-
73-
[compute_angles_advanced] # for OPENPOSE and BLAZEPOSE
61+
[compute_angles_advanced]
7462
show_angles_on_img = true
7563
show_angles_on_vid = true
76-
filter = false
77-
show_plots = false
64+
filter = true
65+
show_plots = true
7866
flip_left_right = true # Same angles whether the participant faces left/right. Set it to false if you want timeseries to be continuous even when the participent switches their stance.
7967
filter_type = 'butterworth' # butterworth, gaussian, LOESS, median
8068
[compute_angles_advanced.butterworth]

Sports2D/Demo/demo2.mp4

1.33 MB
Binary file not shown.

Sports2D/Demo/demo3.mp4

72.7 KB
Binary file not shown.

Sports2D/Demo/demo4.mp4

1020 KB
Binary file not shown.

Sports2D/Demo/demo5.mp4

1.31 MB
Binary file not shown.

0 commit comments

Comments
 (0)