Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Loading 1 frame per 4 second

Hi , I have following code

   if ( !cap.isOpened() ) 
   {
     cout << "Cannot open the video file" << endl;
     return -1;
}
double fps = cap.get(CV_CAP_PROP_FPS); 
cout << "Frame per seconds : " << fps << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); 
while(1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); 
    if (!bSuccess)
    {
                    cout << "Cannot read the frame from video file" << endl;
                   break;
    }

    imshow("MyVideo", frame);

    if(waitKey(30) == 27)
    {
            cout << "esc key is pressed by user" << endl; 
            break; 
     }

It loads one frame per second. Now , How do I change to read 1 frame in 4 or 5 seconds.