Skip to content

Commit 02fe48d

Browse files
committed
refactor(background_subtractor): format with ruff
1 parent e5135b0 commit 02fe48d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

viseron/components/background_subtractor/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Background subtraction motion detection."""
2+
23
import voluptuous as vol
34

45
from viseron import Viseron
@@ -51,10 +52,10 @@
5152
)
5253

5354

54-
def setup_domains(vis: Viseron, config) -> None:
55+
def setup_domains(vis: Viseron, config: dict) -> None:
5556
"""Set up background_subtractor domains."""
5657
config = config[COMPONENT]
57-
for camera_identifier in config[CONFIG_MOTION_DETECTOR][CONFIG_CAMERAS].keys():
58+
for camera_identifier in config[CONFIG_MOTION_DETECTOR][CONFIG_CAMERAS]:
5859
setup_domain(
5960
vis,
6061
COMPONENT,

viseron/components/background_subtractor/motion_detector.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
"""Background subtractor motion detection."""
2+
23
from __future__ import annotations
34

5+
from typing import TYPE_CHECKING
6+
47
import cv2
58
import numpy as np
69

7-
from viseron import Viseron
810
from viseron.domains.motion_detector import AbstractMotionDetectorScanner
911
from viseron.domains.motion_detector.const import CONFIG_CAMERAS, DOMAIN
1012
from viseron.domains.motion_detector.contours import Contours
1113

1214
from .const import COMPONENT, CONFIG_ALPHA, CONFIG_THRESHOLD
1315

16+
if TYPE_CHECKING:
17+
from viseron import Viseron
18+
1419

15-
def setup(vis: Viseron, config, identifier) -> bool:
20+
def setup(vis: Viseron, config: dict, identifier: str) -> bool:
1621
"""Set up the background_subtractor motion_detector domain."""
1722
MotionDetector(vis, config[DOMAIN], identifier)
1823

@@ -22,14 +27,14 @@ def setup(vis: Viseron, config, identifier) -> bool:
2227
class MotionDetector(AbstractMotionDetectorScanner):
2328
"""Perform motion detection."""
2429

25-
def __init__(self, vis: Viseron, config, camera_identifier) -> None:
30+
def __init__(self, vis: Viseron, config: dict, camera_identifier: str) -> None:
2631
super().__init__(vis, COMPONENT, config, camera_identifier)
2732
self._camera_config = config[CONFIG_CAMERAS][camera_identifier]
2833

2934
self._avg: np.ndarray | None = None
3035
self._empty_mat = cv2.Mat(np.empty((3, 3), np.uint8))
3136

32-
def preprocess(self, frame: np.ndarray):
37+
def preprocess(self, frame: np.ndarray) -> np.ndarray:
3338
"""Resize the frame to the desired width and height."""
3439
return cv2.resize(
3540
frame,

0 commit comments

Comments
 (0)