title: Error when trying to access frames from multithreading video capturing
body: <p>I am using ltbb to stream from two cameras. ltbb creates two threads(because of two cameras) for simultaneous streaming from two cameras. It makes use of concurrent queues for fetching frames. The following code snippet displays frames:</p>
  
  <pre><code>while (waitKey(20) != 27)
    {
      //Retrieve frames from each camera capture thread
      vector&lt;Mat&gt; iMats(capture_source.size());
  
      for (int i = 0; i &lt; capture_source.size(); i++)
      {
        Mat frame;
  
        //Pop frame from queue and check if the frame is valid
        if (cam.frame_queue[i]-&gt;try_pop(frame))
        {
          //Show frame on Highgui window
          // IMats.push_back(frame);
          iMats[i] = frame;
          imshow(label[i], frame);
        }
  
      } // end of for - loop
  
      int x = opencv_tri(iMats);
    }  
  </code></pre>
  
  <p><strong>The problem is</strong> when I am doing <code>iMats[i] = frame</code> and pass it to other function, It's giving me an error. <strong>It works fine when I comment iMats and stop calling opencv_tri(iMats)</strong>.</p>
  
  <p>Error: <code>Segmentation fault (core dumped)</code></p>
  
  <p><strong>Link to opencv_tri:</strong> <a href="http://txt.do/dlfnm" rel="nofollow noreferrer">opencv_tri.cpp</a></p>
  
  <p>Can anyone please explain and help me to fix this?</p>