Skip to content

Commit

Permalink
allow interval to be float and fix codec
Browse files Browse the repository at this point in the history
  • Loading branch information
roflcoopter committed Sep 6, 2020
1 parent 14a09c7 commit 86937bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/lib/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions src/lib/config/config_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
},
Expand Down

0 comments on commit 86937bd

Please sign in to comment.