mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
pass full dict instead of individual values
This commit is contained in:
parent
480a576c05
commit
e451547416
@ -36,7 +36,7 @@ def ptz_moving_at_frame_time(frame_time, ptz_start_time, ptz_stop_time):
|
||||
|
||||
|
||||
class PtzMotionEstimator:
|
||||
def __init__(self, config: CameraConfig, ptz_start_time, ptz_stop_time) -> None:
|
||||
def __init__(self, config: CameraConfig, ptz_metrics: PTZMetricsTypes) -> None:
|
||||
self.frame_manager = SharedMemoryFrameManager()
|
||||
# homography is nice (zooming) but slow, translation is pan/tilt only but fast.
|
||||
self.norfair_motion_estimator = MotionEstimator(
|
||||
@ -46,8 +46,9 @@ class PtzMotionEstimator:
|
||||
)
|
||||
self.camera_config = config
|
||||
self.coord_transformations = None
|
||||
self.ptz_start_time = ptz_start_time
|
||||
self.ptz_stop_time = ptz_stop_time
|
||||
self.ptz_metrics = ptz_metrics
|
||||
self.ptz_start_time = self.ptz_metrics["ptz_start_time"]
|
||||
self.ptz_stop_time = self.ptz_metrics["ptz_stop_time"]
|
||||
logger.debug(f"Motion estimator init for cam: {config.name}")
|
||||
|
||||
def motion_estimator(self, detections, frame_time, camera_name):
|
||||
@ -55,7 +56,7 @@ class PtzMotionEstimator:
|
||||
frame_time, self.ptz_start_time.value, self.ptz_stop_time.value
|
||||
):
|
||||
logger.debug(
|
||||
f"Motion estimator running for {camera_name} - frame time: {frame_time}"
|
||||
f"Motion estimator running for {camera_name} - frame time: {frame_time}, {self.ptz_start_time.value}, {self.ptz_stop_time.value}"
|
||||
)
|
||||
|
||||
frame_id = f"{camera_name}{frame_time}"
|
||||
|
||||
@ -8,6 +8,7 @@ from norfair.drawing.drawer import Drawer
|
||||
from frigate.config import CameraConfig
|
||||
from frigate.ptz.autotrack import PtzMotionEstimator
|
||||
from frigate.track import ObjectTracker
|
||||
from frigate.types import PTZMetricsTypes
|
||||
from frigate.util.image import intersection_over_union
|
||||
|
||||
|
||||
@ -58,9 +59,7 @@ class NorfairTracker(ObjectTracker):
|
||||
def __init__(
|
||||
self,
|
||||
config: CameraConfig,
|
||||
ptz_autotracker_enabled,
|
||||
ptz_start_time,
|
||||
ptz_stop_time,
|
||||
ptz_metrics: PTZMetricsTypes,
|
||||
):
|
||||
self.tracked_objects = {}
|
||||
self.disappeared = {}
|
||||
@ -68,7 +67,7 @@ class NorfairTracker(ObjectTracker):
|
||||
self.max_disappeared = config.detect.max_disappeared
|
||||
self.camera_config = config
|
||||
self.detect_config = config.detect
|
||||
self.ptz_autotracker_enabled = ptz_autotracker_enabled
|
||||
self.ptz_autotracker_enabled = ptz_metrics["ptz_autotracker_enabled"]
|
||||
self.camera_name = config.name
|
||||
self.track_id_map = {}
|
||||
# TODO: could also initialize a tracker per object class if there
|
||||
@ -80,9 +79,7 @@ class NorfairTracker(ObjectTracker):
|
||||
hit_counter_max=self.max_disappeared,
|
||||
)
|
||||
if self.ptz_autotracker_enabled.value:
|
||||
self.ptz_motion_estimator = PtzMotionEstimator(
|
||||
config, ptz_start_time, ptz_stop_time
|
||||
)
|
||||
self.ptz_motion_estimator = PtzMotionEstimator(config, ptz_metrics)
|
||||
|
||||
def register(self, track_id, obj):
|
||||
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
|
||||
|
||||
@ -25,6 +25,7 @@ from frigate.object_detection import RemoteObjectDetector
|
||||
from frigate.ptz.autotrack import ptz_moving_at_frame_time
|
||||
from frigate.track import ObjectTracker
|
||||
from frigate.track.norfair_tracker import NorfairTracker
|
||||
from frigate.types import PTZMetricsTypes
|
||||
from frigate.util.builtin import EventsPerSecond
|
||||
from frigate.util.image import (
|
||||
FrameManager,
|
||||
@ -462,7 +463,7 @@ def track_camera(
|
||||
result_connection,
|
||||
detected_objects_queue,
|
||||
process_info,
|
||||
ptz_info,
|
||||
ptz_metrics,
|
||||
):
|
||||
stop_event = mp.Event()
|
||||
|
||||
@ -483,11 +484,6 @@ def track_camera(
|
||||
motion_threshold = process_info["motion_threshold"]
|
||||
motion_contour_area = process_info["motion_contour_area"]
|
||||
|
||||
ptz_autotracker_enabled = ptz_info["ptz_autotracker_enabled"]
|
||||
ptz_start_time = ptz_info["ptz_start_time"]
|
||||
ptz_stop_time = ptz_info["ptz_stop_time"]
|
||||
ptz_stopped = ptz_info["ptz_stopped"]
|
||||
|
||||
frame_shape = config.frame_shape
|
||||
objects_to_track = config.objects.track
|
||||
object_filters = config.objects.filters
|
||||
@ -504,9 +500,7 @@ def track_camera(
|
||||
name, labelmap, detection_queue, result_connection, model_config, stop_event
|
||||
)
|
||||
|
||||
object_tracker = NorfairTracker(
|
||||
config, ptz_autotracker_enabled, ptz_start_time, ptz_stop_time
|
||||
)
|
||||
object_tracker = NorfairTracker(config, ptz_metrics)
|
||||
|
||||
frame_manager = SharedMemoryFrameManager()
|
||||
|
||||
@ -527,9 +521,7 @@ def track_camera(
|
||||
detection_enabled,
|
||||
motion_enabled,
|
||||
stop_event,
|
||||
ptz_start_time,
|
||||
ptz_stop_time,
|
||||
ptz_stopped,
|
||||
ptz_metrics,
|
||||
)
|
||||
|
||||
logger.info(f"{name}: exiting subprocess")
|
||||
@ -754,9 +746,7 @@ def process_frames(
|
||||
detection_enabled: mp.Value,
|
||||
motion_enabled: mp.Value,
|
||||
stop_event,
|
||||
ptz_start_time: mp.Value,
|
||||
ptz_stop_time: mp.Value,
|
||||
ptz_stopped: mp.Event,
|
||||
ptz_metrics: PTZMetricsTypes,
|
||||
exit_on_empty: bool = False,
|
||||
):
|
||||
fps = process_info["process_fps"]
|
||||
@ -799,7 +789,9 @@ def process_frames(
|
||||
motion_detector.detect(frame)
|
||||
if motion_enabled.value
|
||||
and not ptz_moving_at_frame_time(
|
||||
frame_time, ptz_start_time.value, ptz_stop_time.value
|
||||
frame_time,
|
||||
ptz_metrics["ptz_start_time"].value,
|
||||
ptz_metrics["ptz_stop_time"].value,
|
||||
)
|
||||
else []
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user