So, I'm trying to capture from two cameras in openCV (python and windows 7). I shoot with one camera just fine, you will also notice that I make some funky for the image, but it does not matter. This is a code that tries to use two
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
Rather simple. However, this will not work. When trying to create a matrix from the second camera (the second line of code in the loop), I was told that the capture is zero. The cameras I use are logitech and are the same model.
Side note: I also could not find the command to count the cameras connected to the python, so if someone could refer to me, I would really appreciate it. --Ashley
EDIT: It may also be useful to know that windows often prompt me to choose which camera I would like to use. I cannot avoid this behavior. In addition, I downloaded some security, such as software that successfully starts both cameras at the same time. This is not an open source or anything like that. So clearly, it is possible.
source share