mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
Update motion
This commit is contained in:
parent
3457a496c2
commit
945d7e71da
@ -277,8 +277,11 @@ class Dispatcher:
|
||||
f"Turning on motion for {camera_name} due to detection being enabled."
|
||||
)
|
||||
motion_settings.enabled = True
|
||||
self.config_updater.publish(
|
||||
f"config/motion/{camera_name}", motion_settings
|
||||
self.config_updater.publish_update(
|
||||
CameraConfigUpdateTopic(
|
||||
CameraConfigUpdateEnum.motion, camera_name
|
||||
),
|
||||
motion_settings,
|
||||
)
|
||||
self.publish(f"{camera_name}/motion/state", payload, retain=True)
|
||||
elif payload == "OFF":
|
||||
@ -333,7 +336,10 @@ class Dispatcher:
|
||||
logger.info(f"Turning off motion for {camera_name}")
|
||||
motion_settings.enabled = False
|
||||
|
||||
self.config_updater.publish(f"config/motion/{camera_name}", motion_settings)
|
||||
self.config_updater.publish_update(
|
||||
CameraConfigUpdateTopic(CameraConfigUpdateEnum.motion, camera_name),
|
||||
motion_settings,
|
||||
)
|
||||
self.publish(f"{camera_name}/motion/state", payload, retain=True)
|
||||
|
||||
def _on_motion_improve_contrast_command(
|
||||
@ -351,7 +357,10 @@ class Dispatcher:
|
||||
logger.info(f"Turning off improve contrast for {camera_name}")
|
||||
motion_settings.improve_contrast = False # type: ignore[union-attr]
|
||||
|
||||
self.config_updater.publish(f"config/motion/{camera_name}", motion_settings)
|
||||
self.config_updater.publish_update(
|
||||
CameraConfigUpdateTopic(CameraConfigUpdateEnum.motion, camera_name),
|
||||
motion_settings,
|
||||
)
|
||||
self.publish(f"{camera_name}/improve_contrast/state", payload, retain=True)
|
||||
|
||||
def _on_ptz_autotracker_command(self, camera_name: str, payload: str) -> None:
|
||||
@ -391,7 +400,10 @@ class Dispatcher:
|
||||
motion_settings = self.config.cameras[camera_name].motion
|
||||
logger.info(f"Setting motion contour area for {camera_name}: {payload}")
|
||||
motion_settings.contour_area = payload # type: ignore[union-attr]
|
||||
self.config_updater.publish(f"config/motion/{camera_name}", motion_settings)
|
||||
self.config_updater.publish_update(
|
||||
CameraConfigUpdateTopic(CameraConfigUpdateEnum.motion, camera_name),
|
||||
motion_settings,
|
||||
)
|
||||
self.publish(f"{camera_name}/motion_contour_area/state", payload, retain=True)
|
||||
|
||||
def _on_motion_threshold_command(self, camera_name: str, payload: int) -> None:
|
||||
@ -405,7 +417,10 @@ class Dispatcher:
|
||||
motion_settings = self.config.cameras[camera_name].motion
|
||||
logger.info(f"Setting motion threshold for {camera_name}: {payload}")
|
||||
motion_settings.threshold = payload # type: ignore[union-attr]
|
||||
self.config_updater.publish(f"config/motion/{camera_name}", motion_settings)
|
||||
self.config_updater.publish_update(
|
||||
CameraConfigUpdateTopic(CameraConfigUpdateEnum.motion, camera_name),
|
||||
motion_settings,
|
||||
)
|
||||
self.publish(f"{camera_name}/motion_threshold/state", payload, retain=True)
|
||||
|
||||
def _on_global_notification_command(self, payload: str) -> None:
|
||||
|
||||
@ -5,7 +5,6 @@ import numpy as np
|
||||
from scipy.ndimage import gaussian_filter
|
||||
|
||||
from frigate.camera import PTZMetrics
|
||||
from frigate.comms.config_updater import ConfigSubscriber
|
||||
from frigate.config import MotionConfig
|
||||
from frigate.motion import MotionDetector
|
||||
from frigate.util.image import grab_cv2_contours
|
||||
@ -49,7 +48,6 @@ class ImprovedMotionDetector(MotionDetector):
|
||||
self.contrast_values = np.zeros((contrast_frame_history, 2), np.uint8)
|
||||
self.contrast_values[:, 1:2] = 255
|
||||
self.contrast_values_index = 0
|
||||
self.config_subscriber = ConfigSubscriber(f"config/motion/{name}", True)
|
||||
self.ptz_metrics = ptz_metrics
|
||||
self.last_stop_time = None
|
||||
|
||||
@ -59,12 +57,6 @@ class ImprovedMotionDetector(MotionDetector):
|
||||
def detect(self, frame):
|
||||
motion_boxes = []
|
||||
|
||||
# check for updated motion config
|
||||
_, updated_motion_config = self.config_subscriber.check_for_update()
|
||||
|
||||
if updated_motion_config:
|
||||
self.config = updated_motion_config
|
||||
|
||||
if not self.config.enabled:
|
||||
return motion_boxes
|
||||
|
||||
@ -246,4 +238,4 @@ class ImprovedMotionDetector(MotionDetector):
|
||||
|
||||
def stop(self) -> None:
|
||||
"""stop the motion detector."""
|
||||
self.config_subscriber.stop()
|
||||
pass
|
||||
|
||||
Loading…
Reference in New Issue
Block a user