Search code examples
c++opencvbuffercircular-buffer

How to implement a circular buffer of cv::Mat objects (OpenCV)?


I'm trying to implement a circular buffer for my program. The buffer is used to share data between two threads as shown below. I use OpenCV to grab video frames from camera (Thread 1). Then I would like to store this data in a circular buffer, so that Thread 2 can get the data from the buffer.

enter image description here

How can I implement a circular buffer for cv::Mat objects in C++? I know how to create circular buffer for standard C++ objects (like int or char) but I can't make it work with objects of type cv::Mat.

Any suggestions?


Solution

  • Solved, see Thread safe implementation of circular buffer