11"""Background subtractor motion detection."""
2+
23from __future__ import annotations
34
5+ from typing import TYPE_CHECKING
6+
47import cv2
58import numpy as np
69
7- from viseron import Viseron
810from viseron .domains .motion_detector import AbstractMotionDetectorScanner
911from viseron .domains .motion_detector .const import CONFIG_CAMERAS , DOMAIN
1012from viseron .domains .motion_detector .contours import Contours
1113
1214from .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:
2227class 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