这是我到 HTTP 流的链接格式(用户、密码和地址已更改为虚拟):
http://username:password@192.168.0.104:8093/axis-cgi/mjpg/video.cgi
此流在VLC中完美运行。但是,我无法使用 OpenCV 库打开它。
这是我的代码:
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main()
{
VideoCapture cap;
const string videoStreamAddress = "http://username:password@192.168.0.104:8093/axis-cgi/mjpg/video.cgi";
cap.open(videoStreamAddress);
if (!cap.isOpened())
{
cout << endl << "Videostream not found !" << endl;
system("pause");
return 0;
}
Mat frame;
while(1)
{
cap >> frame;
if (frame.empty())
break;
imshow("IPcamera", frame);
int c = waitKey(1);
if (c == 27)
{
break;
}
}
waitKey(0);
return 0;
}
这给了我一个错误:
warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:529)
这指向:
bool CvCapture_FFMPEG::open( const char* _filename )
{
unsigned i;
bool valid = false;
close();
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
int err = avformat_open_input(&ic, _filename, NULL, NULL);
#else
int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);
#endif
if (err < 0)
{
CV_WARN("Error opening file");
goto exit_func;
}
...
可能是什么问题?