title: Getting frames from .avi video using OpenCV
body: <pre><code>#include "cv.h"
  #include "highgui.h"
  int main(int argc, char** argv)
  {
  CvCapture* capture=0;
  IplImage* frame=0;
  
  capture = cvCaptureFromAVI("C:\\boy walking back.avi"); // read AVI video
  if( !capture )
      throw "Error when reading steam_avi";
  
  cvNamedWindow( "w", 1);
  
  for( ; ; )
  {
  /*  int cvGrabFrame (CvCapture* capture);
      IplImage* cvRetrieveFrame (CvCapture* capture)*/
      frame = cvQueryFrame( capture );
  if(!frame)
          break;
      cvShowImage("w", frame);
  
  }
  cvWaitKey(0); // key press to close window
  cvDestroyWindow("w");
  cvReleaseImage(&amp;frame);
  }
  </code></pre>
  
  <p>I am using openCV with VS2008. I have read in a video file and used CV_CAP_PROP_FRAME_COUNT to obtain the number of frames which was approximately 130 for a 4 second long video clip. I am doing a motion recognition of walking so I need to get every other 5 frames since between 5 frames, there is little change in the motion of the body. I have a program so far which allows me to obtain one frame of the video clip. However, I am unable to obtain different frames and also, I am not sure how to go about getting every other 5 frames. The above is the code used to get one frame of the video.</p>