marker detection on multiple frames

asked 2016-03-10 03:24:24 -0600

MarKS9 gravatar image

I have 2 video(.avi) files and i have successfully able to grab multiple frames using C++ threading and store it in frame_queue.

vector<concurrent_queue<Mat>*> frame_queue;

But i want to run marker detection on these captured frames.

Here is the code snippet

while (1)
{
    //Retrieve frames from each camera capture thread
    for (int i = 0; i < capture_source.size(); i++)
    {
        Mat vdo_frame;
        //Pop frame from queue and check if the frame is valid
        if (cam.frame_queue[i]->try_pop(vdo_frame)){
            //Show frame on Highgui window
            marker_detection(vdo_frame);
            //imshow(label[i], frame);
        }
    }
}

If i am not wrong cam.frame_queue[0] holds the frames from video1 and frame_queue[1] holds the frames from video2. But how do i run marker detection for both the videos in parallel? Issue is whenever i run the code it works for some seconds but then my Ubuntu freezes and i have to reboot.

edit retag flag offensive close merge delete

Comments

you can't assume, that any opencv code is threadsafe (esp. when it comes to using gui parts, which also mess with your os)

(also, naive multithreading is the fastest way ever to shoot your foot.)

berak gravatar imageberak ( 2016-03-10 03:42:53 -0600 )edit