catch onvif zooming errors

This commit is contained in:
Josh Hawkins 2023-09-03 18:06:19 -05:00
parent 2eb474b437
commit 6ae9faf5a8

View File

@ -94,6 +94,7 @@ class OnvifController:
None, None,
) )
# autoracking relative panning/tilting needs a relative zoom value set to 0
if self.config.cameras[camera_name].onvif.autotracking.zooming: if self.config.cameras[camera_name].onvif.autotracking.zooming:
zoom_space_id = next( zoom_space_id = next(
( (
@ -122,6 +123,7 @@ class OnvifController:
"RelativePanTiltTranslationSpace" "RelativePanTiltTranslationSpace"
][fov_space_id]["URI"] ][fov_space_id]["URI"]
# try setting relative zoom translation space
try: try:
if self.config.cameras[camera_name].onvif.autotracking.zooming: if self.config.cameras[camera_name].onvif.autotracking.zooming:
if zoom_space_id is not None: if zoom_space_id is not None:
@ -129,11 +131,6 @@ class OnvifController:
"RelativeZoomTranslationSpace" "RelativeZoomTranslationSpace"
][0]["URI"] ][0]["URI"]
except Exception: except Exception:
# camera does not support relative zoom
self.config.cameras[camera_name].onvif.autotracking.zooming = False
logger.warning(
f"Disabling autotracking zooming for {camera_name}: Relative zoom not supported"
)
pass pass
if move_request.Speed is None: if move_request.Speed is None:
@ -176,13 +173,23 @@ class OnvifController:
if ptz_config.Spaces and ptz_config.Spaces.RelativeZoomTranslationSpace: if ptz_config.Spaces and ptz_config.Spaces.RelativeZoomTranslationSpace:
supported_features.append("zoom-r") supported_features.append("zoom-r")
# autotracker uses absolute zooming
if ptz_config.Spaces and ptz_config.Spaces.AbsoluteZoomPositionSpace: if ptz_config.Spaces and ptz_config.Spaces.AbsoluteZoomPositionSpace:
supported_features.append("zoom-a") supported_features.append("zoom-a")
try:
# get camera's zoom limits from onvif config
self.cams[camera_name][ self.cams[camera_name][
"absolute_zoom_range" "absolute_zoom_range"
] = ptz_config.Spaces.AbsoluteZoomPositionSpace[0] ] = ptz_config.Spaces.AbsoluteZoomPositionSpace[0]
self.cams[camera_name]["zoom_limits"] = configs.ZoomLimits self.cams[camera_name]["zoom_limits"] = configs.ZoomLimits
except Exception:
if self.config.cameras[camera_name].onvif.autotracking.zooming:
self.config.cameras[camera_name].onvif.autotracking.zooming = False
logger.warning(
f"Disabling autotracking zooming for {camera_name}: Absolute zoom not supported"
)
# set relative pan/tilt space for autotracker
if fov_space_id is not None: if fov_space_id is not None:
supported_features.append("pt-r-fov") supported_features.append("pt-r-fov")
self.cams[camera_name][ self.cams[camera_name][