Ask Your Question
1

How to skip the first 2 frames?

asked 2014-07-28 06:16:10 -0600

VideoWM gravatar image

Hi I have a while(1) which does a infinite loop, is there a way to ignore the first 2 frames?

while(1)
{
    bool bSuccess = capture.read(fullimage); // read a new frame from video

    if (!bSuccess)                          //if not success, break loop
    {
        cout << "End of video" << endl;
        destroyWindow("Original Video");
        destroyWindow("dctBlockImage");
        break;
    }

    imshow("Original Video", fullimage);    //show the frame in "Original Video" window

    FrameTo8by8(myinput,3.0);               //Proccess and algorithm

    oVideoWriter.write(dctImage);           //write video to file

    namedWindow("dctBlockImage"); 
    imshow("dctBlockImage", dctImage);      //display watermarked image


    if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl; 
        break; 
    }
}

Is there a way to skip the first 2 frames?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-07-28 07:06:13 -0600

unxnut gravatar image

It is a simple programming issue. Here you go:

int frame_num = 0;
const int num_to_skip = 2;  // Number of frames to skip
while(1)
{
    bool bSuccess = capture.read(fullimage); // read a new frame from video
    if (!bSuccess)                          //if not success, break loop
    {
        cout << "End of video" << endl;
        destroyWindow("Original Video");
        destroyWindow("dctBlockImage");
        break;
    }

    imshow("Original Video", fullimage);    //show the frame in "Original Video" window
    if ( ++frame_num < num_to_skip )
        continue;

    /* Rest of the loop */
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-07-28 06:16:10 -0600

Seen: 1,546 times

Last updated: Jul 28 '14