Thursday, March 31, 2011

playing a video using OpenCV

Taken from the learning OpenCV Book
//*** Playing a Video from Disk  ****//

cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
  ////CvCapture* capture = cvCaptureFromAVI( argv[1] ); // either one will work
CvCapture* capture = cvCaptureFromAVI("3ality_short_960x540_cam00.avi");
  ////CvCapture* capture = cvCreateFileCapture( "3ality_short_960x540_cam00.avi" );
  IplImage* frame;
  while(1) {
      frame = cvQueryFrame( capture );
      if( !frame ) break;
      cvShowImage( "Example2", frame );
      char c = cvWaitKey(33);
      if( c == 27 ) break;
  }
  cvReleaseCapture( &capture );
  cvDestroyWindow( "Example2" );

No comments:

Post a Comment

Please ask if anything is not clear enough..........