使用 OpenCV python 捕获 rtsp 相机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40875846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
capturing rtsp camera using OpenCV python
提问by Nik391
I have a remote camera streaming through rtsp protocol and am trying to access it in OpenCV 2.13.1 using python with following code.
我有一个通过 rtsp 协议传输的远程摄像头,并尝试使用带有以下代码的 python 在 OpenCV 2.13.1 中访问它。
camera = cv2.VideoCapture("rtsp://admin:<port>@<ip>/xyz/video.smp")
However, when I do that I get the following warning
但是,当我这样做时,我收到以下警告
WARNING: Couldn't read movie file rtsp://admin:<port>@<ip>/xyz/video.smp
I have also tried doing this:
我也试过这样做:
camera = cv2.VideoCapture.open("rtsp://admin:<port>@<ip>/xyz/video.smp")
but when I do this I get this error:
但是当我这样做时,我收到了这个错误:
`AttributeError: 'builtin_function_or_method' object has no attribute` 'open'
I did searched quite a bit about this problem but couldn't get the idea that works for me. Any help would be appreciated.
我确实对这个问题进行了大量搜索,但无法找到适合我的想法。任何帮助,将不胜感激。
回答by Ryan
Credit from RTSP stream and OpenCV (Python):
来自RTSP 流和 OpenCV (Python) 的信用:
vcap = cv.VideoCapture("rtsp://192.168.1.2:8080/out.h264")
while(1):
ret, frame = vcap.read()
cv.imshow('VIDEO', frame)
cv.waitKey(1)