From cb88ff134c74a32e325aa7ecdeac46fcb65284a0 Mon Sep 17 00:00:00 2001 From: banthungprong <59219161+banthungprong@users.noreply.github.com> Date: Sun, 30 Oct 2022 09:36:26 +0100 Subject: [PATCH] change if-logic, obsolete copy, info disabled cam --- docs/docs/guides/getting_started.md | 1 - frigate/app.py | 64 +++++++++++++++-------------- frigate/config.py | 2 +- web/src/components/CameraImage.jsx | 21 ++++++---- 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/docs/docs/guides/getting_started.md b/docs/docs/guides/getting_started.md index 72dd1c6b0..977649b01 100644 --- a/docs/docs/guides/getting_started.md +++ b/docs/docs/guides/getting_started.md @@ -62,7 +62,6 @@ detectors: cameras: camera_1: # <------ Name the camera - enabled: True # <----- Enable/disable camera ffmpeg: inputs: - path: rtsp://10.0.10.10:554/rtsp # <----- Update for your camera diff --git a/frigate/app.py b/frigate/app.py index 81cf7c89d..dd885526f 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -250,42 +250,44 @@ class FrigateApp: def start_camera_processors(self) -> None: model_shape = (self.config.model.height, self.config.model.width) for name, config in self.config.cameras.items(): - if self.config.cameras[name].enabled: - camera_process = mp.Process( - target=track_camera, - name=f"camera_processor:{name}", - args=( - name, - config, - model_shape, - self.config.model.merged_labelmap, - self.detection_queue, - self.detection_out_events[name], - self.detected_frames_queue, - self.camera_metrics[name], - ), - ) - camera_process.daemon = True - self.camera_metrics[name]["process"] = camera_process - camera_process.start() - logger.info(f"Camera processor started for {name}: {camera_process.pid}") - else: + if not self.config.cameras[name].enabled: logger.info(f"Camera processor not started for disabled camera {name}") + continue + + camera_process = mp.Process( + target=track_camera, + name=f"camera_processor:{name}", + args=( + name, + config, + model_shape, + self.config.model.merged_labelmap, + self.detection_queue, + self.detection_out_events[name], + self.detected_frames_queue, + self.camera_metrics[name], + ), + ) + camera_process.daemon = True + self.camera_metrics[name]["process"] = camera_process + camera_process.start() + logger.info(f"Camera processor started for {name}: {camera_process.pid}") def start_camera_capture_processes(self) -> None: for name, config in self.config.cameras.items(): - if self.config.cameras[name].enabled: - capture_process = mp.Process( - target=capture_camera, - name=f"camera_capture:{name}", - args=(name, config, self.camera_metrics[name]), - ) - capture_process.daemon = True - self.camera_metrics[name]["capture_process"] = capture_process - capture_process.start() - logger.info(f"Capture process started for {name}: {capture_process.pid}") - else: + if not self.config.cameras[name].enabled: logger.info(f"Capture process not started for disabled camera {name}") + continue + + capture_process = mp.Process( + target=capture_camera, + name=f"camera_capture:{name}", + args=(name, config, self.camera_metrics[name]), + ) + capture_process.daemon = True + self.camera_metrics[name]["capture_process"] = capture_process + capture_process.start() + logger.info(f"Capture process started for {name}: {capture_process.pid}") def start_event_processor(self) -> None: self.event_processor = EventProcessor( diff --git a/frigate/config.py b/frigate/config.py index 9a9465341..c7a75adfa 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -817,7 +817,7 @@ class FrigateConfig(FrigateBaseModel): exclude_unset=True, ) - for name, camera in config.cameras.copy().items(): + for name, camera in config.cameras.items(): merged_config = deep_merge(camera.dict(exclude_unset=True), global_config) camera_config: CameraConfig = CameraConfig.parse_obj( {"name": name, **merged_config} diff --git a/web/src/components/CameraImage.jsx b/web/src/components/CameraImage.jsx index 6da88f218..8d5253424 100644 --- a/web/src/components/CameraImage.jsx +++ b/web/src/components/CameraImage.jsx @@ -14,6 +14,7 @@ export default function CameraImage({ camera, onload, searchParams = '', stretch const [{ width: availableWidth }] = useResizeObserver(containerRef); const { name } = config ? config.cameras[camera] : ''; + const enabled = config ? config.cameras[camera].enabled : 'True'; const { width, height } = config ? config.cameras[camera].detect : { width: 1, height: 1 }; const aspectRatio = width / height; @@ -45,12 +46,18 @@ export default function CameraImage({ camera, onload, searchParams = '', stretch return (