return NULL in the case of incorrect camera index (ticket #710)

This commit is contained in:
Vadim Pisarevsky 2011-05-21 18:07:28 +00:00
parent 9170ff6f5e
commit b58d9edc6a

View File

@ -338,11 +338,10 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
}
if (cameraNum >= 0) {
camNum = cameraNum % [devices count];
if (camNum != cameraNum) {
cout << "Warning: Max Camera Num is " << [devices count]-1 << "; Using camera " << camNum << endl;
}
device = [devices objectAtIndex:camNum] ;
int nCameras = [devices count];
if( cameraNum < 0 || cameraNum >= nCameras )
return 0;
device = [devices objectAtIndex:cameraNum] ;
} else {
device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo] ;
}