mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-04 20:47:42 +03:00
Make motion detection less sensitive by ignoring minor (<5%) changes.
This commit is contained in:
parent
7d0d5efac5
commit
3432907c89
@ -121,13 +121,13 @@ class ImprovedMotionDetector(MotionDetector):
|
|||||||
if self.save_images:
|
if self.save_images:
|
||||||
contrasted_saved = resized_frame.copy()
|
contrasted_saved = resized_frame.copy()
|
||||||
|
|
||||||
|
resized_frame = gaussian_filter(resized_frame, sigma=1, radius=self.blur_radius)
|
||||||
|
|
||||||
# mask frame
|
# mask frame
|
||||||
# this has to come after contrast improvement
|
# this has to come after contrast improvement and masking to avoid the mask bleeding into non-masked area.
|
||||||
# Setting masked pixels to zero, to match the average frame at startup
|
# Setting masked pixels to zero, to match the average frame at startup
|
||||||
resized_frame[self.mask] = [0]
|
resized_frame[self.mask] = [0]
|
||||||
|
|
||||||
resized_frame = gaussian_filter(resized_frame, sigma=1, radius=self.blur_radius)
|
|
||||||
|
|
||||||
if self.save_images:
|
if self.save_images:
|
||||||
blurred_saved = resized_frame.copy()
|
blurred_saved = resized_frame.copy()
|
||||||
|
|
||||||
@ -194,10 +194,11 @@ class ImprovedMotionDetector(MotionDetector):
|
|||||||
|
|
||||||
# once the motion is less than 5% and the number of contours is < 4, assume its calibrated
|
# 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:
|
if pct_motion < 0.05 and len(motion_boxes) <= 4:
|
||||||
|
motion_boxes = [] # ignore small movements
|
||||||
self.calibrating = False
|
self.calibrating = False
|
||||||
|
|
||||||
# if calibrating or the motion contours are > 80% of the image area (lightning, ir, ptz) recalibrate
|
# if calibrating or the motion contours are > 80% of the image area (lightning, ir, ptz) recalibrate
|
||||||
if self.calibrating or pct_motion > self.config.lightning_threshold:
|
if not self.calibrating and pct_motion > self.config.lightning_threshold:
|
||||||
self.calibrating = True
|
self.calibrating = True
|
||||||
|
|
||||||
if self.save_images:
|
if self.save_images:
|
||||||
|
|||||||
@ -51,6 +51,9 @@ class TestMotion(unittest.TestCase):
|
|||||||
default_motion_config,
|
default_motion_config,
|
||||||
[[190, 307]],
|
[[190, 307]],
|
||||||
),
|
),
|
||||||
|
TestMotionVideo(
|
||||||
|
"testdata/test_motion_video-3.mp4", default_mask, default_motion_config
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_motion_detector(self, test_clip):
|
def get_motion_detector(self, test_clip):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user