I have been unsuccessful using OpenCV's VideoCapture.open(int) to get video capture from a USB web cam in my MacBook Pro running Mac OS X v10.7 (Lion). Using open(0) successfully gets capture from the iSight camera. But I didn't have any luck trying to find the WebCam.
The WebCam is installed and works well with Skype, and the macam driver application.
Here is a portion of the code that I'm using:
VideoCapture cap;
for (int i = 1; i < 1500; i++) {
if (cap.open(i))
{
cout << "Found camera %d
" << i;
break;
}
}
if(!cap.isOpened()) { // Check if we succeeded
return -1;
}
If I initialize i
with 0 it immediately finds the iSight camera. If I initialize i
with 1, then it finds iSight again when i
= 500.
How can I fix this problem?
See Question&Answers more detail:os