title: Capturing From 2 Cameras (OpenCV, Python)
body: <p>So I am attempting to capture from two cameras in openCV (python &amp; windows 7).  I capture from one camera just fine, youll also notice I am doing some funky stuff to the image but that doesn't matter. This is the code to attempt to use two</p>
  
  <pre><code>import cv
  import time
  cv.NamedWindow("camera", 1)
  cv.NamedWindow("camera2", 1)
  capture = cv.CaptureFromCAM(0)
  capture2 = cv.CaptureFromCAM(1)
  while True:
      img = cv.GetMat(cv.QueryFrame(capture))
      img2 = cv.GetMat(cv.QueryFrame(capture2))
      dst_image = cv.CloneMat(img)
      dst_image2 = cv.CloneMat(img2)
      cv.ConvertScale(img, dst_image, 255, -59745.0)
      cv.ConvertScale(img2, dst_image2, 255, -59745.0)
      cv.ShowImage("camera", dst_image)
      cv.ShowImage("camera2", dst_image2)
      if cv.WaitKey(10) == 27:
          cv.DestroyWindow("camera")
          cv.DestroyWindow("camera2")
          break
  </code></pre>
  
  <p>Rather simple. However it won't work. Upon trying to create the matrix from the second camera (second line of code in the loop), I am told that the capture is null. The cameras I am using are logitech and are the same model. </p>
  
  <p>Side note: I also couldnt find the command to count cameras connected in python, so if someone could refer me to that I'd much appreciate it.
  --Ashley</p>
  
  <p>EDIT:
  It might also be useful to know that windows often prompts me to choose which camera I would like to use. I can't seem to avoid this behavior. Additionally I downloaded some security like software that successful runs both cameras at once.  It is not open source or anything like that. So clearly, this is possible. </p>