You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importcv2fromonvifimportONVIFCameraip='ip'username='username'password='password'port_rtsp='port_rtsp'cam=ONVIFCamera(ip, port, username, password, wsdl_dir=r'python-onvif-zeep/wsdl')
media=cam.create_media_service()
ptz=cam.create_ptz_service()
media_profile=media.GetProfiles()[0]
defmake_rtsp(ip, port, username, password):
return'rtsp_link'rtsp=make_rtsp(ip, port_rtsp, username, password)
# Open the video filecap=cv2.VideoCapture(rtsp)
request=ptz.create_type("GetConfigurationOptions")
request.ConfigurationToken=media_profile.PTZConfiguration.tokenptz_configuration_options=ptz.GetConfigurationOptions(request)
relative_move_request=ptz.create_type("RelativeMove")
relative_move_request.ProfileToken=media_profile.tokenrelative_move_request.Speed= {'PanTilt': {'x': 0, 'y': 0}}
# Loop through the video frameswhilecap.isOpened():
# Read a frame from the videosuccess, frame=cap.read()
ifsuccess:
cv2.imshow('camera', frame)
pan_offset=0.001tilt_offset=0.001zoom_offset=0relative_move_request.Translation= {"PanTilt": {"x": pan_offset, # 0.01 * abs_zoom"y": tilt_offset}, # 0.01 * abs_zoom"Zoom": zoom_offset}
relative_move_request.Speed= {'PanTilt': {'x': 0, 'y': 0}}
ptz.RelativeMove(relative_move_request)
ifcv2.waitKey(1) &0xFF==ord("q"):
breakelse:
# Break the loop if the end of the video is reachedbreak# Release the video capture object and close the display windowcap.release()
cv2.destroyAllWindows()
The frames displayed on the screen via OpenCV are transmitted with a delay relative to the actual frames from the PTZ camera
The text was updated successfully, but these errors were encountered:
The frames displayed on the screen via OpenCV are transmitted with a delay relative to the actual frames from the PTZ camera
The text was updated successfully, but these errors were encountered: