mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-29 18:17:40 +03:00
Ensure that best object is only set when the snapshot is actually updated.
This commit is contained in:
parent
48963618be
commit
8c2fe78783
@ -291,11 +291,9 @@ class CameraState:
|
|||||||
new_obj.thumbnail_data = thumbnail_data
|
new_obj.thumbnail_data = thumbnail_data
|
||||||
tracked_objects[id].thumbnail_data = thumbnail_data
|
tracked_objects[id].thumbnail_data = thumbnail_data
|
||||||
object_type = new_obj.obj_data["label"]
|
object_type = new_obj.obj_data["label"]
|
||||||
self.best_objects[object_type] = new_obj
|
|
||||||
|
|
||||||
# call event handlers
|
# call event handlers
|
||||||
for c in self.callbacks["snapshot"]:
|
self.send_mqtt_snapshot(new_obj, object_type)
|
||||||
c(self.name, self.best_objects[object_type], frame_name)
|
|
||||||
|
|
||||||
for c in self.callbacks["start"]:
|
for c in self.callbacks["start"]:
|
||||||
c(self.name, new_obj, frame_name)
|
c(self.name, new_obj, frame_name)
|
||||||
@ -417,13 +415,9 @@ class CameraState:
|
|||||||
or (now - current_best.thumbnail_data["frame_time"])
|
or (now - current_best.thumbnail_data["frame_time"])
|
||||||
> self.camera_config.best_image_timeout
|
> self.camera_config.best_image_timeout
|
||||||
):
|
):
|
||||||
self.best_objects[object_type] = obj
|
self.send_mqtt_snapshot(obj, object_type)
|
||||||
for c in self.callbacks["snapshot"]:
|
|
||||||
c(self.name, self.best_objects[object_type], frame_name)
|
|
||||||
else:
|
else:
|
||||||
self.best_objects[object_type] = obj
|
self.send_mqtt_snapshot(obj, object_type)
|
||||||
for c in self.callbacks["snapshot"]:
|
|
||||||
c(self.name, self.best_objects[object_type], frame_name)
|
|
||||||
|
|
||||||
for c in self.callbacks["camera_activity"]:
|
for c in self.callbacks["camera_activity"]:
|
||||||
c(self.name, camera_activity)
|
c(self.name, camera_activity)
|
||||||
@ -472,6 +466,20 @@ class CameraState:
|
|||||||
|
|
||||||
self.previous_frame_id = frame_name
|
self.previous_frame_id = frame_name
|
||||||
|
|
||||||
|
def send_mqtt_snapshot(self, new_obj: TrackedObject, object_type: str) -> None:
|
||||||
|
for c in self.callbacks["snapshot"]:
|
||||||
|
updated = c(self.name, new_obj)
|
||||||
|
|
||||||
|
# if the snapshot was not updated, then this object is not a best object
|
||||||
|
# but all new objects should be considered the next best object
|
||||||
|
# so we remove the label from the best objects
|
||||||
|
if updated:
|
||||||
|
self.best_objects[object_type] = new_obj
|
||||||
|
else:
|
||||||
|
if object_type in self.best_objects:
|
||||||
|
self.best_objects.pop(object_type)
|
||||||
|
break
|
||||||
|
|
||||||
def save_manual_event_image(
|
def save_manual_event_image(
|
||||||
self,
|
self,
|
||||||
frame: np.ndarray | None,
|
frame: np.ndarray | None,
|
||||||
|
|||||||
@ -156,7 +156,7 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def snapshot(camera, obj: TrackedObject, frame_name: str):
|
def snapshot(camera: str, obj: TrackedObject) -> bool:
|
||||||
mqtt_config: CameraMqttConfig = self.config.cameras[camera].mqtt
|
mqtt_config: CameraMqttConfig = self.config.cameras[camera].mqtt
|
||||||
if mqtt_config.enabled and self.should_mqtt_snapshot(camera, obj):
|
if mqtt_config.enabled and self.should_mqtt_snapshot(camera, obj):
|
||||||
jpg_bytes = obj.get_img_bytes(
|
jpg_bytes = obj.get_img_bytes(
|
||||||
@ -189,6 +189,10 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
retain=True,
|
retain=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def camera_activity(camera, activity):
|
def camera_activity(camera, activity):
|
||||||
last_activity = self.camera_activity.get(camera)
|
last_activity = self.camera_activity.get(camera)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user