From 616eb5f96af95a78f73c2c20388a50f823c49a00 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Fri, 16 Feb 2024 06:09:30 -0600 Subject: [PATCH 1/4] Use zoom space id in Onvif RelativeMove setup (#9859) * use zoom space id in onvif relativemove setup * better handle cases when zooming is disabled --- frigate/ptz/onvif.py | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/frigate/ptz/onvif.py b/frigate/ptz/onvif.py index a7a2cd68b..c4f0fbc01 100644 --- a/frigate/ptz/onvif.py +++ b/frigate/ptz/onvif.py @@ -151,7 +151,10 @@ class OnvifController: # autoracking relative panning/tilting needs a relative zoom value set to 0 # if camera supports relative movement - if self.config.cameras[camera_name].onvif.autotracking.zooming: + if ( + self.config.cameras[camera_name].onvif.autotracking.zooming + != ZoomingModeEnum.disabled + ): zoom_space_id = next( ( i @@ -182,23 +185,21 @@ class OnvifController: try: if ( self.config.cameras[camera_name].onvif.autotracking.zooming - == ZoomingModeEnum.relative + != ZoomingModeEnum.disabled ): if zoom_space_id is not None: move_request.Translation.Zoom.space = ptz_config["Spaces"][ "RelativeZoomTranslationSpace" - ][0]["URI"] + ][zoom_space_id]["URI"] + else: + move_request.Translation.Zoom = [] except Exception: - if ( - self.config.cameras[camera_name].onvif.autotracking.zooming - == ZoomingModeEnum.relative - ): - self.config.cameras[ - camera_name - ].onvif.autotracking.zooming = ZoomingModeEnum.disabled - logger.warning( - f"Disabling autotracking zooming for {camera_name}: Relative zoom not supported" - ) + self.config.cameras[ + camera_name + ].onvif.autotracking.zooming = ZoomingModeEnum.disabled + logger.warning( + f"Disabling autotracking zooming for {camera_name}: Relative zoom not supported" + ) if move_request.Speed is None: move_request.Speed = configs.DefaultPTZSpeed if configs else None @@ -387,7 +388,11 @@ class OnvifController: move_request.Translation.PanTilt.x = pan move_request.Translation.PanTilt.y = tilt - if "zoom-r" in self.cams[camera_name]["features"]: + if ( + "zoom-r" in self.cams[camera_name]["features"] + and self.config.cameras[camera_name].onvif.autotracking.zooming + == ZoomingModeEnum.relative + ): move_request.Speed = { "PanTilt": { "x": speed, @@ -403,7 +408,11 @@ class OnvifController: move_request.Translation.PanTilt.x = 0 move_request.Translation.PanTilt.y = 0 - if "zoom-r" in self.cams[camera_name]["features"]: + if ( + "zoom-r" in self.cams[camera_name]["features"] + and self.config.cameras[camera_name].onvif.autotracking.zooming + == ZoomingModeEnum.relative + ): move_request.Translation.Zoom.x = 0 self.cams[camera_name]["active"] = False From 42bf6141314baa176d02a5ebbf57d08513666399 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 16 Feb 2024 07:43:46 -0700 Subject: [PATCH 2/4] Fix birdseye camera comparison (#9887) --- frigate/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frigate/output.py b/frigate/output.py index 465c07786..33596f500 100644 --- a/frigate/output.py +++ b/frigate/output.py @@ -445,7 +445,7 @@ class BirdsEyeFrameManager: if len(self.active_cameras) - len(active_cameras) == 0: if ( len(self.active_cameras) == 1 - and self.active_cameras[0] == active_cameras[0] + and self.active_cameras != active_cameras ): reset_layout = True elif max_camera_refresh: From 6476f8ade78a337be2244ead486d68e6d6365807 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 16 Feb 2024 08:35:21 -0700 Subject: [PATCH 3/4] Format (#9889) --- frigate/output.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frigate/output.py b/frigate/output.py index 33596f500..91899ef46 100644 --- a/frigate/output.py +++ b/frigate/output.py @@ -443,10 +443,7 @@ class BirdsEyeFrameManager: # check if we need to reset the layout because there is a different number of cameras if len(self.active_cameras) - len(active_cameras) == 0: - if ( - len(self.active_cameras) == 1 - and self.active_cameras != active_cameras - ): + if len(self.active_cameras) == 1 and self.active_cameras != active_cameras: reset_layout = True elif max_camera_refresh: reset_layout = True From 0dade98bf3c74d25eaa6438503179b4457be1f25 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Fri, 23 Feb 2024 19:23:03 -0600 Subject: [PATCH 4/4] use first onvif profile with ptz config --- frigate/ptz/onvif.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frigate/ptz/onvif.py b/frigate/ptz/onvif.py index c4f0fbc01..4b18558e2 100644 --- a/frigate/ptz/onvif.py +++ b/frigate/ptz/onvif.py @@ -92,6 +92,9 @@ class OnvifController: if ( onvif_profile.VideoEncoderConfiguration and onvif_profile.VideoEncoderConfiguration.Encoding == "H264" + and onvif_profile.PTZConfiguration + and onvif_profile.PTZConfiguration.DefaultContinuousPanTiltVelocitySpace + is not None ): profile = onvif_profile logger.debug(f"Selected Onvif profile for {camera_name}: {profile}")