Skip to content

Commit

Permalink
feature: add get zoom/focus, discrete set zoom/focus commands, and ge…
Browse files Browse the repository at this point in the history
…t/set autofocus (#89)

* zoom and focus commands

* get and set autofocus

* fix SetAutoFocus api call

* update readme
  • Loading branch information
stevebriskin authored Jan 23, 2025
1 parent 53e053b commit 058380f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ GET:
- [X] User -> Manage User
- [X] Device -> HDD/SD Card
- [x] PTZ -> Presets, Calibration Status
- [ ] Zoom
- [ ] Focus
- [x] Zoom
- [x] Focus
- [ ] Image (Brightness, Contrast, Saturation, Hue, Sharp, Mirror, Rotate)
- [ ] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR)
- [X] Image Data -> "Snap" Frame from Video Stream
Expand Down Expand Up @@ -152,6 +152,7 @@ do not work and is not supported here.
- RLC-410-5MP
- RLC-510A
- RLC-520
- RLC-823A
- C1-Pro
- D400
- E1 Zoom
Expand Down
25 changes: 25 additions & 0 deletions reolinkapi/mixins/zoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ def _stop_zooming_or_focusing(self) -> Dict:
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": "Stop"}}]
return self._execute_command('PtzCtrl', data)

def get_zoom_focus(self) -> Dict:
"""This command returns the current zoom and focus values."""
data = [{"cmd": "GetZoomFocus", "action": 0, "param": {"channel": 0}}]
return self._execute_command('GetZoomFocus', data)

def start_zoom_pos(self, position: float) -> Dict:
"""This command sets the zoom position."""
data = [{"cmd": "StartZoomFocus", "action": 0, "param": {"ZoomFocus": {"channel": 0, "op": "ZoomPos", "pos": position}}}]
return self._execute_command('StartZoomFocus', data)

def start_focus_pos(self, position: float) -> Dict:
"""This command sets the focus position."""
data = [{"cmd": "StartZoomFocus", "action": 0, "param": {"ZoomFocus": {"channel": 0, "op": "FocusPos", "pos": position}}}]
return self._execute_command('StartZoomFocus', data)

def get_auto_focus(self) -> Dict:
"""This command returns the current auto focus status."""
data = [{"cmd": "GetAutoFocus", "action": 0, "param": {"channel": 0}}]
return self._execute_command('GetAutoFocus', data)

def set_auto_focus(self, disable: bool) -> Dict:
"""This command sets the auto focus status."""
data = [{"cmd": "SetAutoFocus", "action": 0, "param": {"AutoFocus": {"channel": 0, "disable": 1 if disable else 0}}}]
return self._execute_command('SetAutoFocus', data)

def start_zooming_in(self, speed: float = 60) -> Dict:
"""
The camera zooms in until self.stop_zooming() is called.
Expand Down

0 comments on commit 058380f

Please sign in to comment.