2023-06-11 09:45:11 -04:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
from typing import Tuple
|
|
|
|
|
|
2025-05-22 20:51:23 -06:00
|
|
|
from numpy import ndarray
|
|
|
|
|
|
2023-06-11 09:45:11 -04:00
|
|
|
from frigate.config import MotionConfig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MotionDetector(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
frame_shape: Tuple[int, int, int],
|
|
|
|
|
config: MotionConfig,
|
|
|
|
|
fps: int,
|
|
|
|
|
improve_contrast,
|
|
|
|
|
threshold,
|
|
|
|
|
contour_area,
|
|
|
|
|
):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
2025-05-22 20:51:23 -06:00
|
|
|
def detect(self, frame: ndarray) -> list:
|
|
|
|
|
"""Detect motion and return motion boxes."""
|
2023-06-11 09:45:11 -04:00
|
|
|
pass
|
2023-10-14 08:05:44 -04:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def is_calibrating(self):
|
2025-05-22 20:51:23 -06:00
|
|
|
"""Return if motion is recalibrating."""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def update_mask(self) -> None:
|
|
|
|
|
"""Update the motion mask after a config change."""
|
2023-10-14 08:05:44 -04:00
|
|
|
pass
|
2024-02-19 06:26:59 -07:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def stop(self):
|
2025-05-22 20:51:23 -06:00
|
|
|
"""Stop any ongoing work and processes."""
|
2024-02-19 06:26:59 -07:00
|
|
|
pass
|