From da09e3904e87574fd6139af3566302844eb083dc Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:49:34 -0600 Subject: [PATCH] don't split up large ptz movements --- frigate/ptz/autotrack.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index 44312c3e9..04786f99a 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -734,11 +734,12 @@ class PtzAutoTracker: and frame_time > self.ptz_metrics[camera]["ptz_stop_time"].value and not self.move_queue_locks[camera].locked() ): - # split up any large moves caused by velocity estimated movements + # we can split up any large moves caused by velocity estimated movements if necessary + # get an excess amount and assign it instead of 0 below while pan != 0 or tilt != 0 or zoom != 0: - pan, pan_excess = split_value(pan) - tilt, tilt_excess = split_value(tilt) - zoom, zoom_excess = split_value(zoom, False) + pan, _ = split_value(pan) + tilt, _ = split_value(tilt) + zoom, _ = split_value(zoom, False) logger.debug( f"{camera}: Enqueue movement for frame time: {frame_time} pan: {pan}, tilt: {tilt}, zoom: {zoom}" @@ -746,9 +747,10 @@ class PtzAutoTracker: move_data = (frame_time, pan, tilt, zoom) self.move_queues[camera].put(move_data) - pan = pan_excess - tilt = tilt_excess - zoom = zoom_excess + # reset values to not split up large movements + pan = 0 + tilt = 0 + zoom = 0 def _touching_frame_edges(self, camera, box): camera_config = self.config.cameras[camera] @@ -1152,7 +1154,9 @@ class PtzAutoTracker: "target_box" ] + self._predict_area_after_time( camera, predicted_movement_time - ) / (camera_width * camera_height) + ) / ( + camera_width * camera_height + ) logger.debug( f"{camera}: Zooming prediction: predicted movement time: {predicted_movement_time}, original box: {self.tracked_object_metrics[camera]['target_box']}, calculated box: {calculated_target_box}" )