diff --git a/modules/highgui/src/cap_qtkit.mm b/modules/highgui/src/cap_qtkit.mm index f88929d75..80b043c81 100644 --- a/modules/highgui/src/cap_qtkit.mm +++ b/modules/highgui/src/cap_qtkit.mm @@ -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] ; }