From b6b8c470bee4854c9bd7d5536bd3cf872f8ca4de Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 20 Feb 2024 09:21:02 -0700 Subject: [PATCH] Only include true positives --- frigate/review/maintainer.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/frigate/review/maintainer.py b/frigate/review/maintainer.py index 14f067602..3e2dcc077 100644 --- a/frigate/review/maintainer.py +++ b/frigate/review/maintainer.py @@ -147,14 +147,7 @@ class ReviewSegmentMaintainer(threading.Thread): ) -> None: """Validate if existing review segment should continue.""" camera_config = self.config.cameras[segment.camera] - - # get objects that are not stationary and detected in this frame - active_objects = [ - o - for o in objects - if o["motionless_count"] < camera_config.detect.stationary.threshold - and o["frame_time"] == frame_time - ] + active_objects = get_active_objects(frame_time, camera_config, objects) if len(active_objects) > 0: segment.last_update = frame_time @@ -208,12 +201,7 @@ class ReviewSegmentMaintainer(threading.Thread): ) -> None: """Check if a new review segment should be created.""" camera_config = self.config.cameras[camera] - active_objects = [ - o - for o in objects - if o["motionless_count"] < camera_config.detect.stationary.threshold - and o["frame_time"] == frame_time - ] + active_objects = get_active_objects(frame_time, camera_config, objects) if len(active_objects) > 0: has_sig_object = False @@ -313,3 +301,16 @@ class ReviewSegmentMaintainer(threading.Thread): SeverityEnum.detection, audio=set(audio_detections), ) + + +def get_active_objects( + frame_time: float, camera_config: CameraConfig, all_objects: list[TrackedObject] +) -> list[TrackedObject]: + """get active objects for detection.""" + return [ + o + for o in all_objects + if o["motionless_count"] < camera_config.detect.stationary.threshold + and o["frame_time"] == frame_time + and not o["false_positive"] + ]