i have a problem of recording of video in opencv2.4.9 with visualstudio2012
#include "opencv2/highgui/highgui.hpp"
#include"opencv2/core/core.hpp"
#include"opencv2/imgproc/imgproc.hpp"
#include<stdlib.h>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture cap(0);
// open the video camera no. 0
if (!cap.isOpened()) // if not success, exit program
{
cout << "ERROR: Cannot open the video file" << endl;
return -1;
}
namedWindow("My",CV_WINDOW_AUTOSIZE);
double j=cap.get(CV_CAP_PROP_FPS);
double width=cap.get(CV_CAP_PROP_FRAME_WIDTH);
double height=cap.get(CV_CAP_PROP_FRAME_HEIGHT);
cout<<width<<endl;
Size framesize(static_cast<int>(width),static_cast<int>(height));
VideoWriter ovid("D:\ashish.avi",CV_FOURCC('P','I','M','1'),20,framesize,true);
cout<<framesize;
if(!ovid.isOpened())
{
system("pause");
return -1;
}
while (1)
{
Mat frame;
cap>>frame;
ovid.write(frame);
imshow("My", frame); //show the frame in "MyVideo" window
if (waitKey(10) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}
above code executes with no warning but no video is displays on window as well as no recording happens.
what is it printing? Have you tried debug mode?
Please refer this http://docs.opencv.org/doc/tutorials/highgui/video-write/video-write.html#the-source-code