int main( int argc, char** argv )
{
CvCapture* capture = 0;
IplImage *frame, *frame_copy = 0;
static CvMemStorage* storage = cvCreateMemStorage(0);
capture = cvCaptureFromAVI( "G:\FlickAnimation.avi" );
cvNamedWindow( "Picture:", 1 );
int index = 0;
if( capture )
{
for(;;)
{
if( !cvGrabFrame( capture ))
break;
frame = cvRetrieveFrame( capture );
if( !frame )
break;
else
{
index++;
//save image
std::string s;
std::stringstream out;
out << index;
s = out.str();
string location = "G:\\movie\\"+s+".jpg";
cvSaveImage(location.c_str(),frame);
}
if( !frame_copy )
frame_copy = cvCreateImage(cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
if( frame->origin == IPL_ORIGIN_TL )
cvCopy( frame, frame_copy, 0 );
else
cvFlip( frame, frame_copy, 0 );
cvShowImage("Picture:",frame_copy);
// Varying this will vary the speed of the avi file
if( cvWaitKey( 20 ) >= 0 )
break;
}
cvReleaseImage( &frame_copy );
cvReleaseCapture( &capture );
}
cvClearMemStorage( storage );
cvDestroyWindow("Picture:");
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment