Skip to content

Instantly share code, notes, and snippets.

@kumarkrishna
Created November 30, 2013 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumarkrishna/7716774 to your computer and use it in GitHub Desktop.
Save kumarkrishna/7716774 to your computer and use it in GitHub Desktop.
Video writer
#include <iostream>
#include <highgui.h>
#include <cv.h>
#include <cmath>
#include <time.h>
int main()
{
CvCapture* capture=cvCreateCameraCapture(0);
IplImage *frame,*output;
//int k=cvWaitKey(3000);
cvNamedWindow("win",CV_WINDOW_AUTOSIZE);
//cvNamedWindow(win2,CV_WINDOW_AUTOSIZE);
frame = cvQueryFrame(capture);
CvVideoWriter* writer = cvCreateVideoWriter("video.avi",CV_FOURCC('M','J','P','G'),30, cvGetSize(frame));
/* CvVideoWriter* writer= cvCreateVideoWriter(<filename>,<format>,<fps>,<size>) */
while(1)
{
frame = cvQueryFrame(capture);
//output = createbinary(frame);
cvWriteFrame( writer, frame );
cvShowImage("win",frame);
//cvShowImage(win2,output);
char c=cvWaitKey(33);
if(c==27)
break;
}
//printf("%lld\n",fps);
cvReleaseCapture(&capture);
cvReleaseImage(&frame);
cvReleaseVideoWriter( &writer );
//cvReleaseImage(&output);
cvDestroyWindow("win");
//cvDestroyWindow(win2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment