Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Skipping all but the lastest frame in VideoCapture

As an answer to the question "Skipping frames in VideoCapture" Will Stewart presented grap() for skipping frames. But how many frames to I have to skip until I reach the current one?

In a loop the frames of a camera are processed using a very time consuming function. In the meantime the camera is providing further frames and as loop is doing the next vcap.read() it gets an old buffered frame. That delays the output even further than it is already delayed by the processing anyway. How to skip all of theses frames. I am looking for something like vcap.flush_read_buffer() except for the latest frame.

Skipping all but the lastest frame in VideoCapture

As an answer to the question "Skipping frames in VideoCapture" Will Stewart presented grap() for skipping frames. But how many frames to I have to skip until I reach the current one?

In a loop the frames of a camera are processed using a very time consuming function. In the meantime the camera is providing further frames and as frames. Thus if the loop is doing the next vcap.read() it gets an old buffered frame. That delays the output even further than it is already delayed by the processing anyway. How to skip all of theses frames. I am looking for something like vcap.flush_read_buffer() except for the latest frame.

Some sort of non blocking grap() would also do the job while(vcap.grap()); and then vcap.retrieve() the last successful graped frame. Or a function providing a flag if frames are buffered while(vcap.buffered()) vcap.grap(). Any of these would be better that nothing.

Doing multi-threading (like harsha proposed) would surely do the job. But it is like taking a sledgehammer to crack a nut. Especially on an embedded system this won't feel good. Processing as many frames of a camera as possible but these just in time, should be possible on a system designed "with a strong focus on real-time applications."

Any further idea?

Skipping all but the lastest latest frame in VideoCapture

As an answer to the question "Skipping frames in VideoCapture" Will Stewart presented grap() for skipping frames. But how many frames to I have to skip until I reach the current one?

In a loop the frames of a camera are processed using a very time consuming function. In the meantime the camera is providing further frames. Thus if the loop is doing the next vcap.read() it gets an old buffered frame. That delays the output even further than it is already delayed by the processing anyway. How to skip all of theses frames. I am looking for something like vcap.flush_read_buffer() except for the latest frame.

Some sort of non blocking grap() would also do the job while(vcap.grap()); and then vcap.retrieve() the last successful graped frame. Or a function providing a flag if frames are buffered while(vcap.buffered()) vcap.grap(). Any of these would be better that nothing.

Doing multi-threading (like harsha proposed) would surely do the job. But it is like taking a sledgehammer to crack a nut. Especially on an embedded system this won't feel good. Processing as many frames of a camera as possible but these just in time, should be possible on a system designed "with a strong focus on real-time applications."

Any further idea?