title: Capturing video from two cameras in OpenCV at once
body: <p>How do you capture video from two or more cameras at once (or nearly) with OpenCV, using the Python API?</p>
  
  <p>I have three webcams, all capable of video streaming, located at /dev/video0, /dev/video1, and /dev/video2.</p>
  
  <p>Using the <a href="http://docs.opencv.org/trunk/dd/d43/tutorial_py_video_display.html" rel="noreferrer">tutorial</a> as an example, capturing images from a single camera is simply:</p>
  
  <pre><code>import cv2
  cap0 = cv2.VideoCapture(0)
  ret0, frame0 = cap0.read()
  cv2.imshow('frame', frame0)
  cv2.waitKey()
  </code></pre>
  
  <p>And this works fine.</p>
  
  <p>However, if I try to initialize a second camera, attempting to <code>read()</code> from it returns None:</p>
  
  <pre><code>import cv2
  cap0 = cv2.VideoCapture(0)
  cap1 = cv2.VideoCapture(1)
  ret0, frame0 = cap0.read()
  assert ret0 # succeeds
  ret1, frame1 = cap1.read()
  assert ret1 # fails?!
  </code></pre>
  
  <p>Just to ensure I wasn't accidentally giving OpenCV a bad camera index, I tested each camera index individually and they all work by themselves. e.g.</p>
  
  <pre><code>import cv2
  #cap0 = cv2.VideoCapture(0)
  cap1 = cv2.VideoCapture(1)
  #ret0, frame0 = cap0.read()
  #assert ret0
  ret1, frame1 = cap1.read()
  assert ret1 # now it works?!
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Edit: My hardware is a Macbook Pro running Ubuntu. Researching the issue specifically on Macbooks, I've found others that have run into this problem too, both on OSX and with different types of cameras. If I access the iSight, both calls in my code fail.</p>