reduce the motion detection timeout to 5 seconds

This commit is contained in:
blakeblackshear 2019-02-10 20:09:25 -06:00
parent a3c5dd91a1
commit 6bdacffa2e

View File

@ -387,7 +387,7 @@ def process_frames(shared_arr, shared_output_arr, shared_frame_time, shared_moti
# copy the detected objects to the output array, filling the array when needed # copy the detected objects to the output array, filling the array when needed
shared_output_arr[:] = objects + [0.0] * (60-len(objects)) shared_output_arr[:] = objects + [0.0] * (60-len(objects))
# do the actual object detection # do the actual motion detection
def detect_motion(shared_arr, shared_frame_time, ready_for_frame, shared_motion, frame_shape, region_size, region_x_offset, region_y_offset, min_motion_area): def detect_motion(shared_arr, shared_frame_time, ready_for_frame, shared_motion, frame_shape, region_size, region_x_offset, region_y_offset, min_motion_area):
# shape shared input array into frame for processing # shape shared input array into frame for processing
arr = tonumpyarray(shared_arr).reshape(frame_shape) arr = tonumpyarray(shared_arr).reshape(frame_shape)
@ -398,8 +398,8 @@ def detect_motion(shared_arr, shared_frame_time, ready_for_frame, shared_motion,
frame_time = 0.0 frame_time = 0.0
while True: while True:
now = datetime.datetime.now().timestamp() now = datetime.datetime.now().timestamp()
# if it has been 30 seconds since the last motion, clear the flag # if it has been long enough since the last motion, clear the flag
if last_motion > 0 and (now - last_motion) > 30: if last_motion > 0 and (now - last_motion) > 5:
last_motion = -1 last_motion = -1
shared_motion.value = 0 shared_motion.value = 0
# if there isnt a frame ready for processing # if there isnt a frame ready for processing