Adjust motion calibration to be more dynamic

This commit is contained in:
Nick Mowen 2023-10-20 15:11:04 -06:00
parent facd557f8c
commit 859043c58b

View File

@ -1,11 +1,14 @@
import cv2
import imutils
import logging
import numpy as np
from scipy.ndimage import gaussian_filter
from frigate.config import MotionConfig
from frigate.motion import MotionDetector
logger = logging.getLogger(__name__)
class ImprovedMotionDetector(MotionDetector):
def __init__(
@ -138,8 +141,8 @@ class ImprovedMotionDetector(MotionDetector):
self.motion_frame_size[0] * self.motion_frame_size[1]
)
# once the motion drops to less than 1% for the first time, assume its calibrated
if pct_motion < 0.01:
# once the motion is less than 5% and the number of contours is < 4, assume its calibrated
if pct_motion < 0.05 and len(motion_boxes) <= 4:
self.calibrating = False
# if calibrating or the motion contours are > 80% of the image area (lightning, ir, ptz) recalibrate