python+opencv 打开网络摄像头(手机)(转)
#以下是最常用的读取视频流的方法
import cv2
url = 'rtsp://admin:admin@192.169.5.2:554/'#根据摄像头设置IP及rtsp端口 @前面是账号和密码
cap = cv2.VideoCapture(url)#读取视频流
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()