请看下面的代码:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <string>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/video/background_segm.hpp>
using namespace std;
using namespace cv;
double getMSE(const Mat& I1, const Mat& I2);
int main()
{
Mat current;
VideoCapture cam1;
VideoWriter *writer = new VideoWriter();
cam1.open(0);
namedWindow("Normal");
if(!cam1.isOpened())
{
cout << "Cam not found" << endl;
return -1;
}
cam1>>current;
Size *s = new Size((int)current.cols,current.rows);
writer->open("D:/OpenCV Final Year/OpenCV Video/MyVideo.avi",CV_FOURCC('D','I','V','X'),10,*s,true);
while(true)
{
//Take the input
cam1 >> current;
*writer << current;
imshow("Normal",current);
if(waitKey(30)>=0)
{
break;
}
}
}
此代码运行良好,没有问题。但是,当我运行录制的视频时,它超级快!就像它快进一样。我真的不明白为什么。