Skip to content

Commit

Permalink
Handle no stop prediction better
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalior committed Aug 27, 2018
1 parent 5ce4de3 commit 1cc3098
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions live_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main(args):
write_predictions(valid_predictions, img)
save_predictions(valid_predictions, args.video, tmp_video_file, args.out_directory)

logging.debug("Predict time: {:.3f}, Track time: {:.3f}".format(
logging.info("Predict time: {:.3f}, Track time: {:.3f}".format(
predict_people_time, track_people_time))
track_people_start = time()

Expand Down Expand Up @@ -163,8 +163,7 @@ def classifier_predict_no_stop(track, confidence_threshold):
return False

constant_moving = all(prediction['label'] == 'moving' and
prediction['confidence'] > confidence_threshold or
prediction['confidence'] < confidence_threshold
prediction['confidence'] > confidence_threshold
for prediction in list(track.predictions.values())[-20:])
return constant_moving

Expand All @@ -179,11 +178,7 @@ 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.
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
first_movement_index = next(i for i, b in enumerate((frame_speed > stop_threshold)) if b)

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

Expand Down Expand Up @@ -216,7 +211,7 @@ def speed_no_stop_prediction(track, stop_threshold):
help=('Output directory to where the processed video and identified '
'chunks are saved.'))

logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.INFO)

args = parser.parse_args()
main(args)

0 comments on commit 1cc3098

Please sign in to comment.