Skip to content

Commit

Permalink
more informative message error in best_coords_for_measurementswhen no…
Browse files Browse the repository at this point in the history
…t moving or badly detected
  • Loading branch information
davidpagnon committed Dec 21, 2024
1 parent 9d063bf commit 49a7a34
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sports2D/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,8 @@ def best_coords_for_measurements(Q_coords, keypoints_names, fastest_frames_to_re
# Using 80% slowest frames
sum_speeds = pd.Series(np.nansum([np.linalg.norm(Q_coords.iloc[:,kpt:kpt+3].diff(), axis=1) for kpt in range(n_markers)], axis=0))
sum_speeds = sum_speeds[sum_speeds>close_to_zero_speed] # Removing when speeds close to zero (out of frame)
if len(sum_speeds)==0:
raise ValueError('All frames have speed close to zero. Make sure the person is moving and correctly detected, or change close_to_zero_speed to a lower value.')
min_speed_indices = sum_speeds.abs().nsmallest(int(len(sum_speeds) * (1-fastest_frames_to_remove_percent))).index
Q_coords_low_speeds = Q_coords.iloc[min_speed_indices].reset_index(drop=True)

Expand Down

0 comments on commit 49a7a34

Please sign in to comment.