mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
notify mqtt when objects deregistered
This commit is contained in:
parent
9ebe186443
commit
b18e8ca468
@ -45,3 +45,10 @@ class MqttObjectPublisher(threading.Thread):
|
||||
for obj_name in expired_objects:
|
||||
current_object_status[obj_name] = 'OFF'
|
||||
self.client.publish(self.topic_prefix+'/'+obj_name, 'OFF', retain=False)
|
||||
# send updated snapshot snapshot over mqtt if we have it as well
|
||||
if obj_name in self.camera.best_frames.best_frames:
|
||||
best_frame = cv2.cvtColor(self.camera.best_frames.best_frames[obj_name], cv2.COLOR_RGB2BGR)
|
||||
ret, jpg = cv2.imencode('.jpg', best_frame)
|
||||
if ret:
|
||||
jpg_bytes = jpg.tobytes()
|
||||
self.client.publish(self.topic_prefix+'/'+obj_name+'/snapshot', jpg_bytes, retain=True)
|
@ -27,6 +27,7 @@ class ObjectCleaner(threading.Thread):
|
||||
if not frame_time in self.camera.frame_cache:
|
||||
del self.camera.detected_objects[frame_time]
|
||||
|
||||
objects_deregistered = False
|
||||
with self.camera.object_tracker.tracked_objects_lock:
|
||||
now = datetime.datetime.now().timestamp()
|
||||
for id, obj in list(self.camera.object_tracker.tracked_objects.items()):
|
||||
@ -34,6 +35,11 @@ class ObjectCleaner(threading.Thread):
|
||||
# and not in the most recent frame, deregister
|
||||
if (now - obj['frame_time']) > 10 and self.camera.object_tracker.most_recent_frame_time > obj['frame_time']:
|
||||
self.camera.object_tracker.deregister(id)
|
||||
objects_deregistered = True
|
||||
|
||||
if objects_deregistered:
|
||||
with self.camera.objects_tracked:
|
||||
self.camera.objects_tracked.notify_all()
|
||||
|
||||
class DetectedObjectsProcessor(threading.Thread):
|
||||
def __init__(self, camera):
|
||||
|
Loading…
Reference in New Issue
Block a user