From c90067b5541ce82010b81a83e1bb097cb3eb51ba Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 9 Dec 2024 07:19:53 -0700 Subject: [PATCH] Keep track of objects max review severity --- frigate/events/maintainer.py | 1 + frigate/object_processing.py | 25 +------------------------ frigate/track/tracked_object.py | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py index 3a4209ec3..e2b9245d6 100644 --- a/frigate/events/maintainer.py +++ b/frigate/events/maintainer.py @@ -210,6 +210,7 @@ class EventProcessor(threading.Thread): "top_score": event_data["top_score"], "attributes": attributes, "type": "object", + "max_severity": event_data.get("max_severity"), }, } diff --git a/frigate/object_processing.py b/frigate/object_processing.py index ef23c3de3..b5196e686 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -702,30 +702,7 @@ class TrackedObjectProcessor(threading.Thread): return False # If the object is not considered an alert or detection - review_config = self.config.cameras[camera].review - if not ( - ( - obj.obj_data["label"] in review_config.alerts.labels - and ( - not review_config.alerts.required_zones - or set(obj.entered_zones) & set(review_config.alerts.required_zones) - ) - ) - or ( - ( - not review_config.detections.labels - or obj.obj_data["label"] in review_config.detections.labels - ) - and ( - not review_config.detections.required_zones - or set(obj.entered_zones) - & set(review_config.detections.required_zones) - ) - ) - ): - logger.debug( - f"Not creating clip for {obj.obj_data['id']} because it did not qualify as an alert or detection" - ) + if obj.max_severity is None: return False return True diff --git a/frigate/track/tracked_object.py b/frigate/track/tracked_object.py index 65e7a2ed5..af2d0f5a5 100644 --- a/frigate/track/tracked_object.py +++ b/frigate/track/tracked_object.py @@ -13,6 +13,7 @@ from frigate.config import ( CameraConfig, ModelConfig, ) +from frigate.review.maintainer import SeverityEnum from frigate.util.image import ( area, calculate_region, @@ -59,6 +60,27 @@ class TrackedObject: self.pending_loitering = False self.previous = self.to_dict() + @property + def max_severity(self) -> Optional[str]: + review_config = self.camera_config.review + + if self.obj_data["label"] in review_config.alerts.labels and ( + not review_config.alerts.required_zones + or set(self.entered_zones) & set(review_config.alerts.required_zones) + ): + return SeverityEnum.alert + + if ( + not review_config.detections.labels + or self.obj_data["label"] in review_config.detections.labels + ) and ( + not review_config.detections.required_zones + or set(self.entered_zones) & set(review_config.detections.required_zones) + ): + return SeverityEnum.detection + + return None + def _is_false_positive(self): # once a true positive, always a true positive if not self.false_positive: @@ -232,6 +254,7 @@ class TrackedObject: "attributes": self.attributes, "current_attributes": self.obj_data["attributes"], "pending_loitering": self.pending_loitering, + "max_severity": self.max_severity, } if include_thumbnail: