From 19323ac957c8677caa004ec3e2c039a8c5e2338c Mon Sep 17 00:00:00 2001 From: blakeblackshear Date: Wed, 20 Feb 2019 17:43:27 -0600 Subject: [PATCH] only clear the flag and notify if it was set --- detect_objects.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/detect_objects.py b/detect_objects.py index 75c6bd235..90a89663b 100644 --- a/detect_objects.py +++ b/detect_objects.py @@ -534,9 +534,10 @@ def detect_motion(shared_arr, shared_frame_time, frame_lock, frame_ready, motion # when no motion, just keep averaging the frames together cv2.accumulateWeighted(gray, avg_frame, 0.01) motion_frames = 0 - motion_detected.clear() - with motion_changed: - motion_changed.notify_all() + if motion_detected.is_set(): + motion_detected.clear() + with motion_changed: + motion_changed.notify_all() if debug and motion_frames >= 3: cv2.imwrite("/lab/debug/motion-{}-{}-{}.jpg".format(region_x_offset, region_y_offset, datetime.datetime.now().timestamp()), cropped_frame)