FalkTannhaeuser / python-onvif-zeep

ONVIF Client Implementation in Python 2+3 (using https://github.com/mvantellingen/python-zeep instead of suds as SOAP client)
MIT License
428 stars 140 forks source link

Issue with create_type() from ONVIFCamera().create_ptz_service() #11

Open Guilmort opened 6 years ago

Guilmort commented 6 years ago

Hello

My Python version is 3.5.3. I followed the guide for installation.

The issue is :

mycam=ONVIFCamera("192.168.5.6",888,"admin","*******","/home/guilmort/ONVIF/python-onvif-zeep/wsdl/")
ptz=mycam.create_ptz_service()
media = mycam.create_media_service()
media_profile = media.GetProfiles()[0]
token=media_profile.token
request=ptz.create_type('ContinuousMove')
request.ProfileToken=token
request.Velocity.Zoom.x=-1.0   ---------------> AttributeError: 'NoneType' object has no attribute 'Zoom'

However when I do

request.Velocity={'Zoom':{'x':-1.0}}

Then it works.

jmiguel99 commented 5 years ago

Another solution I found was this, you need to add the parameters from the status that you get from the ptz profile.

status = self.ptz.GetStatus({'ProfileToken': self.media_profile.token}) status.Position.PanTilt.x = 0.0 status.Position.PanTilt.y = velocity self.requestc.Velocity = status.Position self.perform_move(timeout)

So basically, you need to get the ptz status from the camera, and change the parameters of the position, then add the status.position parameters to the velocity one that is inside the request. As it has created the objects, you can modify them and then add then to the request, or add the status.Position to the request and then modify them. This is working for me in a continuous movement, but also works for absolute movement if the camera is compatible with it.