Skip to content

Commit

Permalink
support for recalc focus
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic committed Jan 21, 2025
1 parent 8e92a0a commit 4e777a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 8 additions & 6 deletions axis-ptz-controller/axis_ptz_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,14 @@ def _config_callback(
self.camera.update_zoom(config["zoom"])
if "focus" in config:
self.camera.focus = config["focus"]
if "focus_min" in config:
self.camera.focus_min = config["focus_min"]
if "focus_max" in config:
self.camera.focus_max = config["focus_max"]
if "hyperfocal_distance" in config:
self.camera.hyperfocal_distance = config["hyperfocal_distance"]
if "focus_min" in config or "focus_max" in config or "hyperfocal_distance" in config:
if "focus_min" in config:
self.camera.focus_min = config["focus_min"]
if "focus_max" in config:
self.camera.focus_max = config["focus_max"]
if "hyperfocal_distance" in config:
self.camera.hyperfocal_distance = config["hyperfocal_distance"]
self.camera.recalculate_focus()
if "auto_focus" in config:
self.camera.auto_focus = config["auto_focus"]
if "use_camera" in config:
Expand Down
3 changes: 3 additions & 0 deletions axis-ptz-controller/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def update_tripod_position(
) = axis_ptz_utilities.compute_E_XYZ_to_ENz(
self.tripod_longitude, self.tripod_latitude
)
def recalculate_focus(self) -> None:
self.focus_slope = (self.focus_min - self.focus_max) / self.hyperfocal_distance
self.focus_intercept = self.focus_max

def update_tripod_orientation(
self, tripod_yaw: float, tripod_pitch: float, tripod_roll: float
Expand Down

0 comments on commit 4e777a5

Please sign in to comment.