From 9d2937e68119ef6ce912b29f37e326ce6aec680c Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sat, 7 Oct 2023 12:10:32 -0500 Subject: [PATCH] zoom on initial move if relative --- frigate/ptz/autotrack.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index e4b4dc481..b10228f2b 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -775,26 +775,24 @@ class PtzAutoTracker: # relative zooming concurrently with pan/tilt if camera_config.onvif.autotracking.zooming == ZoomingModeEnum.relative: - # don't zoom on initial move if self.tracked_object_previous[camera] is None: - zoom = 0 self.previous_target_box[camera] = target_box - else: - if ( - result := self._should_zoom_in( - camera, - obj, - predicted_box - if camera_config.onvif.autotracking.movement_weights - else obj.obj_data["box"], - ) - ) is not None: - # zoom in value - zoom = target_box ** self.zoom_factor[camera] - if not result: - # zoom out - zoom = -(1 - zoom) if zoom != 0 else 0 + if ( + result := self._should_zoom_in( + camera, + obj, + predicted_box + if camera_config.onvif.autotracking.movement_weights + else obj.obj_data["box"], + ) + ) is not None: + # zoom in value + zoom = target_box ** self.zoom_factor[camera] + + if not result: + # zoom out + zoom = -(1 - zoom) if zoom != 0 else 0 logger.debug(f"{camera}: Zooming: {result} Zoom amount: {zoom}")