From 174a2b4903b2116d29e65186f0d7b925c2822894 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 31 Aug 2025 13:47:57 -0600 Subject: [PATCH] Add review config for cutoff times --- docs/docs/configuration/reference.md | 4 ++++ frigate/config/camera/review.py | 8 ++++++++ frigate/review/maintainer.py | 13 +++++++------ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/docs/configuration/reference.md b/docs/docs/configuration/reference.md index 9b2127b83..068f25d78 100644 --- a/docs/docs/configuration/reference.md +++ b/docs/docs/configuration/reference.md @@ -390,6 +390,8 @@ review: labels: - car - person + # Time to cutoff alerts after no alert-causing activity has occurred (default: shown below) + cutoff_time: 40 # Optional: required zones for an object to be marked as an alert (default: none) # NOTE: when settings required zones globally, this zone must exist on all cameras # or the config will be considered invalid. In that case the required_zones @@ -404,6 +406,8 @@ review: labels: - car - person + # Time to cutoff detections after no detection-causing activity has occurred (default: shown below) + cutoff_time: 30 # Optional: required zones for an object to be marked as a detection (default: none) # NOTE: when settings required zones globally, this zone must exist on all cameras # or the config will be considered invalid. In that case the required_zones diff --git a/frigate/config/camera/review.py b/frigate/config/camera/review.py index 51268339b..17f97efd1 100644 --- a/frigate/config/camera/review.py +++ b/frigate/config/camera/review.py @@ -26,6 +26,10 @@ class AlertsConfig(FrigateBaseModel): enabled_in_config: Optional[bool] = Field( default=None, title="Keep track of original state of alerts." ) + cutoff_time: int = Field( + default=40, + title="Time to cutoff alerts after no alert-causing activity has occurred.", + ) @field_validator("required_zones", mode="before") @classmethod @@ -48,6 +52,10 @@ class DetectionsConfig(FrigateBaseModel): default_factory=list, title="List of required zones to be entered in order to save the event as a detection.", ) + cutoff_time: int = Field( + default=30, + title="Time to cutoff detection after no detection-causing activity has occurred.", + ) enabled_in_config: Optional[bool] = Field( default=None, title="Keep track of original state of detections." diff --git a/frigate/review/maintainer.py b/frigate/review/maintainer.py index 6d7bc4e06..202b9b701 100644 --- a/frigate/review/maintainer.py +++ b/frigate/review/maintainer.py @@ -40,9 +40,6 @@ logger = logging.getLogger(__name__) THUMB_HEIGHT = 180 THUMB_WIDTH = 320 -THRESHOLD_ALERT_ACTIVITY = 40 -THRESHOLD_DETECTION_ACTIVITY = 30 - class PendingReviewSegment: def __init__( @@ -472,11 +469,14 @@ class ReviewSegmentMaintainer(threading.Thread): return if segment.severity == SeverityEnum.alert and frame_time > ( - segment.last_alert_time + THRESHOLD_ALERT_ACTIVITY + segment.last_alert_time + camera_config.review.alerts.cutoff_time ): needs_new_detection = ( segment.last_detection_time > segment.last_alert_time - and (segment.last_detection_time + THRESHOLD_DETECTION_ACTIVITY) + and ( + segment.last_detection_time + + camera_config.review.detections.cutoff_time + ) > frame_time ) last_detection_time = segment.last_detection_time @@ -510,7 +510,8 @@ class ReviewSegmentMaintainer(threading.Thread): activity.camera_config.name ].last_detection_time = last_detection_time elif segment.severity == SeverityEnum.detection and frame_time > ( - segment.last_detection_time + THRESHOLD_DETECTION_ACTIVITY + segment.last_detection_time + + camera_config.review.detections.cutoff_time ): self._publish_segment_end(segment, prev_data)