Skip to content

Commit

Permalink
Make frame speed counting handle zero cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalior committed Aug 27, 2018
1 parent bb8d33c commit 5ce4de3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion live_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ def speed_no_stop_prediction(track, stop_threshold):
frame_speed = np.linalg.norm(frame_speed, axis=1)

# Find first index where there is movement. Count from there.
first_movement_index = np.where(frame_speed > stop_threshold)[0][0]
movement_indicies = np.where(frame_speed > stop_threshold)
if len(movement_indicies) > 0 and len(movement_indicies[0]) > 0:
first_movement_index = movement_indicies[0][0]
else:
first_movement_index = 0

n_movement_frames = np.count_nonzero(frame_speed[first_movement_index:] > stop_threshold)

# Calculate how many of the last moving frames have to have had movement
Expand Down

0 comments on commit 5ce4de3

Please sign in to comment.