From da2492413f87cfefdfc2b9d1ea6bee5b214a77e9 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Wed, 7 Jul 2021 07:02:36 -0500 Subject: [PATCH] publish on zone change (fixes #1310) --- frigate/object_processing.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 706d04328..372db8ef7 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -107,6 +107,7 @@ class TrackedObject: def update(self, current_frame_time, obj_data): significant_update = False + zone_change = False self.obj_data.update(obj_data) # if the object is not in the current frame, add a 0.0 to the score history if self.obj_data["frame_time"] != current_frame_time: @@ -152,10 +153,10 @@ class TrackedObject: # if the zones changed, signal an update if not self.false_positive and set(self.current_zones) != set(current_zones): - significant_update = True + zone_change = True self.current_zones = current_zones - return significant_update + return (significant_update, zone_change) def to_dict(self, include_thumbnail: bool = False): snapshot_time = ( @@ -451,7 +452,9 @@ class CameraState: for id in updated_ids: updated_obj = tracked_objects[id] - significant_update = updated_obj.update(frame_time, current_detections[id]) + significant_update, zone_change = updated_obj.update( + frame_time, current_detections[id] + ) if significant_update: # ensure this frame is stored in the cache @@ -464,11 +467,12 @@ class CameraState: updated_obj.last_updated = frame_time # if it has been more than 5 seconds since the last publish - # and the last update is greater than the last publish + # and the last update is greater than the last publish or + # the object has changed zones if ( frame_time - updated_obj.last_published > 5 and updated_obj.last_updated > updated_obj.last_published - ): + ) or zone_change: # call event handlers for c in self.callbacks["update"]: c(self.name, updated_obj, frame_time)