Add review config for cutoff times

This commit is contained in:
Nicolas Mowen 2025-08-31 13:47:57 -06:00
parent e135d4cf9f
commit 174a2b4903
3 changed files with 19 additions and 6 deletions

View File

@ -390,6 +390,8 @@ review:
labels: labels:
- car - car
- person - 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) # 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 # 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 # or the config will be considered invalid. In that case the required_zones
@ -404,6 +406,8 @@ review:
labels: labels:
- car - car
- person - 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) # 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 # 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 # or the config will be considered invalid. In that case the required_zones

View File

@ -26,6 +26,10 @@ class AlertsConfig(FrigateBaseModel):
enabled_in_config: Optional[bool] = Field( enabled_in_config: Optional[bool] = Field(
default=None, title="Keep track of original state of alerts." 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") @field_validator("required_zones", mode="before")
@classmethod @classmethod
@ -48,6 +52,10 @@ class DetectionsConfig(FrigateBaseModel):
default_factory=list, default_factory=list,
title="List of required zones to be entered in order to save the event as a detection.", 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( enabled_in_config: Optional[bool] = Field(
default=None, title="Keep track of original state of detections." default=None, title="Keep track of original state of detections."

View File

@ -40,9 +40,6 @@ logger = logging.getLogger(__name__)
THUMB_HEIGHT = 180 THUMB_HEIGHT = 180
THUMB_WIDTH = 320 THUMB_WIDTH = 320
THRESHOLD_ALERT_ACTIVITY = 40
THRESHOLD_DETECTION_ACTIVITY = 30
class PendingReviewSegment: class PendingReviewSegment:
def __init__( def __init__(
@ -472,11 +469,14 @@ class ReviewSegmentMaintainer(threading.Thread):
return return
if segment.severity == SeverityEnum.alert and frame_time > ( 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 = ( needs_new_detection = (
segment.last_detection_time > segment.last_alert_time 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 > frame_time
) )
last_detection_time = segment.last_detection_time last_detection_time = segment.last_detection_time
@ -510,7 +510,8 @@ class ReviewSegmentMaintainer(threading.Thread):
activity.camera_config.name activity.camera_config.name
].last_detection_time = last_detection_time ].last_detection_time = last_detection_time
elif segment.severity == SeverityEnum.detection and frame_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) self._publish_segment_end(segment, prev_data)