2023-06-11 16:45:11 +03:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
from typing import Tuple
|
|
|
|
|
|
2025-05-23 05:51:23 +03:00
|
|
|
from numpy import ndarray
|
|
|
|
|
|
2023-06-11 16:45:11 +03: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-23 05:51:23 +03:00
|
|
|
def detect(self, frame: ndarray) -> list:
|
|
|
|
|
"""Detect motion and return motion boxes."""
|
2023-06-11 16:45:11 +03:00
|
|
|
pass
|
2023-10-14 15:05:44 +03:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def is_calibrating(self):
|
2025-05-23 05:51:23 +03:00
|
|
|
"""Return if motion is recalibrating."""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def update_mask(self) -> None:
|
|
|
|
|
"""Update the motion mask after a config change."""
|
2023-10-14 15:05:44 +03:00
|
|
|
pass
|
2024-02-19 16:26:59 +03:00
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def stop(self):
|
2025-05-23 05:51:23 +03:00
|
|
|
"""Stop any ongoing work and processes."""
|
2024-02-19 16:26:59 +03:00
|
|
|
pass
|