python+opencv 打开网络摄像头

时间:2021-01-12 21:10:33

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()

注:可以下在ip摄像头App查看
原文链接:https://blog.csdn.net/weixin_33595571/article/details/84351476?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-6.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-6.channel_param