NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Only match on exact config name in some cases (#16704)
Nicolas Mowenc7db0f479d48
diff --git a/frigate/comms/config_updater.py b/frigate/comms/config_updater.pyindex 2731039110..49be36c1e4 100644--- a/frigate/comms/config_updater.py+++ b/frigate/comms/config_updater.py@@ -32,7 +32,9 @@ class ConfigPublisher:class ConfigSubscriber:"""Simplifies receiving an updated config."""- def __init__(self, topic: str) -> None:+ def __init__(self, topic: str, exact=False) -> None:+ self.topic = topic+ self.exact = exactself.context = zmq.Context()self.socket = self.context.socket(zmq.SUB)self.socket.setsockopt_string(zmq.SUBSCRIBE, topic)@@ -42,7 +44,12 @@ class ConfigSubscriber:"""Returns updated config or None if no update."""try:topic = self.socket.recv_string(flags=zmq.NOBLOCK)- return (topic, self.socket.recv_pyobj())+ obj = self.socket.recv_pyobj()++ if not self.exact or self.topic == topic:+ return (topic, obj)+ else:+ return (None, None)except zmq.ZMQError:return (None, None)diff --git a/frigate/motion/improved_motion.py b/frigate/motion/improved_motion.pyindex d865cc92df..aae5167a45 100644--- a/frigate/motion/improved_motion.py+++ b/frigate/motion/improved_motion.py@@ -49,7 +49,7 @@ class ImprovedMotionDetector(MotionDetector):self.contrast_values = np.zeros((contrast_frame_history, 2), np.uint8)self.contrast_values[:, 1:2] = 255self.contrast_values_index = 0- self.config_subscriber = ConfigSubscriber(f"config/motion/{name}")+ self.config_subscriber = ConfigSubscriber(f"config/motion/{name}", True)self.ptz_metrics = ptz_metricsself.last_stop_time = Nonediff --git a/frigate/output/preview.py b/frigate/output/preview.pyindex ae2ba4591c..4f8796d39f 100644--- a/frigate/output/preview.py+++ b/frigate/output/preview.py@@ -172,7 +172,9 @@ class PreviewRecorder:# create communication for finished previewsself.requestor = InterProcessRequestor()- self.config_subscriber = ConfigSubscriber(f"config/record/{self.config.name}")+ self.config_subscriber = ConfigSubscriber(+ f"config/record/{self.config.name}", True+ )y, u1, u2, v1, v2 = get_yuv_crop(self.config.frame_shape_yuv,diff --git a/frigate/video.py b/frigate/video.pyindex f82d866483..233cebb9e5 100755--- a/frigate/video.py+++ b/frigate/video.py@@ -539,7 +539,7 @@ def process_frames(exit_on_empty: bool = False,):next_region_update = get_tomorrow_at_time(2)- config_subscriber = ConfigSubscriber(f"config/detect/{camera_name}")+ config_subscriber = ConfigSubscriber(f"config/detect/{camera_name}", True)fps_tracker = EventsPerSecond()fps_tracker.start()