mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-23 19:11:14 +01:00
notify mqtt when objects deregistered
This commit is contained in:
parent
2aada930e3
commit
3a66e672d3
@ -44,4 +44,11 @@ class MqttObjectPublisher(threading.Thread):
|
||||
expired_objects = [obj_name for obj_name, status in current_object_status.items() if status == 'ON' and not obj_name in obj_counter]
|
||||
for obj_name in expired_objects:
|
||||
current_object_status[obj_name] = 'OFF'
|
||||
self.client.publish(self.topic_prefix+'/'+obj_name, 'OFF', retain=False)
|
||||
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