C++ Opencv 3.2读取mpeg文件太慢
我正在阅读学习OpenCV 3这本书,并测试视频示例2.3。我可以编辑、编译和运行它,但问题是它立即关闭了C++ Opencv 3.2读取mpeg文件太慢,c++,opencv3.2,C++,Opencv3.2,我正在阅读学习OpenCV 3这本书,并测试视频示例2.3。我可以编辑、编译和运行它,但问题是它立即关闭了 // DisplayPicture.cpp : Defines the entry point for the console application. // //#include "opencv2/opencv.hpp" // Include file for every supported OpenCV function #include "opencv2\imgproc\im
// DisplayPicture.cpp : Defines the entry point for the console application.
//
//#include "opencv2/opencv.hpp" // Include file for every supported OpenCV function
#include "opencv2\imgproc\imgproc.hpp"
#include "opencv2\highgui\highgui.hpp"
#include <opencv2/videoio.hpp>
#include <stdio.h>
#include <string.h>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
namedWindow("video3", WINDOW_AUTOSIZE);
VideoCapture cap;
cap.open( string(argv[1]));
int tell = 0;
Mat frame;
for (;;) {
cap >> frame;
//waitKey(30);
if (frame.empty())
{
break;
//end of film
}
imshow("video3", frame);
}
return 0;
}
//DisplayPicture.cpp:定义控制台应用程序的入口点。
//
//#为每个支持的opencv函数包含“opencv2/opencv.hpp”//include文件
#包括“opencv2\imgproc\imgproc.hpp”
#包括“opencv2\highgui\highgui.hpp”
#包括
#包括
#包括
使用名称空间cv;
使用名称空间std;
int main(int argc,字符**argv){
namedWindow(“video3”,窗口自动大小);
视频捕捉帽;
未结(字符串(argv[1]);
int-tell=0;
垫架;
对于(;;){
cap>>框架;
//等候室(30);
if(frame.empty())
{
打破
//电影的结尾
}
imshow(“video3”,帧);
}
返回0;
}
我发现我的电脑处理数据太快了。它无法足够快地读取下一帧<代码>如果(frame.empty())为真,则程序到达break
语句并结束
通过在查看图像帧之前添加30毫秒的waitkey
,视频程序运行良好。至少我可以看视频。因为这个例子来自《圣经》,它应该能用,但不能用我的电脑
我正在用英伟达gtx880m运行一台MSI gt72 2PE计算机。不知道这是否重要
我假设添加一个waitKey(30)
是不合适的,所以我正在寻求关于可以做什么不同的建议