mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	require a minimum of 3 consecutive motion frames to try and reduce false positives from rain
This commit is contained in:
		
							parent
							
								
									225f434718
								
							
						
					
					
						commit
						861539e8b5
					
				@ -396,6 +396,7 @@ def detect_motion(shared_arr, shared_frame_time, ready_for_frame, shared_motion,
 | 
				
			|||||||
    avg_frame = None
 | 
					    avg_frame = None
 | 
				
			||||||
    last_motion = -1
 | 
					    last_motion = -1
 | 
				
			||||||
    frame_time = 0.0
 | 
					    frame_time = 0.0
 | 
				
			||||||
 | 
					    motion_frames = 0
 | 
				
			||||||
    while True:
 | 
					    while True:
 | 
				
			||||||
        now = datetime.datetime.now().timestamp()
 | 
					        now = datetime.datetime.now().timestamp()
 | 
				
			||||||
        # if it has been long enough since the last motion, clear the flag
 | 
					        # if it has been long enough since the last motion, clear the flag
 | 
				
			||||||
@ -459,11 +460,16 @@ def detect_motion(shared_arr, shared_frame_time, ready_for_frame, shared_motion,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # loop over the contours
 | 
					        # loop over the contours
 | 
				
			||||||
        for c in cnts:
 | 
					        for c in cnts:
 | 
				
			||||||
            # if the contour is big enough report motion
 | 
					            # if the contour is big enough, count it as motion
 | 
				
			||||||
            if cv2.contourArea(c) > min_motion_area:
 | 
					            contour_area = cv2.contourArea(c)
 | 
				
			||||||
                last_motion = now
 | 
					            if contour_area > min_motion_area:
 | 
				
			||||||
 | 
					                motion_frames += 1
 | 
				
			||||||
 | 
					                # if there have been enough consecutive motion frames, report motion
 | 
				
			||||||
 | 
					                if motion_frames >= 3:
 | 
				
			||||||
                    shared_motion.value = 1
 | 
					                    shared_motion.value = 1
 | 
				
			||||||
 | 
					                    last_motion = now
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
 | 
					            motion_frames = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    mp.freeze_support()
 | 
					    mp.freeze_support()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user