使用cv2.VideoCapture()从IP摄像机读取流 [英] Reading stream from IP camera with cv2.VideoCapture()

查看:3417
本文介绍了使用cv2.VideoCapture()从IP摄像机读取流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

引用此类似问题如何解析mjpeg http流通过IP摄像机?通过使用requests,我可以从IP摄像机读取流:

Referring to this similar question How to parse mjpeg http stream from ip camera? I was able to read the stream from IP camera, by using requests:

stream = requests.get('http://<user>:<pass>@<addr>:<port>/videostream.cgi', stream=True)

bytez = ''
while True:
    bytez += stream.raw.read(16384)
    ...

效果很好,但想通过使用cv2.VideoCapture()代替它到达目的地.

and it works beautifully, but would like to get there by using cv2.VideoCapture() instead requests.

我尝试了以下几种方式:

I tried variations in a manner of:

cap = cv2.VideoCapture()
cap.open('http://<user>:<pass>@<addr>:<port>/videostream.cgi?.mjpg')

while(True):
    ret, frame = cap.read()
    ...

但是什么也没得到,但是关于空框架的异常.

but wasn't able to get anything, but Exception about empty frame.

如何使用cv2.VideoCapture()读取IP摄像机流?

How to read IP camera stream with cv2.VideoCapture()?

推荐答案

将C:\ OpenCV \ 3rdparty \ ffmpeg \添加到Windows PATH环境变量,或将opencv_ffmpeg.dll从该目录复制到C:\ Python27. OpenCV 2.4 VideoCapture无法在Windows上运行

Add C:\OpenCV\3rdparty\ffmpeg\ to the Windows PATH environment variable or copy opencv_ffmpeg.dll from that directory to C:\Python27. This has been answered in this question OpenCV 2.4 VideoCapture not working on Windows

这篇关于使用cv2.VideoCapture()从IP摄像机读取流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆