mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
Only match on exact config name in some cases (#16704)
* Only match on exact config name in some cases * Cleanup
This commit is contained in:
parent
94a9dcede8
commit
c7db0f479d
@ -32,7 +32,9 @@ class ConfigPublisher:
|
|||||||
class ConfigSubscriber:
|
class ConfigSubscriber:
|
||||||
"""Simplifies receiving an updated config."""
|
"""Simplifies receiving an updated config."""
|
||||||
|
|
||||||
def __init__(self, topic: str) -> None:
|
def __init__(self, topic: str, exact=False) -> None:
|
||||||
|
self.topic = topic
|
||||||
|
self.exact = exact
|
||||||
self.context = zmq.Context()
|
self.context = zmq.Context()
|
||||||
self.socket = self.context.socket(zmq.SUB)
|
self.socket = self.context.socket(zmq.SUB)
|
||||||
self.socket.setsockopt_string(zmq.SUBSCRIBE, topic)
|
self.socket.setsockopt_string(zmq.SUBSCRIBE, topic)
|
||||||
@ -42,7 +44,12 @@ class ConfigSubscriber:
|
|||||||
"""Returns updated config or None if no update."""
|
"""Returns updated config or None if no update."""
|
||||||
try:
|
try:
|
||||||
topic = self.socket.recv_string(flags=zmq.NOBLOCK)
|
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:
|
except zmq.ZMQError:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class ImprovedMotionDetector(MotionDetector):
|
|||||||
self.contrast_values = np.zeros((contrast_frame_history, 2), np.uint8)
|
self.contrast_values = np.zeros((contrast_frame_history, 2), np.uint8)
|
||||||
self.contrast_values[:, 1:2] = 255
|
self.contrast_values[:, 1:2] = 255
|
||||||
self.contrast_values_index = 0
|
self.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_metrics
|
self.ptz_metrics = ptz_metrics
|
||||||
self.last_stop_time = None
|
self.last_stop_time = None
|
||||||
|
|
||||||
|
@ -172,7 +172,9 @@ class PreviewRecorder:
|
|||||||
|
|
||||||
# create communication for finished previews
|
# create communication for finished previews
|
||||||
self.requestor = InterProcessRequestor()
|
self.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(
|
y, u1, u2, v1, v2 = get_yuv_crop(
|
||||||
self.config.frame_shape_yuv,
|
self.config.frame_shape_yuv,
|
||||||
|
@ -539,7 +539,7 @@ def process_frames(
|
|||||||
exit_on_empty: bool = False,
|
exit_on_empty: bool = False,
|
||||||
):
|
):
|
||||||
next_region_update = get_tomorrow_at_time(2)
|
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 = EventsPerSecond()
|
||||||
fps_tracker.start()
|
fps_tracker.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user