From f26093dc4a21b4709ea3b5fae42026bad142d9b2 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 29 Jun 2023 13:20:25 -0500 Subject: [PATCH] Revert "Threaded motion estimator" This reverts commit 3171801607cbbbe58cda7b637f2a3917d919959a. --- frigate/ptz_autotrack.py | 19 ------------------- frigate/track/norfair_tracker.py | 16 +++++----------- frigate/video.py | 4 +--- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/frigate/ptz_autotrack.py b/frigate/ptz_autotrack.py index 3e3bf29d6..5761aa475 100644 --- a/frigate/ptz_autotrack.py +++ b/frigate/ptz_autotrack.py @@ -17,21 +17,6 @@ from frigate.util import SharedMemoryFrameManager, intersection_over_union logger = logging.getLogger(__name__) -class PtzMotionEstimatorThread(threading.Thread): - def __init__(self, config: CameraConfig, ptz_moving, stop_event) -> None: - threading.Thread.__init__(self) - self.name = "frigate_ptz_motion_estimator" - self.ptz_moving = ptz_moving - self.config = config - self.stop_event = stop_event - self.ptz_motion_estimator = PtzMotionEstimator(self.config, self.ptz_moving) - - def run(self): - while not self.stop_event.is_set(): - pass - logger.info("Exiting motion estimator...") - - class PtzMotionEstimator: def __init__(self, config: CameraConfig, ptz_moving) -> None: self.frame_manager = SharedMemoryFrameManager() @@ -71,10 +56,6 @@ class PtzMotionEstimator: self.frame_manager.close(frame_id) - logger.debug( - f"frame time: {frame_time}, coord_transformations: {vars(self.coord_transformations)}" - ) - return self.coord_transformations return None diff --git a/frigate/track/norfair_tracker.py b/frigate/track/norfair_tracker.py index 2683b05d1..48cc029ee 100644 --- a/frigate/track/norfair_tracker.py +++ b/frigate/track/norfair_tracker.py @@ -6,7 +6,7 @@ from norfair import Detection, Drawable, Tracker, draw_boxes from norfair.drawing.drawer import Drawer from frigate.config import CameraConfig -from frigate.ptz_autotrack import PtzMotionEstimatorThread +from frigate.ptz_autotrack import PtzMotionEstimator from frigate.track import ObjectTracker from frigate.util import intersection_over_union @@ -55,9 +55,7 @@ def frigate_distance(detection: Detection, tracked_object) -> float: class NorfairTracker(ObjectTracker): - def __init__( - self, config: CameraConfig, ptz_autotracker_enabled, ptz_moving, stop_event - ): + def __init__(self, config: CameraConfig, ptz_autotracker_enabled, ptz_moving): self.tracked_objects = {} self.disappeared = {} self.positions = {} @@ -77,9 +75,7 @@ class NorfairTracker(ObjectTracker): hit_counter_max=self.max_disappeared, ) if self.ptz_autotracker_enabled: - self.ptz_motion_estimator_thread = PtzMotionEstimatorThread( - config, self.ptz_moving, stop_event - ) + self.ptz_motion_estimator = PtzMotionEstimator(config, self.ptz_moving) def register(self, track_id, obj): rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6)) @@ -247,10 +243,8 @@ class NorfairTracker(ObjectTracker): self.ptz_autotracker_enabled and self.camera_config.onvif.autotracking.motion_estimator ): - coord_transformations = ( - self.ptz_motion_estimator_thread.ptz_motion_estimator.motion_estimator( - detections, frame_time, self.camera_name - ) + coord_transformations = self.ptz_motion_estimator.motion_estimator( + detections, frame_time, self.camera_name ) tracked_objects = self.tracker.update( diff --git a/frigate/video.py b/frigate/video.py index 2eaa439c2..4dfcbedab 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -478,9 +478,7 @@ def track_camera( name, labelmap, detection_queue, result_connection, model_config, stop_event ) - object_tracker = NorfairTracker( - config, ptz_autotracker_enabled, ptz_moving, stop_event - ) + object_tracker = NorfairTracker(config, ptz_autotracker_enabled, ptz_moving) frame_manager = SharedMemoryFrameManager()