Merge pull request #13 from burrscurr/master
Implement calls for zooming and focusing
This commit is contained in:
3
Pipfile
3
Pipfile
@@ -9,5 +9,8 @@ verify_ssl = true
|
|||||||
pillow = "*"
|
pillow = "*"
|
||||||
pyyaml = "*"
|
pyyaml = "*"
|
||||||
requests = "*"
|
requests = "*"
|
||||||
|
numpy = "*"
|
||||||
|
opencv-python = "*"
|
||||||
|
pysocks = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
|
|||||||
75
Pipfile.lock
generated
75
Pipfile.lock
generated
@@ -1,12 +1,10 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "0016c39167fc595718fc98862c09aecb3938149a1ff375707052007de7c2ad6f"
|
"sha256": "6700bce6ed08db166eff9d3105158923ffd2ffbf35c814a4d0133552bda03b5a"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {},
|
||||||
"python_version": "3.7"
|
|
||||||
},
|
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"name": "pypi",
|
"name": "pypi",
|
||||||
@@ -37,6 +35,66 @@
|
|||||||
],
|
],
|
||||||
"version": "==2.9"
|
"version": "==2.9"
|
||||||
},
|
},
|
||||||
|
"numpy": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:1786a08236f2c92ae0e70423c45e1e62788ed33028f94ca99c4df03f5be6b3c6",
|
||||||
|
"sha256:17aa7a81fe7599a10f2b7d95856dc5cf84a4eefa45bc96123cbbc3ebc568994e",
|
||||||
|
"sha256:20b26aaa5b3da029942cdcce719b363dbe58696ad182aff0e5dcb1687ec946dc",
|
||||||
|
"sha256:2d75908ab3ced4223ccba595b48e538afa5ecc37405923d1fea6906d7c3a50bc",
|
||||||
|
"sha256:39d2c685af15d3ce682c99ce5925cc66efc824652e10990d2462dfe9b8918c6a",
|
||||||
|
"sha256:56bc8ded6fcd9adea90f65377438f9fea8c05fcf7c5ba766bef258d0da1554aa",
|
||||||
|
"sha256:590355aeade1a2eaba17617c19edccb7db8d78760175256e3cf94590a1a964f3",
|
||||||
|
"sha256:70a840a26f4e61defa7bdf811d7498a284ced303dfbc35acb7be12a39b2aa121",
|
||||||
|
"sha256:77c3bfe65d8560487052ad55c6998a04b654c2fbc36d546aef2b2e511e760971",
|
||||||
|
"sha256:9537eecf179f566fd1c160a2e912ca0b8e02d773af0a7a1120ad4f7507cd0d26",
|
||||||
|
"sha256:9acdf933c1fd263c513a2df3dceecea6f3ff4419d80bf238510976bf9bcb26cd",
|
||||||
|
"sha256:ae0975f42ab1f28364dcda3dde3cf6c1ddab3e1d4b2909da0cb0191fa9ca0480",
|
||||||
|
"sha256:b3af02ecc999c8003e538e60c89a2b37646b39b688d4e44d7373e11c2debabec",
|
||||||
|
"sha256:b6ff59cee96b454516e47e7721098e6ceebef435e3e21ac2d6c3b8b02628eb77",
|
||||||
|
"sha256:b765ed3930b92812aa698a455847141869ef755a87e099fddd4ccf9d81fffb57",
|
||||||
|
"sha256:c98c5ffd7d41611407a1103ae11c8b634ad6a43606eca3e2a5a269e5d6e8eb07",
|
||||||
|
"sha256:cf7eb6b1025d3e169989416b1adcd676624c2dbed9e3bcb7137f51bfc8cc2572",
|
||||||
|
"sha256:d92350c22b150c1cae7ebb0ee8b5670cc84848f6359cf6b5d8f86617098a9b73",
|
||||||
|
"sha256:e422c3152921cece8b6a2fb6b0b4d73b6579bd20ae075e7d15143e711f3ca2ca",
|
||||||
|
"sha256:e840f552a509e3380b0f0ec977e8124d0dc34dc0e68289ca28f4d7c1d0d79474",
|
||||||
|
"sha256:f3d0a94ad151870978fb93538e95411c83899c9dc63e6fb65542f769568ecfa5"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.18.1"
|
||||||
|
},
|
||||||
|
"opencv-python": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:0f2e739c582e8c5e432130648bc6d66a56bc65f4cd9ff0bc7033033d2130c7a3",
|
||||||
|
"sha256:0f3d159ad6cb9cbd188c726f87485f0799a067a0a15f34c25d7b5c8db3cb2e50",
|
||||||
|
"sha256:167a6aff9bd124a3a67e0ec25d0da5ecdc8d96a56405e3e5e7d586c4105eb1bb",
|
||||||
|
"sha256:1b90d50bc7a31e9573a8da1b80fcd1e4d9c86c0e5f76387858e1b87eb8b0332b",
|
||||||
|
"sha256:2baf1213ae2fd678991f905d7b2b94eddfdfb5f75757db0f0b31eebd48ca200d",
|
||||||
|
"sha256:312dda54c7e809c20d7409418060ae0e9cdbe82975e7ced429eb3c234ffc0d4a",
|
||||||
|
"sha256:32384e675f7cefe707cac40a95eeb142d6869065e39c5500374116297cd8ca6d",
|
||||||
|
"sha256:5c50634dd8f2f866fd99fd939292ce10e52bef82804ebc4e7f915221c3b7e951",
|
||||||
|
"sha256:6841bb9cc24751dbdf94e7eefc4e6d70ec297952501954471299fd12ab67391c",
|
||||||
|
"sha256:68c1c846dd267cd7e293d3fc0bb238db0a744aa1f2e721e327598f00cb982098",
|
||||||
|
"sha256:703910aaa1dcd25a412f78a190fb7a352d9a64ee7d9a35566d786f3cc66ebf20",
|
||||||
|
"sha256:8002959146ed21959e3118c60c8e94ceac02eea15b691da6c62cff4787c63f7f",
|
||||||
|
"sha256:889eef049d38488b5b4646c48a831feed37c0fd44f3d83c05cff80f4baded145",
|
||||||
|
"sha256:8c76983c9ec3e4cf3a4c1d172ec4285332d9fb1c7194d724aff0c518437471ee",
|
||||||
|
"sha256:9cd9bd72f4a9743ef6f11f0f96784bd215a542e996db1717d4c2d3d03eb81a1b",
|
||||||
|
"sha256:a1a5517301dc8d56243a14253d231ec755b94486b4fff2ae68269bc941bb1f2e",
|
||||||
|
"sha256:a2b08aec2eacae868723136383d9eb84a33062a7a7ec5ec3bd2c423bd1355946",
|
||||||
|
"sha256:a8529a79233f3581a66984acd16bce52ab0163f6f77568dd69e9ee4956d2e1db",
|
||||||
|
"sha256:afbc81a3870739610a9f9a1197374d6a45892cf1933c90fc5617d39790991ed3",
|
||||||
|
"sha256:baeb5dd8b21c718580687f5b4efd03f8139b1c56239cdf6b9805c6946e80f268",
|
||||||
|
"sha256:db1d49b753e6e6c76585f21d09c7e9812176732baa9bddb64bc2fc6cd24d4179",
|
||||||
|
"sha256:e242ed419aeb2488e0f9ee6410a34917f0f8d62b3ae96aa3170d83bae75004e2",
|
||||||
|
"sha256:e36a8857be2c849e54009f1bee25e8c34fbc683fcd38c6c700af4cba5f8d57c2",
|
||||||
|
"sha256:e699232fd033ef0053efec2cba0a7505514f374ba7b18c732a77cb5304311ef9",
|
||||||
|
"sha256:eae3da9231d87980f8082d181c276a04f7a6fdac130cebd467390b96dd05f944",
|
||||||
|
"sha256:ee6814c94dbf1cae569302afef9dd29efafc52373e8770ded0db549a3b6e0c00",
|
||||||
|
"sha256:f01a87a015227d8af407161eb48222fc3c8b01661cdc841e2b86eee4f1a7a417"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==4.2.0.32"
|
||||||
|
},
|
||||||
"pillow": {
|
"pillow": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:0a628977ac2e01ca96aaae247ec2bd38e729631ddf2221b4b715446fd45505be",
|
"sha256:0a628977ac2e01ca96aaae247ec2bd38e729631ddf2221b4b715446fd45505be",
|
||||||
@@ -65,6 +123,15 @@
|
|||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==7.0.0"
|
"version": "==7.0.0"
|
||||||
},
|
},
|
||||||
|
"pysocks": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299",
|
||||||
|
"sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5",
|
||||||
|
"sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.7.1"
|
||||||
|
},
|
||||||
"pyyaml": {
|
"pyyaml": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:059b2ee3194d718896c0ad077dd8c043e5e909d9180f387ce42012662a4946d6",
|
"sha256:059b2ee3194d718896c0ad077dd8c043e5e909d9180f387ce42012662a4946d6",
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ SET:
|
|||||||
- [ ] User -> Add User
|
- [ ] User -> Add User
|
||||||
- [ ] User -> Manage User
|
- [ ] User -> Manage User
|
||||||
- [ ] Device -> HDD/SD Card
|
- [ ] Device -> HDD/SD Card
|
||||||
- [ ] Zoom
|
- [x] Zoom
|
||||||
- [ ] Focus
|
- [x] Focus
|
||||||
- [ ] Image (Brightness, Contrass, Saturation, Hue, Sharp, Mirror, Rotate)
|
- [ ] Image (Brightness, Contrass, Saturation, Hue, Sharp, Mirror, Rotate)
|
||||||
- [ ] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR)
|
- [ ] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from api.recording import RecordingAPIMixin
|
from .recording import RecordingAPIMixin
|
||||||
|
from .zoom import ZoomAPIMixin
|
||||||
from .device import DeviceAPIMixin
|
from .device import DeviceAPIMixin
|
||||||
from .display import DisplayAPIMixin
|
from .display import DisplayAPIMixin
|
||||||
from .network import NetworkAPIMixin
|
from .network import NetworkAPIMixin
|
||||||
@@ -12,7 +13,8 @@ class APIHandler(SystemAPIMixin,
|
|||||||
UserAPIMixin,
|
UserAPIMixin,
|
||||||
DeviceAPIMixin,
|
DeviceAPIMixin,
|
||||||
DisplayAPIMixin,
|
DisplayAPIMixin,
|
||||||
RecordingAPIMixin):
|
RecordingAPIMixin,
|
||||||
|
ZoomAPIMixin):
|
||||||
"""
|
"""
|
||||||
The APIHandler class is the backend part of the API, the actual API calls
|
The APIHandler class is the backend part of the API, the actual API calls
|
||||||
are implemented in Mixins.
|
are implemented in Mixins.
|
||||||
|
|||||||
56
api/zoom.py
Normal file
56
api/zoom.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
class ZoomAPIMixin:
|
||||||
|
"""
|
||||||
|
API for zooming and changing focus.
|
||||||
|
Note that the API does not allow zooming/focusing by absolute
|
||||||
|
values rather that changing focus/zoom for a given time.
|
||||||
|
"""
|
||||||
|
def _start_operation(self, operation, speed):
|
||||||
|
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": operation, "speed": speed}}]
|
||||||
|
return self._execute_command('PtzCtrl', data)
|
||||||
|
|
||||||
|
def _stop_zooming_or_focusing(self):
|
||||||
|
"""This command stops any ongoing zooming or focusing actions."""
|
||||||
|
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": "Stop"}}]
|
||||||
|
return self._execute_command('PtzCtrl', data)
|
||||||
|
|
||||||
|
def start_zooming_in(self, speed=60):
|
||||||
|
"""
|
||||||
|
The camera zooms in until self.stop_zooming() is called.
|
||||||
|
:return: response json
|
||||||
|
"""
|
||||||
|
return self._start_operation('ZoomInc', speed=speed)
|
||||||
|
|
||||||
|
def start_zooming_out(self, speed=60):
|
||||||
|
"""
|
||||||
|
The camera zooms out until self.stop_zooming() is called.
|
||||||
|
:return: response json
|
||||||
|
"""
|
||||||
|
return self._start_operation('ZoomDec', speed=speed)
|
||||||
|
|
||||||
|
def stop_zooming(self):
|
||||||
|
"""
|
||||||
|
Stop zooming.
|
||||||
|
:return: response json
|
||||||
|
"""
|
||||||
|
return self._stop_zooming_or_focusing()
|
||||||
|
|
||||||
|
def start_focusing_in(self, speed=32):
|
||||||
|
"""
|
||||||
|
The camera focuses in until self.stop_focusing() is called.
|
||||||
|
:return: response json
|
||||||
|
"""
|
||||||
|
return self._start_operation('FocusInc', speed=speed)
|
||||||
|
|
||||||
|
def start_focusing_out(self, speed=32):
|
||||||
|
"""
|
||||||
|
The camera focuses out until self.stop_focusing() is called.
|
||||||
|
:return: response json
|
||||||
|
"""
|
||||||
|
return self._start_operation('FocusDec', speed=speed)
|
||||||
|
|
||||||
|
def stop_focusing(self):
|
||||||
|
"""
|
||||||
|
Stop focusing.
|
||||||
|
:return: response json
|
||||||
|
"""
|
||||||
|
return self._stop_zooming_or_focusing()
|
||||||
Reference in New Issue
Block a user