Skip to content

feature: add get zoom/focus, discrete set zoom/focus commands, and get/set autofocus #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading