From 86937bd9195229b7286dd83417acfc3f84cc3552 Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Sun, 6 Sep 2020 15:04:28 +0000 Subject: [PATCH] allow interval to be float and fix codec --- src/lib/camera.py | 17 ++++++++++------- src/lib/config/config_camera.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/lib/camera.py b/src/lib/camera.py index 6a782de1f..ed5391628 100644 --- a/src/lib/camera.py +++ b/src/lib/camera.py @@ -118,19 +118,22 @@ def capture_pipe( self.connected = True object_frame_number = 0 - self._logger.debug( - f"Running object detection at {object_decoder_interval}s interval" - ) - object_decoder_interval_calculated = int( + object_decoder_interval_calculated = round( object_decoder_interval * self.stream_fps ) - motion_frame_number = 0 self._logger.debug( - f"Running motion detection at {motion_decoder_interval}s interval" + f"Running object detection at {object_decoder_interval}s interval, " + f"every {object_decoder_interval_calculated} frame(s)" ) - motion_decoder_interval_calculated = int( + + motion_frame_number = 0 + motion_decoder_interval_calculated = round( motion_decoder_interval * self.stream_fps ) + self._logger.debug( + f"Running motion detection at {motion_decoder_interval}s interval, " + f"every {motion_decoder_interval_calculated} frame(s)" + ) while self.connected: if self.connection_error: diff --git a/src/lib/config/config_camera.py b/src/lib/config/config_camera.py index 00e1d7134..5f3111c79 100644 --- a/src/lib/config/config_camera.py +++ b/src/lib/config/config_camera.py @@ -40,6 +40,9 @@ def check_for_hwaccels(hwaccel_args: list) -> list: def get_codec(camera: dict) -> dict: + if camera["codec"]: + return camera + if camera["stream_format"] == "rtsp": if os.getenv(ENV_CUDA_SUPPORTED) == "true": camera["codec"] = HWACCEL_CUDA_DECODER_CODEC @@ -81,7 +84,7 @@ def get_codec(camera: dict) -> dict: Optional("filter_args", default=[]): list, Optional("motion_detection", default=None): Any( { - Optional("interval"): int, + Optional("interval"): Any(int, float), Optional("trigger"): bool, Optional("timeout"): bool, Optional("width"): int, @@ -92,7 +95,10 @@ def get_codec(camera: dict) -> dict: None, ), Optional("object_detection", default=None): Any( - {Optional("interval"): int, Optional("labels"): LABELS_SCHEMA,}, + { + Optional("interval"): Any(int, float), + Optional("labels"): LABELS_SCHEMA, + }, None, ), },