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