mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-12 05:41:12 +03:00
Dynamically update masks and zones for cameras (#18359)
* Include config publisher in api * Call update topic for passed topics * Update zones dynamically * Update zones internally * Support zone and mask reset * Handle updating objects config * Don't put status for needing to restart Frigate * Cleanup http tests * Fix tests
This commit is contained in:
committed by
Blake Blackshear
parent
dc187eee1c
commit
4dc526761c
@@ -1,6 +1,8 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Tuple
|
||||
|
||||
from numpy import ndarray
|
||||
|
||||
from frigate.config import MotionConfig
|
||||
|
||||
|
||||
@@ -18,13 +20,21 @@ class MotionDetector(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def detect(self, frame):
|
||||
def detect(self, frame: ndarray) -> list:
|
||||
"""Detect motion and return motion boxes."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def is_calibrating(self):
|
||||
"""Return if motion is recalibrating."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update_mask(self) -> None:
|
||||
"""Update the motion mask after a config change."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def stop(self):
|
||||
"""Stop any ongoing work and processes."""
|
||||
pass
|
||||
|
||||
@@ -35,12 +35,7 @@ class ImprovedMotionDetector(MotionDetector):
|
||||
self.avg_frame = np.zeros(self.motion_frame_size, np.float32)
|
||||
self.motion_frame_count = 0
|
||||
self.frame_counter = 0
|
||||
resized_mask = cv2.resize(
|
||||
config.mask,
|
||||
dsize=(self.motion_frame_size[1], self.motion_frame_size[0]),
|
||||
interpolation=cv2.INTER_AREA,
|
||||
)
|
||||
self.mask = np.where(resized_mask == [0])
|
||||
self.update_mask()
|
||||
self.save_images = False
|
||||
self.calibrating = True
|
||||
self.blur_radius = blur_radius
|
||||
@@ -236,6 +231,14 @@ class ImprovedMotionDetector(MotionDetector):
|
||||
|
||||
return motion_boxes
|
||||
|
||||
def update_mask(self) -> None:
|
||||
resized_mask = cv2.resize(
|
||||
self.config.mask,
|
||||
dsize=(self.motion_frame_size[1], self.motion_frame_size[0]),
|
||||
interpolation=cv2.INTER_AREA,
|
||||
)
|
||||
self.mask = np.where(resized_mask == [0])
|
||||
|
||||
def stop(self) -> None:
|
||||
"""stop the motion detector."""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user