c – 警告:找不到编解码器参数(../../modules/highgui/src/cap_ffmpeg_impl.hpp:540)
作者:互联网
我试图从IP摄像头显示视频输入,得到以下错误
warning: Could not find codec parameters
(../../modules/highgui/src/cap_ffmpeg_impl.hpp:540)
这是相同的代码.
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int, char**)
{
VideoCapture vcap;
Mat image;
// This works on a D-Link CDS-932L
const string videoStreamAddress = "http://admin:admin123@172.41.20.55:80/? action=stream?dummy=param.mjpg";//From mjpeg streamer
//const string videoStreamAddress = "http://192.168.1.13:8080/videofeed? dummy=param.mjpg"; // Streaming from android using ip-cam
//open the video stream and make sure it's opened
if(!vcap.open(videoStreamAddress)) {
cout << "Error opening video stream or file" << std::endl;
return -1;
}
for(;;) {
if(!vcap.read(image)) {
cout << "No frame" << std::endl;
waitKey();
}
cv::imshow("Output Window", image);
if(cv::waitKey(1) >= 0) break;
}
}
首先我得到了不同的错误,所以我安装了K-Lite编解码器.现在我收到了这个错误.
有人可以告诉我有什么错误.
我已经经历了stackoverflow和opencv的许多帖子,但可以设法得到一个满意的答案.
请帮我.
提前致谢.
解决方法:
我能够使用以下代码解决问题.
#include <stdio.h>
#include <opencv2/opencv.hpp>
int main(){
CvCapture *camera=cvCaptureFromFile("http://username:password@ipOfCamera/axis-cgi/mjpg/video.cgi?resolution=640x480&req_fps=30&.mjpg");
if (camera==NULL)
printf("camera is null\n");
else
printf("camera is not null");
cvNamedWindow("img");
while (cvWaitKey(10)!=atoi("q")){
double t1=(double)cvGetTickCount();
IplImage *img=cvQueryFrame(camera);
/*if(img){
cvSaveImage("C:/opencv.jpg",img);
}*/
double t2=(double)cvGetTickCount();
printf("time: %gms fps: %.2g\n",(t2-t1)/(cvGetTickFrequency()*1000.), 1000./((t2-t1)/(cvGetTickFrequency()*1000.)));
cvShowImage("img",img);
}
cvReleaseCapture(&camera);
}
如果它能帮助像我这样的人,那会很好.
还要感谢@karlphillip给你的时间.
标签:c,opencv,video,ip-camera 来源: https://codeday.me/bug/20190725/1532114.html