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"))
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
Error Image