Video Recording is too fast
Please note I am duplicating this questions because I did not get the answer I am seeking for.
Please have a look at the following code.
#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;
}
}
}
This code runs fine, no issue. But, when I run the recorded video, it is super fast! Like it is fast forwarded. I really do not understand why. Please help.
In the previous question I was advised to use usleep()
and I coudn't find it so I used Sleep()
. But I got the same results! Anyway this is a real time application, so video should be displayed to the user real time. Using such methods disturb how the video is shown because video also displayed to the user after the specified number of milliseconds. you know, it is like watching a movie which gets stuck always.
Please help.