cv :: VideoCapture适用于网络摄像头,但不适用于IP摄像机? [英] cv::VideoCapture works for webcams but not IP cameras?
问题描述
这是必须发生的,当我想使用自己的代码时,我陷入了项目的最后阶段,就像在网络摄像头,IP摄像机上一样,它的工作原理很迷人.该URL在我的浏览器中可以正常运行,但是OpenCV没有任何显示... 这是我的代码:
It had to happen, I'm stuck in the last phase of my project, when I want to use my code which works like a charm on my webcam, on an IP camera. The URL works perfectly in my browser, but nothing comes out with OpenCV... Here is my code:
#include <opencv/highgui.h>
using namespace cv;
int main(int argc, char *argv[])
{
Mat frame;
namedWindow("video", 1);
VideoCapture cap("http://192.168.1.99:99/videostream.cgi?resolution=32&rate=0&user=admin&pwd=password&.mjpg");
while ( cap.isOpened() )
{
cap >> frame;
if(frame.empty()) break;
imshow("video", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}
以及编译器设置:
//Added to the .pro file of QtCreator
INCLUDEPATH += C:\\OpenCV243\\release\\include
LIBS += -LC:\\OpenCV243\\release\\lib \
-lopencv_core243.dll \
-lopencv_highgui243.dll
我已经测试过使用相同的代码打开.avi文件,并且可以正常工作...但是像http://66.184.211.231/mjpg/video.mjpg
这样的公共IP摄像机URL却不起作用!那怎么了?
I've tested opening a .avi file with the same code and it works... But a public IP camera URL like http://66.184.211.231/mjpg/video.mjpg
doesn't ! What's the matter then ?
已被编辑删除:我认为FFMPEG是一个问题,但v2.4.3.具有内置的FFMPEG支持和.avi文件,尽管我没有安装任何FFMPEG库(请解释一下?)
Removed by edit: I had considered FFMPEG to be an issue, but v2.4.3. has built-in FFMPEG support and .avi files work although I don't have any FFMPEG library installed (care to explain?)
预先感谢
关于, 米斯特尔先生
推荐答案
通过从源代码的build \ x86 \ mingw \ bin文件夹中复制opencv_ffmpeg.dll并将其粘贴到已构建的DLL(可通过PATH访问的bin文件夹)旁边来解决此问题):我不知道为什么,但是改为生成了opencv_ffmpeg_64.dll.
Solved it by copying opencv_ffmpeg.dll from the build\x86\mingw\bin folder of the sources and pasting it next to built DLLs (bin folder accessible through PATH): I have no idea why, but the opencv_ffmpeg_64.dll had been produced instead.
这篇关于cv :: VideoCapture适用于网络摄像头,但不适用于IP摄像机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!