mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 586 forks source link

not connected to PTZ camera #1380

Closed fti-sbargule closed 1 year ago

fti-sbargule commented 1 year ago

OS :- ubuntu 22.04 Lib used :- onvif-zeep-async camera :- Hikvision mini PTZ camera

This code and error i try to connected to ptz camera to control rotation . Code File

from onvif import ONVIFCamera
import asyncio

async def rotate_ptz(camera_ip, username, password):
    # Create an ONVIFCamera object
    mycam = ONVIFCamera(camera_ip, 80, username, password)
    await mycam.update_xaddrs()
    # Get the PTZ service
    ptz_service = mycam.create_ptz_service()

    # Get the media service
    media_service = mycam.create_media_service()

    # Get the main video source token
    media_profile = await media_service.GetProfiles()
    video_source_token = media_profile.VideoSourceConfiguration.Source

    # Create a request for continuous move
    request = ptz_service.create_type('ContinuousMove')
    request.ProfileToken = media_profile.token

    # Set the velocity for pan and tilt
    request.Velocity = ptz_service.get_type('PTZSpeed')
    request.Velocity.PanTilt.x = 1.0  # Pan velocity
    request.Velocity.PanTilt.y = 0.0  # Tilt velocity

    # Start the continuous move
    await ptz_service.ContinuousMove(request)

    # Wait for some time to allow the rotation to happen (e.g., 5 seco
    await asyncio.sleep(5)

    # Stop the continuous move
    await ptz_service.Stop({'ProfileToken': media_profile.token})

    # Close the camera connection
    mycam.close()

# Call the function with the appropriate parameters

asyncio.run(rotate_ptz("192.168.10.35", "admin", "selfstyle!2012"))

Error Image

Screenshot from 2023-06-20 14-40-45

fti-sbargule commented 1 year ago

Enable ONVIF setting