title: OpenCV: Should the write from VideoWriter run in an independent thread?
body: <p>I'm writing a program that reads multiple webcams, stitches the pictures together and saves them into a video file.</p>
  
  <ol>
  <li>Should i use threads to capture the images and to write the resulting large image into a file? </li>
  <li>If yes, should i use c+11 or boost?</li>
  <li>Do you maybe have some simple example code which shows how to avoid racing conditions?</li>
  </ol>
  
  <p>I already found <a href="https://stackoverflow.com/questions/17091975/opencv-videowriter-framerate-issue">this thread</a> which uses threads for write but it doesn't seem to avoid racing conditions.</p>
  
  <p>pseudocode of my program:</p>
  
  <pre><code>camVector //vector with cameras
  VideoWriter outputVideo //outputs the video
  
  while(true){
      for(camera:camVector){
          camera.grab() //send signal to grab picture
      }
      picVector = getFrames(camVector) //collect frames of all cameras into a Vector
  
      Mat bigImg = stitchPicTogether(picVector)
  
      outputVideo.write(bigImg)
  }
  </code></pre>