diff --git a/Sports2D/process.py b/Sports2D/process.py index cb4a29b..c8bbc62 100644 --- a/Sports2D/process.py +++ b/Sports2D/process.py @@ -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)