Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1b6f20b
Replace SOAP client suds by zeep for Python3 compatibility - first wo…
FalkTannhaeuser Jun 21, 2017
2fa9b69
First version compatible both with Python 2 and 3
FalkTannhaeuser Jun 21, 2017
ac157d5
Update setup files
FalkTannhaeuser Jun 22, 2017
611d1eb
debugging
FalkTannhaeuser Jun 22, 2017
e3550b0
Add caching; debugging (first version working both for getting and se…
FalkTannhaeuser Jun 23, 2017
fece842
Port cli.py to zeep
FalkTannhaeuser Jun 26, 2017
4a298bd
Update tests
FalkTannhaeuser Jun 27, 2017
d2c05e1
Merge upstream changes from quatanium/python-onvif, as far as applicable
FalkTannhaeuser Jun 29, 2017
28a41be
Add reference to Py3 compatible fork to README
Aug 6, 2017
c97cbe7
Update install instructions in README, fixes #2
Aug 6, 2017
b561673
Merge branch (pull request) 'hovissimo-patch-2' into zeep
FalkTannhaeuser Aug 16, 2017
be51e2a
Add explanation about 'pip' command for installation
FalkTannhaeuser Aug 16, 2017
e9ec97f
Fix formatting
FalkTannhaeuser Aug 16, 2017
aa28a4a
Merge pull request #52 from hovissimo/patch-1
sinchb Aug 22, 2017
b623a04
release 0.2.0
sinchb Aug 26, 2017
22f569e
Fix warning: https://github.com/FalkTannhaeuser/python-onvif-zeep/iss…
FalkTannhaeuser Sep 21, 2017
4691372
Fix wsdl target directory for Windows Anaconda and Cygwin Python; upl…
FalkTannhaeuser Sep 22, 2017
9d3c15d
added transport capabilities
lattice0 Oct 22, 2017
5bf8551
added transports support
lattice0 Oct 23, 2017
aa4f031
Merge pull request #10 from lucaszanella/zeep
FalkTannhaeuser Dec 10, 2017
14d9b0a
fix client.py imports for python3
iomihai Jan 23, 2018
a025443
fix events pullpoint service xaddr
iomihai Jan 23, 2018
ea56212
Add HTTPS client support
iomihai Apr 2, 2018
728375f
gitignore Pipfile
iomihai Apr 2, 2018
b4df798
create_pullpoint_service() binding fix
iomihai Apr 3, 2018
beac5f1
Merge pull request #17 from iomihai/zeep
FalkTannhaeuser Apr 9, 2018
d9d8151
Bump version after merging pull request
FalkTannhaeuser Apr 9, 2018
21ae5d3
Fixed client for zeep v3.0.0
dd-alexander Jun 20, 2018
c7e784f
Merge pull request #20 from Brootux/zeep
FalkTannhaeuser Jun 20, 2018
a49e461
Bumped version to 0.2.11 (now requires zeep >= 3.0.0)
FalkTannhaeuser Jun 21, 2018
0d7f847
Allow the use of a time delta parameter between local and camera time.
FalkTannhaeuser Aug 20, 2018
3273b20
Dead code removal
FalkTannhaeuser Aug 20, 2018
1cf4cee
Bump version number
FalkTannhaeuser Aug 20, 2018
a5f3f20
This was not working. Still for Python 2. Made it into a simplistic i…
frawau Nov 8, 2018
1d22a96
Merge pull request #31 from frawau/zeep
FalkTannhaeuser Dec 13, 2018
980b579
added a notification service in order to facilitate requesting a noti…
monocongo Feb 13, 2019
fb5141b
fixed bug where we had the service name as "notifications" (plural) i…
monocongo Feb 13, 2019
de05595
added an additional subscription service to facilitate subscription r…
monocongo Feb 18, 2019
8a18caa
removed the unused `from_template` parameter from the ONVIFCamera.cre…
monocongo Feb 18, 2019
247c5bc
various minor cleanups suggested by PyCharm file inspection (PEP8 com…
monocongo Feb 19, 2019
f737db9
removed unused parameter variable `portType` from the `ONVIFService` …
monocongo Feb 19, 2019
8aba823
Allow services to be created with custom transport
GeertvanHorrik Apr 12, 2019
33f8051
Merge pull request #38 from monocongo/new_service_notifications
FalkTannhaeuser Apr 17, 2019
ed37d16
Merge branch 'zeep' into pr/async-services
FalkTannhaeuser Apr 17, 2019
d549eed
Merge pull request #44 from GeertvanHorrik/pr/async-services
FalkTannhaeuser Apr 17, 2019
5fae485
add the ability to rewrite the address and the port if the camera is …
davidea72 Jun 11, 2019
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: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ docs/_build/

# PyBuilder
target/

.idea
.venv
Pipfile
Pipfile.lock
17 changes: 7 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
python-onvif
python-onvif-zeep
============

ONVIF Client Implementation in Python

Dependencies
------------
`suds <https://pypi.python.org/pypi/suds>`_ >= 0.4
`zeep <http://docs.python-zeep.org>`_ >= 3.0.0

`suds-passworddigest <https://pypi.python.org/pypi/suds_passworddigest>`_

Install python-onvif
--------------------
Install python-onvif-zeep
-------------------------
**From Source**

You should clone this repository and run setup.py::

cd python-onvif && python setup.py install
cd python-onvif-zeep && python setup.py install

**From PyPI**
Alternatively, you can run::

::
pip install --upgrade onvif_zeep

pip install onvif

Getting Started
---------------
Expand Down
175 changes: 124 additions & 51 deletions examples/continuous_move.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,100 @@
from time import sleep

import asyncio, sys
from onvif import ONVIFCamera

IP="192.168.0.100" # Camera IP address
PORT=10080 # Port
USER="admin" # Username
PASS="password" # Password


XMAX = 1
XMIN = -1
YMAX = 1
YMIN = -1
moverequest = None
ptz = None
active = False

def perform_move(ptz, request, timeout):
def do_move(ptz, request):
# Start continuous move
global active
if active:
ptz.Stop({'ProfileToken': request.ProfileToken})
active = True
ptz.ContinuousMove(request)
# Wait a certain time
sleep(timeout)
# Stop continuous move
ptz.Stop({'ProfileToken': request.ProfileToken})

def move_up(ptz, request, timeout=1):
print 'move up...'
request.Velocity.PanTilt._x = 0
request.Velocity.PanTilt._y = YMAX
perform_move(ptz, request, timeout)

def move_down(ptz, request, timeout=1):
print 'move down...'
request.Velocity.PanTilt._x = 0
request.Velocity.PanTilt._y = YMIN
perform_move(ptz, request, timeout)

def move_right(ptz, request, timeout=1):
print 'move right...'
request.Velocity.PanTilt._x = XMAX
request.Velocity.PanTilt._y = 0
perform_move(ptz, request, timeout)

def move_left(ptz, request, timeout=1):
print 'move left...'
request.Velocity.PanTilt._x = XMIN
request.Velocity.PanTilt._y = 0
perform_move(ptz, request, timeout)

def continuous_move():
mycam = ONVIFCamera('192.168.0.112', 80, 'admin', '12345')

def move_up(ptz, request):
print ('move up...')
request.Velocity.PanTilt.x = 0
request.Velocity.PanTilt.y = YMAX
do_move(ptz, request)

def move_down(ptz, request):
print ('move down...')
request.Velocity.PanTilt.x = 0
request.Velocity.PanTilt.y = YMIN
do_move(ptz, request)

def move_right(ptz, request):
print ('move right...')
request.Velocity.PanTilt.x = XMAX
request.Velocity.PanTilt.y = 0
do_move(ptz, request)

def move_left(ptz, request):
print ('move left...')
request.Velocity.PanTilt.x = XMIN
request.Velocity.PanTilt.y = 0
do_move(ptz, request)


def move_upleft(ptz, request):
print ('move up left...')
request.Velocity.PanTilt.x = XMIN
request.Velocity.PanTilt.y = YMAX
do_move(ptz, request)

def move_upright(ptz, request):
print ('move up left...')
request.Velocity.PanTilt.x = XMAX
request.Velocity.PanTilt.y = YMAX
do_move(ptz, request)

def move_downleft(ptz, request):
print ('move down left...')
request.Velocity.PanTilt.x = XMIN
request.Velocity.PanTilt.y = YMIN
do_move(ptz, request)

def move_downright(ptz, request):
print ('move down left...')
request.Velocity.PanTilt.x = XMAX
request.Velocity.PanTilt.y = YMIN
do_move(ptz, request)

def setup_move():
mycam = ONVIFCamera(IP, PORT, USER, PASS)
# Create media service object
media = mycam.create_media_service()

# Create ptz service object
global ptz
ptz = mycam.create_ptz_service()

# Get target profile
media_profile = media.GetProfiles()[0];
media_profile = media.GetProfiles()[0]

# Get PTZ configuration options for getting continuous move range
request = ptz.create_type('GetConfigurationOptions')
request.ConfigurationToken = media_profile.PTZConfiguration._token
request.ConfigurationToken = media_profile.PTZConfiguration.token
ptz_configuration_options = ptz.GetConfigurationOptions(request)

request = ptz.create_type('ContinuousMove')
request.ProfileToken = media_profile._token
global moverequest
moverequest = ptz.create_type('ContinuousMove')
moverequest.ProfileToken = media_profile.token
if moverequest.Velocity is None:
moverequest.Velocity = ptz.GetStatus({'ProfileToken': media_profile.token}).Position

ptz.Stop({'ProfileToken': media_profile._token})

# Get range of pan and tilt
# NOTE: X and Y are velocity vector
Expand All @@ -67,17 +104,53 @@ def continuous_move():
YMAX = ptz_configuration_options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max
YMIN = ptz_configuration_options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Min

# move right
move_right(ptz, request)

# move left
move_left(ptz, request)

# Move up
move_up(ptz, request)

# move down
move_down(ptz, request)

def readin():
"""Reading from stdin and displaying menu"""
global moverequest, ptz

selection = sys.stdin.readline().strip("\n")
lov=[ x for x in selection.split(" ") if x != ""]
if lov:

if lov[0].lower() in ["u","up"]:
move_up(ptz,moverequest)
elif lov[0].lower() in ["d","do","dow","down"]:
move_down(ptz,moverequest)
elif lov[0].lower() in ["l","le","lef","left"]:
move_left(ptz,moverequest)
elif lov[0].lower() in ["l","le","lef","left"]:
move_left(ptz,moverequest)
elif lov[0].lower() in ["r","ri","rig","righ","right"]:
move_right(ptz,moverequest)
elif lov[0].lower() in ["ul"]:
move_upleft(ptz,moverequest)
elif lov[0].lower() in ["ur"]:
move_upright(ptz,moverequest)
elif lov[0].lower() in ["dl"]:
move_downleft(ptz,moverequest)
elif lov[0].lower() in ["dr"]:
move_downright(ptz,moverequest)
elif lov[0].lower() in ["s","st","sto","stop"]:
ptz.Stop({'ProfileToken': moverequest.ProfileToken})
active = False
else:
print("What are you asking?\tI only know, 'up','down','left','right', 'ul' (up left), \n\t\t\t'ur' (up right), 'dl' (down left), 'dr' (down right) and 'stop'")

print("")
print("Your command: ", end='',flush=True)


if __name__ == '__main__':
continuous_move()
setup_move()
loop = asyncio.get_event_loop()
try:
loop.add_reader(sys.stdin,readin)
print("Use Ctrl-C to quit")
print("Your command: ", end='',flush=True)
loop.run_forever()
except:
pass
finally:
loop.remove_reader(sys.stdin)
loop.close()
4 changes: 2 additions & 2 deletions onvif/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from onvif.client import ONVIFService, ONVIFCamera, SERVICES
from onvif.exceptions import ONVIFError, ERR_ONVIF_UNKNOWN, \
ERR_ONVIF_PROTOCOL, ERR_ONVIF_WSDL, ERR_ONVIF_BUILD
from onvif import cli
#from onvif import cli

__all__ = ( 'ONVIFService', 'ONVIFCamera', 'ONVIFError',
'ERR_ONVIF_UNKNOWN', 'ERR_ONVIF_PROTOCOL',
'ERR_ONVIF_WSDL', 'ERR_ONVIF_BUILD',
'SERVICES', 'cli'
'SERVICES'#, 'cli'
)
17 changes: 8 additions & 9 deletions onvif/cli.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/python
'''ONVIF Client Command Line Interface'''

from __future__ import print_function, division
import re
from cmd import Cmd
from ast import literal_eval
from json import dumps
from argparse import ArgumentParser, ArgumentError, REMAINDER
from argparse import ArgumentParser, REMAINDER

from suds import MethodNotFound
from suds.sax.text import Text
from zeep.exceptions import LookupError as MethodNotFound
from zeep.xsd import String as Text
from onvif import ONVIFCamera, ONVIFService, ONVIFError
from definition import SERVICES
from onvif.definition import SERVICES
import os.path

SUPPORTED_SERVICES = SERVICES.keys()
Expand All @@ -21,10 +20,10 @@ def error(self, message):
raise ValueError("%s\n%s" % (message, usage))

def success(message):
print 'True: ' + str(message)
print('True: ' + str(message))

def error(message):
print 'False: ' + str(message)
print('False: ' + str(message))

class ONVIFCLI(Cmd):
prompt = 'ONVIF >>> '
Expand Down Expand Up @@ -151,7 +150,7 @@ def main():
try:
args = parser.parse_args()
except ValueError as err:
print str(err)
print(str(err))
return
# Also need parse configuration file.

Expand Down
Loading