Skip to content

Commit aa14b60

Browse files
committed
Add requirement file, docs, updates to complete PTZ
1 parent 9b58499 commit aa14b60

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This project intends to stick with [PEP8](https://www.python.org/dev/peps/pep-00
2525

2626
GET:
2727
- [X] Login
28+
- [X] Logout
2829
- [ ] Display -> OSD
2930
- [ ] Recording -> Encode (Clear and Fluent Stream)
3031
- [ ] Recording -> Advance (Scheduling)
@@ -73,6 +74,7 @@ SET:
7374
- [ ] User -> Add User
7475
- [ ] User -> Manage User
7576
- [ ] Device -> HDD/SD Card
77+
- [x] PTZ
7678
- [x] Zoom
7779
- [x] Focus
7880
- [ ] Image (Brightness, Contrass, Saturation, Hue, Sharp, Mirror, Rotate)

api/APIHandler.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .network import NetworkAPIMixin
66
from .system import SystemAPIMixin
77
from .user import UserAPIMixin
8+
from .ptz import PtzAPIMixin
89
from resthandle import Request
910

1011

@@ -14,7 +15,8 @@ class APIHandler(SystemAPIMixin,
1415
DeviceAPIMixin,
1516
DisplayAPIMixin,
1617
RecordingAPIMixin,
17-
ZoomAPIMixin):
18+
ZoomAPIMixin,
19+
PtzAPIMixin):
1820
"""
1921
The APIHandler class is the backend part of the API, the actual API calls
2022
are implemented in Mixins.
@@ -68,7 +70,21 @@ def login(self) -> bool:
6870
except Exception as e:
6971
print("Error Login\n", e)
7072
raise
71-
73+
74+
def logout(self) -> bool:
75+
"""
76+
Logout of the camera
77+
:return: bool
78+
"""
79+
try:
80+
data = [{"cmd": "Logout", "action": 0}]
81+
ret = self._execute_command('Logout', data)
82+
print(ret)
83+
return True
84+
except Exception as e:
85+
print("Error Logout\n", e)
86+
return False
87+
7288
def _execute_command(self, command, data, multi=False):
7389
"""
7490
Send a POST request to the IP camera with given data.

api/ptz.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,63 +40,63 @@ def remove_preset(self, preset=1, name='pos1'):
4040
"""
4141
return self._send_set_preset('PtzPreset', enable=0, preset=preset, name=name)
4242

43-
def move_right(self, speed=32):
43+
def move_right(self, speed=25):
4444
"""
4545
Move the camera to the right
4646
The camera moves self.stop_ptz() is called.
4747
:return: response json
4848
"""
4949
return self._send_operation('Right', speed=speed)
5050

51-
def move_right_up(self, speed=32):
51+
def move_right_up(self, speed=25):
5252
"""
5353
Move the camera to the right and up
5454
The camera moves self.stop_ptz() is called.
5555
:return: response json
5656
"""
5757
return self._send_operation('RightUp', speed=speed)
5858

59-
def move_right_down(self, speed=32):
59+
def move_right_down(self, speed=25):
6060
"""
6161
Move the camera to the right and down
6262
The camera moves self.stop_ptz() is called.
6363
:return: response json
6464
"""
6565
return self._send_operation('RightDown', speed=speed)
6666

67-
def move_left(self, speed=32):
67+
def move_left(self, speed=25):
6868
"""
6969
Move the camera to the left
7070
The camera moves self.stop_ptz() is called.
7171
:return: response json
7272
"""
7373
return self._send_operation('Left', speed=speed)
7474

75-
def move_left_up(self, speed=32):
75+
def move_left_up(self, speed=25):
7676
"""
7777
Move the camera to the left and up
7878
The camera moves self.stop_ptz() is called.
7979
:return: response json
8080
"""
8181
return self._send_operation('LeftUp', speed=speed)
8282

83-
def move_left_down(self, speed=32):
83+
def move_left_down(self, speed=25):
8484
"""
8585
Move the camera to the left and down
8686
The camera moves self.stop_ptz() is called.
8787
:return: response json
8888
"""
8989
return self._send_operation('LeftDown', speed=speed)
9090

91-
def move_up(self, speed=32):
91+
def move_up(self, speed=25):
9292
"""
9393
Move the camera up.
9494
The camera moves self.stop_ptz() is called.
9595
:return: response json
9696
"""
9797
return self._send_operation('Up', speed=speed)
9898

99-
def move_down(self, speed=32):
99+
def move_down(self, speed=25):
100100
"""
101101
Move the camera down.
102102
The camera moves self.stop_ptz() is called.
@@ -111,7 +111,7 @@ def stop_ptz(self):
111111
"""
112112
return self._send_noparm_operation('Stop')
113113

114-
def auto_movement(self, speed=32):
114+
def auto_movement(self, speed=25):
115115
"""
116116
Move the camera in a clockwise rotation.
117117
The camera moves self.stop_ptz() is called.

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
requests
2+
opencv-python
3+
numpy
4+
socks

0 commit comments

Comments
 (0)