Capturing a frame in a double while loop

asked 2019-01-22 06:47:29 -0600

Filippo9669 gravatar image

Hi! I have a problem with something like this. The case is that if i > a && i < b (it is just an example, the whole thing is a bit more complex) I need my function to still capture frames but use static variables from //do something1. Unfortunately, whenever this second while loop starts, I get an error saying that the frame object is empty - nothing has been captured. Any idea how to solve it? Cheers.

int i = 0;    
while(cap.isOpened())
    {
        cap >> frame;
        //do something1

        while (i > a && i < b) //for a < b
            {
                 cap >> frame;
                //do something
            }
    ++i;
    }
edit retag flag offensive close merge delete

Comments

What's exactly error message? May be you should check frame empty

I don't understand while loops : it's only a if with else i++

LBerger gravatar imageLBerger ( 2019-01-22 06:52:23 -0600 )edit

Does this help? CAP_PROP_POS_MSEC

supra56 gravatar imagesupra56 ( 2019-01-22 08:42:06 -0600 )edit

Because loops are far more complicated and it is not really helpful to show what's inside of them.

Filippo9669 gravatar imageFilippo9669 ( 2019-01-22 10:51:19 -0600 )edit

@supra56 how exactly shall I apply it?

Filippo9669 gravatar imageFilippo9669 ( 2019-01-22 10:53:31 -0600 )edit

I can't post here. It is forbidden content

supra56 gravatar imagesupra56 ( 2019-01-22 12:11:37 -0600 )edit