Keep track of objects max review severity

This commit is contained in:
Nicolas Mowen 2024-12-09 07:19:53 -07:00
parent d0cc8cb64b
commit c90067b554
3 changed files with 25 additions and 24 deletions

View File

@ -210,6 +210,7 @@ class EventProcessor(threading.Thread):
"top_score": event_data["top_score"], "top_score": event_data["top_score"],
"attributes": attributes, "attributes": attributes,
"type": "object", "type": "object",
"max_severity": event_data.get("max_severity"),
}, },
} }

View File

@ -702,30 +702,7 @@ class TrackedObjectProcessor(threading.Thread):
return False return False
# If the object is not considered an alert or detection # If the object is not considered an alert or detection
review_config = self.config.cameras[camera].review if obj.max_severity is None:
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"
)
return False return False
return True return True

View File

@ -13,6 +13,7 @@ from frigate.config import (
CameraConfig, CameraConfig,
ModelConfig, ModelConfig,
) )
from frigate.review.maintainer import SeverityEnum
from frigate.util.image import ( from frigate.util.image import (
area, area,
calculate_region, calculate_region,
@ -59,6 +60,27 @@ class TrackedObject:
self.pending_loitering = False self.pending_loitering = False
self.previous = self.to_dict() 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): def _is_false_positive(self):
# once a true positive, always a true positive # once a true positive, always a true positive
if not self.false_positive: if not self.false_positive:
@ -232,6 +254,7 @@ class TrackedObject:
"attributes": self.attributes, "attributes": self.attributes,
"current_attributes": self.obj_data["attributes"], "current_attributes": self.obj_data["attributes"],
"pending_loitering": self.pending_loitering, "pending_loitering": self.pending_loitering,
"max_severity": self.max_severity,
} }
if include_thumbnail: if include_thumbnail: