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
433 stars 144 forks source link

how to get absulte value for ptz? #68

Open tms2003 opened 4 years ago

tms2003 commented 4 years ago

how to get absulte value for ptz? I found locate absulately value in samples,but I can't get ptz value,so ,please help me!

asterissco commented 3 years ago

With this, but you need one media profile token

mycam = ONVIFCamera(cameraConfig['ip'], cameraConfig['port'], cameraConfig['onvif_user'], cameraConfig['onvif_pass'], cameraConfig['path_wsdl'])

# instances resources
media                           = mycam.create_media_service()
media_profile                   = media.GetProfiles()[0]
ptz                             = mycam.create_ptz_service()

# set profile token
requestPtzStatus                = ptz.create_type('GetStatus')
requestPtzStatus.ProfileToken   = media_profile.token
status                          = ptz.GetStatus(requestPtzStatus)

# return data from "ptz.GetStatus"
position = { }
position['x']       = status.Position.PanTilt.x
position['y']       = status.Position.PanTilt.y
position['z']       = status.Position.Zoom.x

To create a new media profile token

def createMediaProfile(name,token):

    media                           = mycam.create_media_service()
    newProfile                      = media.create_type('CreateProfile')
    newProfile.Name     = name
    newProfile.Token    = token
    media.CreateProfile(newProfile)