Skip to content

Commit 058380f

Browse files
authored
feature: add get zoom/focus, discrete set zoom/focus commands, and get/set autofocus (#89)
* zoom and focus commands * get and set autofocus * fix SetAutoFocus api call * update readme
1 parent 53e053b commit 058380f

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ GET:
109109
- [X] User -> Manage User
110110
- [X] Device -> HDD/SD Card
111111
- [x] PTZ -> Presets, Calibration Status
112-
- [ ] Zoom
113-
- [ ] Focus
112+
- [x] Zoom
113+
- [x] Focus
114114
- [ ] Image (Brightness, Contrast, Saturation, Hue, Sharp, Mirror, Rotate)
115115
- [ ] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR)
116116
- [X] Image Data -> "Snap" Frame from Video Stream
@@ -152,6 +152,7 @@ do not work and is not supported here.
152152
- RLC-410-5MP
153153
- RLC-510A
154154
- RLC-520
155+
- RLC-823A
155156
- C1-Pro
156157
- D400
157158
- E1 Zoom

reolinkapi/mixins/zoom.py

+25
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ def _stop_zooming_or_focusing(self) -> Dict:
1616
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": "Stop"}}]
1717
return self._execute_command('PtzCtrl', data)
1818

19+
def get_zoom_focus(self) -> Dict:
20+
"""This command returns the current zoom and focus values."""
21+
data = [{"cmd": "GetZoomFocus", "action": 0, "param": {"channel": 0}}]
22+
return self._execute_command('GetZoomFocus', data)
23+
24+
def start_zoom_pos(self, position: float) -> Dict:
25+
"""This command sets the zoom position."""
26+
data = [{"cmd": "StartZoomFocus", "action": 0, "param": {"ZoomFocus": {"channel": 0, "op": "ZoomPos", "pos": position}}}]
27+
return self._execute_command('StartZoomFocus', data)
28+
29+
def start_focus_pos(self, position: float) -> Dict:
30+
"""This command sets the focus position."""
31+
data = [{"cmd": "StartZoomFocus", "action": 0, "param": {"ZoomFocus": {"channel": 0, "op": "FocusPos", "pos": position}}}]
32+
return self._execute_command('StartZoomFocus', data)
33+
34+
def get_auto_focus(self) -> Dict:
35+
"""This command returns the current auto focus status."""
36+
data = [{"cmd": "GetAutoFocus", "action": 0, "param": {"channel": 0}}]
37+
return self._execute_command('GetAutoFocus', data)
38+
39+
def set_auto_focus(self, disable: bool) -> Dict:
40+
"""This command sets the auto focus status."""
41+
data = [{"cmd": "SetAutoFocus", "action": 0, "param": {"AutoFocus": {"channel": 0, "disable": 1 if disable else 0}}}]
42+
return self._execute_command('SetAutoFocus', data)
43+
1944
def start_zooming_in(self, speed: float = 60) -> Dict:
2045
"""
2146
The camera zooms in until self.stop_zooming() is called.

0 commit comments

Comments
 (0)