mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-06 19:25:22 +03:00
don't zoom if camera doesn't support it
This commit is contained in:
parent
7c629c1874
commit
144264e760
@ -176,7 +176,7 @@ class PtzAutoTracker:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.onvif.cams[camera_name]["relative_fov_supported"]:
|
if "pt-r-fov" not in self.onvif.cams[camera_name]["features"]:
|
||||||
cam.onvif.autotracking.enabled = False
|
cam.onvif.autotracking.enabled = False
|
||||||
self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = False
|
self.ptz_metrics[camera_name]["ptz_autotracker_enabled"].value = False
|
||||||
logger.warning(
|
logger.warning(
|
||||||
@ -219,7 +219,7 @@ class PtzAutoTracker:
|
|||||||
# on some cameras with cheaper motors it seems like small values can cause jerky movement
|
# on some cameras with cheaper motors it seems like small values can cause jerky movement
|
||||||
# TODO: double check, might not need this
|
# TODO: double check, might not need this
|
||||||
if abs(pan) > 0.02 or abs(tilt) > 0.02:
|
if abs(pan) > 0.02 or abs(tilt) > 0.02:
|
||||||
self.onvif._move_relative(camera, pan, tilt, 1)
|
self.onvif._move_relative(camera, pan, tilt, 0, 1)
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Not moving, pan and tilt too small: {pan}, {tilt}"
|
f"Not moving, pan and tilt too small: {pan}, {tilt}"
|
||||||
|
|||||||
@ -89,6 +89,17 @@ class OnvifController:
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
zoom_space_id = next(
|
||||||
|
(
|
||||||
|
i
|
||||||
|
for i, space in enumerate(
|
||||||
|
ptz_config.Spaces.RelativeZoomTranslationSpace
|
||||||
|
)
|
||||||
|
if "TranslationGenericSpace" in space["URI"]
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
# setup continuous moving request
|
# setup continuous moving request
|
||||||
move_request = ptz.create_type("ContinuousMove")
|
move_request = ptz.create_type("ContinuousMove")
|
||||||
move_request.ProfileToken = profile.token
|
move_request.ProfileToken = profile.token
|
||||||
@ -104,9 +115,10 @@ class OnvifController:
|
|||||||
move_request.Translation.PanTilt.space = ptz_config["Spaces"][
|
move_request.Translation.PanTilt.space = ptz_config["Spaces"][
|
||||||
"RelativePanTiltTranslationSpace"
|
"RelativePanTiltTranslationSpace"
|
||||||
][fov_space_id]["URI"]
|
][fov_space_id]["URI"]
|
||||||
move_request.Translation.Zoom.space = ptz_config["Spaces"][
|
if zoom_space_id is not None:
|
||||||
"RelativeZoomTranslationSpace"
|
move_request.Translation.Zoom.space = ptz_config["Spaces"][
|
||||||
][0]["URI"]
|
"RelativeZoomTranslationSpace"
|
||||||
|
][0]["URI"]
|
||||||
if move_request.Speed is None:
|
if move_request.Speed is None:
|
||||||
move_request.Speed = ptz.GetStatus({"ProfileToken": profile.token}).Position
|
move_request.Speed = ptz.GetStatus({"ProfileToken": profile.token}).Position
|
||||||
self.cams[camera_name]["relative_move_request"] = move_request
|
self.cams[camera_name]["relative_move_request"] = move_request
|
||||||
@ -153,8 +165,6 @@ class OnvifController:
|
|||||||
"relative_fov_range"
|
"relative_fov_range"
|
||||||
] = ptz_config.Spaces.RelativePanTiltTranslationSpace[fov_space_id]
|
] = ptz_config.Spaces.RelativePanTiltTranslationSpace[fov_space_id]
|
||||||
|
|
||||||
self.cams[camera_name]["relative_fov_supported"] = fov_space_id is not None
|
|
||||||
|
|
||||||
self.cams[camera_name]["features"] = supported_features
|
self.cams[camera_name]["features"] = supported_features
|
||||||
|
|
||||||
self.cams[camera_name]["init"] = True
|
self.cams[camera_name]["init"] = True
|
||||||
@ -204,8 +214,8 @@ class OnvifController:
|
|||||||
|
|
||||||
onvif.get_service("ptz").ContinuousMove(move_request)
|
onvif.get_service("ptz").ContinuousMove(move_request)
|
||||||
|
|
||||||
def _move_relative(self, camera_name: str, pan, tilt, speed) -> None:
|
def _move_relative(self, camera_name: str, pan, tilt, zoom, speed) -> None:
|
||||||
if not self.cams[camera_name]["relative_fov_supported"]:
|
if "pt-r-fov" not in self.cams[camera_name]["features"]:
|
||||||
logger.error(f"{camera_name} does not support ONVIF RelativeMove (FOV).")
|
logger.error(f"{camera_name} does not support ONVIF RelativeMove (FOV).")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -251,12 +261,14 @@ class OnvifController:
|
|||||||
"x": speed,
|
"x": speed,
|
||||||
"y": speed,
|
"y": speed,
|
||||||
},
|
},
|
||||||
"Zoom": 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
move_request.Translation.PanTilt.x = pan
|
move_request.Translation.PanTilt.x = pan
|
||||||
move_request.Translation.PanTilt.y = tilt
|
move_request.Translation.PanTilt.y = tilt
|
||||||
move_request.Translation.Zoom.x = 0
|
|
||||||
|
if "zoom-r" in self.cams[camera_name]["features"]:
|
||||||
|
move_request.Speed["Zoom"] = 0
|
||||||
|
move_request.Translation.Zoom.x = zoom
|
||||||
|
|
||||||
onvif.get_service("ptz").RelativeMove(move_request)
|
onvif.get_service("ptz").RelativeMove(move_request)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user