NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
send MQTT snapshot when object enters required zone (#22690)
Josh Hawkinsf002513d362c
diff --git a/frigate/camera/state.py b/frigate/camera/state.pyindex a203264a66..8d0b586022 100644--- a/frigate/camera/state.py+++ b/frigate/camera/state.py@@ -428,6 +428,18 @@ class CameraState:c(self.name, updated_obj, frame_name)updated_obj.last_published = frame_time+ # send MQTT snapshot when object first enters a required zone,+ # since the initial snapshot at creation time is blocked before+ # zone evaluation has run+ if updated_obj.new_zone_entered and not updated_obj.false_positive:+ mqtt_required = self.camera_config.mqtt.required_zones+ if mqtt_required and set(updated_obj.entered_zones) & set(+ mqtt_required+ ):+ object_type = updated_obj.obj_data["label"]+ self.send_mqtt_snapshot(updated_obj, object_type)+ updated_obj.new_zone_entered = False+for id in removed_ids:# publish events to mqttremoved_obj = tracked_objects[id]diff --git a/frigate/track/tracked_object.py b/frigate/track/tracked_object.pyindex 44d2708750..f5c33d1e6c 100644--- a/frigate/track/tracked_object.py+++ b/frigate/track/tracked_object.py@@ -61,6 +61,7 @@ class TrackedObject:self.zone_loitering: dict[str, int] = {}self.current_zones: list[str] = []self.entered_zones: list[str] = []+ self.new_zone_entered: bool = Falseself.attributes: dict[str, float] = defaultdict(float)self.false_positive = Trueself.has_clip = False@@ -278,6 +279,7 @@ class TrackedObject:if name not in self.entered_zones:self.entered_zones.append(name)+ self.new_zone_entered = Trueelse:self.zone_loitering[name] = loitering_score