gpt4 book ai didi

c++ - 警告 : Could not find codec parameters (. ./../modules/highgui/src/cap_ffmpeg_impl.hpp:540)

转载 作者:太空狗 更新时间:2023-10-29 20:04:19 27 4
gpt4 key购买 nike

我正在尝试显示来自 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++ - 警告 : Could not find codec parameters (. ./../modules/highgui/src/cap_ffmpeg_impl.hpp:540),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20613453/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com