When this call returns NULL:
CvCapture* cap = cvCaptureFromCAM(0);
if (!cap)
{
// print error and exit
cout << "ERROR: Capture is null!\n";
return -1;
}
this means that no devices were found in the index 0. Try passing CV_CAP_ANYinstead, so that OpenCV chooses a valid index number for you.
If this does not work, your camera may not be supported by OpenCV. Try to find in this list .
source
share