mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-05 04:57:42 +03:00
Remove duplicate enabled checkers
This commit is contained in:
parent
3018f54d1e
commit
ae07dd8305
@ -754,7 +754,6 @@ class Birdseye:
|
|||||||
"birdseye", self.converter, websocket_server, stop_event
|
"birdseye", self.converter, websocket_server, stop_event
|
||||||
)
|
)
|
||||||
self.birdseye_manager = BirdsEyeFrameManager(config, stop_event)
|
self.birdseye_manager = BirdsEyeFrameManager(config, stop_event)
|
||||||
self.config_enabled_subscriber = ConfigSubscriber("config/enabled/")
|
|
||||||
self.birdseye_subscriber = ConfigSubscriber("config/birdseye/")
|
self.birdseye_subscriber = ConfigSubscriber("config/birdseye/")
|
||||||
self.frame_manager = SharedMemoryFrameManager()
|
self.frame_manager = SharedMemoryFrameManager()
|
||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
@ -799,24 +798,13 @@ class Birdseye:
|
|||||||
updated_birdseye_config,
|
updated_birdseye_config,
|
||||||
) = self.birdseye_subscriber.check_for_update()
|
) = self.birdseye_subscriber.check_for_update()
|
||||||
|
|
||||||
(
|
if not updated_birdseye_topic:
|
||||||
updated_enabled_topic,
|
|
||||||
updated_enabled_config,
|
|
||||||
) = self.config_enabled_subscriber.check_for_update()
|
|
||||||
|
|
||||||
if not updated_birdseye_topic and not updated_enabled_topic:
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if updated_birdseye_config:
|
if updated_birdseye_config:
|
||||||
camera_name = updated_birdseye_topic.rpartition("/")[-1]
|
camera_name = updated_birdseye_topic.rpartition("/")[-1]
|
||||||
self.config.cameras[camera_name].birdseye = updated_birdseye_config
|
self.config.cameras[camera_name].birdseye = updated_birdseye_config
|
||||||
|
|
||||||
if updated_enabled_config:
|
|
||||||
camera_name = updated_enabled_topic.rpartition("/")[-1]
|
|
||||||
self.config.cameras[
|
|
||||||
camera_name
|
|
||||||
].enabled = updated_enabled_config.enabled
|
|
||||||
|
|
||||||
if self.birdseye_manager.update(
|
if self.birdseye_manager.update(
|
||||||
camera,
|
camera,
|
||||||
len([o for o in current_tracked_objects if not o["stationary"]]),
|
len([o for o in current_tracked_objects if not o["stationary"]]),
|
||||||
|
|||||||
@ -99,12 +99,7 @@ def output_frames(
|
|||||||
websocket_thread = threading.Thread(target=websocket_server.serve_forever)
|
websocket_thread = threading.Thread(target=websocket_server.serve_forever)
|
||||||
|
|
||||||
detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video)
|
detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video)
|
||||||
|
config_enabled_subscriber = ConfigSubscriber("config/enabled/")
|
||||||
enabled_subscribers = {
|
|
||||||
camera: ConfigSubscriber(f"config/enabled/{camera}", True)
|
|
||||||
for camera in config.cameras.keys()
|
|
||||||
if config.cameras[camera].enabled_in_config
|
|
||||||
}
|
|
||||||
|
|
||||||
jsmpeg_cameras: dict[str, JsmpegCamera] = {}
|
jsmpeg_cameras: dict[str, JsmpegCamera] = {}
|
||||||
birdseye: Birdseye | None = None
|
birdseye: Birdseye | None = None
|
||||||
@ -128,16 +123,21 @@ def output_frames(
|
|||||||
|
|
||||||
websocket_thread.start()
|
websocket_thread.start()
|
||||||
|
|
||||||
def get_enabled_state(camera: str) -> bool:
|
|
||||||
_, config_data = enabled_subscribers[camera].check_for_update()
|
|
||||||
|
|
||||||
if config_data:
|
|
||||||
config.cameras[camera].enabled = config_data.enabled
|
|
||||||
return config_data.enabled
|
|
||||||
|
|
||||||
return config.cameras[camera].enabled
|
|
||||||
|
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
|
# check if there is an updated config
|
||||||
|
while True:
|
||||||
|
(
|
||||||
|
updated_enabled_topic,
|
||||||
|
updated_enabled_config,
|
||||||
|
) = config_enabled_subscriber.check_for_update()
|
||||||
|
|
||||||
|
if not updated_enabled_topic:
|
||||||
|
break
|
||||||
|
|
||||||
|
if updated_enabled_config:
|
||||||
|
camera_name = updated_enabled_topic.rpartition("/")[-1]
|
||||||
|
config.cameras[camera_name].enabled = updated_enabled_config.enabled
|
||||||
|
|
||||||
(topic, data) = detection_subscriber.check_for_update(timeout=1)
|
(topic, data) = detection_subscriber.check_for_update(timeout=1)
|
||||||
now = datetime.datetime.now().timestamp()
|
now = datetime.datetime.now().timestamp()
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ def output_frames(
|
|||||||
_,
|
_,
|
||||||
) = data
|
) = data
|
||||||
|
|
||||||
if not get_enabled_state(camera):
|
if not config.cameras[camera].enabled:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
frame = frame_manager.get(frame_name, config.cameras[camera].frame_shape_yuv)
|
frame = frame_manager.get(frame_name, config.cameras[camera].frame_shape_yuv)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user