Video I/O Functions in OpenCV
Video Capture
CvCapture* capture = NULL;
IplImage *frame = NULL;
if(is_video_file(input))
capture = cvCreateFileCapture( input );
else if ( isdigit(input[0]) )
capture = cvCreateCameraCapture( atoi(input) );
//cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH);
//cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT);
if(capture)
{
for(;;)
{
if(!frame = cvQueryFrame( capture ))
continue;//break;
process_frame(frame);
if( cvWaitKey( 10 ) >= 0 )
break;
}
}
cvReleaseImage( &frame );
cvReleaseCapture( &capture );
Video Writing
CvVideoWriter *writer = cvCreateVideoWriter(
const char* filename, int fourcc, double fps, CvSize frame_size, int is_color=1);
IplImage *frame = NULL;
if(writer)
{
for(;;)
{
if(!frame = get_frame();
continue;
cvWriteFrame(writer, frame);
if( cvWaitKey( 10 ) >= 0 )
break;
}
}
cvReleaseImage( &frame );
cvReleaseVideoWriter( &writer );
Labels: OpenCV

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home