Ask Your Question

Is it possible to get a pointer to two different frames in a video sequence at the same time with OpenCV?

asked 2012-09-23 13:06:34 -0600

excelerate gravatar image

You can access a specific frame in a video sequence like this:

capture.set(CV_CAP_PROP_POS_FRAMES, frame_num);
capture >> frame;

You can then access a separate frame like this:

capture.set(CV_CAP_PROP_POS_FRAMES, frame_num - 20);
capture >> frame2;

However, when you set the capture property with CV_CAP_PROP_POS_FRAMES, it actually moves the first pointer and frame and frame2 end up pointing to the same data, containing the same values.

I want a pointer to both, so I do not have to clone the data (expensive computation) but I can perform comparisons between the two frames. How can this be done with OpenCV?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-24 01:54:08 -0600

Adi gravatar image

It can't be done. The frame point to the internal decompressed buffers of the codec.
Only a single one is valid at any time.

You will have to copy your additional frame.

edit flag offensive delete link more

Question Tools


Asked: 2012-09-23 13:06:34 -0600

Seen: 1,068 times

Last updated: Sep 24 '12