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

pull/13383/head
Vadim Pisarevsky 14 years ago
parent 9170ff6f5e
commit b58d9edc6a
  1. 9
      modules/highgui/src/cap_qtkit.mm

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

Loading…
Cancel
Save