Skip to content

Commit 685f3e0

Browse files
committed
Various small fixes
1 parent ff64d93 commit 685f3e0

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ Will be much faster, with no impact on accuracy. However, the installation takes
237237
<br>
238238

239239
#### Customize your output:
240-
- Choose whether you want video, images, trc pose file, and angle mot file:
240+
- Choose whether you want video, images, trc pose file, angle mot file, and real-time display:
241241
```cmd
242-
sports2d --save_vid false --save_img true --save_trc false --save_mot true
242+
sports2d --save_vid false --save_img true --save_pose false --save_angles true --show_realtime_results false
243243
```
244244
- Choose which angles you need:
245245
```cmd
@@ -415,7 +415,7 @@ If you want to contribute to Sports2D, please follow [this guide](https://docs.g
415415
- [x] Run again without pose estimation with the option `--load_trc` for px .trc file.
416416
- [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)
417417
- [ ] 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.
418-
- [ ] Run with the options `--load_trc` and `--compare` 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.
418+
- [ ] 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.
419419
- [ ] **Colab version**: more user-friendly, usable on a smartphone.
420420
- [ ] **GUI applications** for Windows, Mac, and Linux, as well as for Android and iOS.
421421

Sports2D/process.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,10 +1559,10 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
15591559
if save_img:
15601560
cv2.imwrite(str((img_output_dir / f'{output_dir_name}_{frame_count:06d}.png')), img)
15611561

1562-
if save_pose:
1563-
all_frames_X.append(np.array(valid_X))
1564-
all_frames_Y.append(np.array(valid_Y))
1565-
all_frames_scores.append(np.array(valid_scores))
1562+
all_frames_X.append(np.array(valid_X))
1563+
all_frames_Y.append(np.array(valid_Y))
1564+
all_frames_scores.append(np.array(valid_scores))
1565+
15661566
if save_angles and calculate_angles:
15671567
all_frames_angles.append(np.array(valid_angles))
15681568
if video_file=='webcam' and save_vid: # To adjust framerate of output video
@@ -1587,26 +1587,25 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
15871587

15881588

15891589
# Post-processing: Interpolate, filter, and save pose and angles
1590+
all_frames_X_homog = make_homogeneous(all_frames_X)
1591+
all_frames_X_homog = all_frames_X_homog[...,keypoints_ids]
1592+
all_frames_Y_homog = make_homogeneous(all_frames_Y)
1593+
all_frames_Y_homog = all_frames_Y_homog[...,keypoints_ids]
1594+
all_frames_Z_homog = pd.DataFrame(np.zeros_like(all_frames_X_homog)[:,0,:], columns=keypoints_names)
1595+
all_frames_scores = make_homogeneous(all_frames_scores)
1596+
15901597
frame_range = [0,frame_count] if video_file == 'webcam' else frame_range
15911598
all_frames_time = pd.Series(np.linspace(frame_range[0]/fps/slowmo_factor, frame_range[1]/fps/slowmo_factor, frame_count+1), name='time')
1592-
1599+
if not multiperson:
1600+
detected_persons = [get_personID_with_highest_scores(all_frames_scores)]
1601+
else:
1602+
detected_persons = range(all_frames_X_homog.shape[1])
1603+
1604+
# Post-processing pose
15931605
if save_pose:
15941606
logging.info('\nPost-processing pose:')
1595-
# Select only the keypoints that are in the model from skeletons.py, invert Y axis, divide pixel values by 1000
1596-
all_frames_X_homog = make_homogeneous(all_frames_X)
1597-
all_frames_X_homog = all_frames_X_homog[...,keypoints_ids]
1598-
all_frames_Y_homog = make_homogeneous(all_frames_Y)
1599-
all_frames_Y_homog = all_frames_Y_homog[...,keypoints_ids]
1600-
all_frames_scores = make_homogeneous(all_frames_scores)
1601-
1602-
all_frames_Z_homog = pd.DataFrame(np.zeros_like(all_frames_X_homog)[:,0,:], columns=keypoints_names)
1603-
1604-
# Process pose for each person
1605-
if not multiperson:
1606-
detected_persons = [get_personID_with_highest_scores(all_frames_scores)]
1607-
else:
1608-
detected_persons = range(all_frames_X_homog.shape[1])
16091607

1608+
# Process pose for each person
16101609
trc_data = []
16111610
trc_data_unfiltered = []
16121611
for i in detected_persons:
@@ -1706,7 +1705,6 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
17061705
cx, cy = xy_origin_estim
17071706
else:
17081707
cx, cy = xy_origin
1709-
print(xy_origin_estim, xy_origin)
17101708
logging.info(f'Using height of person #{calib_on_person_id} ({person_height_m}m) to convert coordinates in meters. '
17111709
f'Floor angle: {np.degrees(-floor_angle_estim) if not floor_angle=="auto" else f"auto (estimation: {round(np.degrees(-floor_angle_estim),2)}°)"}, '
17121710
f'xy_origin: {xy_origin if not xy_origin=="auto" else f"auto (estimation: {[round(c,2) for c in xy_origin_estim]})"}.')
@@ -1775,7 +1773,7 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
17751773

17761774

17771775

1778-
# Angles post-processing
1776+
# Post-processing angles
17791777
if save_angles and calculate_angles:
17801778
logging.info('\nPost-processing angles:')
17811779
all_frames_angles = make_homogeneous(all_frames_angles)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = sports2d
3-
version = 0.5.0
3+
version = 0.5.1
44
author = David Pagnon
55
author_email = contact@david-pagnon.com
66
description = Detect pose and compute 2D joint angles from a video.

0 commit comments

Comments
 (0)