我今晚只是在调查这个。据我所知,iPad 2 不进行对焦——它进行曝光调整——所以在默认的相机应用程序中,点击屏幕会显示一个矩形,点击发生的地方指示要在该区域上进行白点调整。
也许我错了,但这是我发现的,并且似乎已通过您的 API(isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus
返回 NO)测试得到证实。
iPad 2 的摄像头很弱——尤其是前置摄像头。我很惊讶苹果公司提供了这个。
更新:这是处理焦点 + 曝光 + 白点的最新 AVCamDemo Apple 示例的代码。我不认为这在 AVCam 示例中。AVCamDemo 可能只能从开发者中心下载 WWDC 代码 .dmg 包 - 而不是从网络上单独下载。在我的 iPad 2 上,曝光代码永远不会被调用。//-来自 AVCamDemo:
- (BOOL) hasExposure
{
AVCaptureDevice *device = [[self videoInput] device];
return [device isExposureModeSupported:AVCaptureExposureModeLocked] ||
[device isExposureModeSupported:AVCaptureExposureModeAutoExpose] ||
[device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure];
}
- (AVCaptureExposureMode) exposureMode
{
return [[[self videoInput] device] exposureMode];
}
- (void) setExposureMode:(AVCaptureExposureMode)exposureMode
{
if (exposureMode == 1) {
exposureMode = 2;
}
AVCaptureDevice *device = [[self videoInput] device];
if ([device isExposureModeSupported:exposureMode] && [device exposureMode] != exposureMode) {
NSError *error;
if ([device lockForConfiguration:&error]) {
[device setExposureMode:exposureMode];
[device unlockForConfiguration];
} else {
id delegate = [self delegate];
if ([delegate respondsToSelector:@selector(acquiringDeviceLockFailedWithError:)]) {
[delegate acquiringDeviceLockFailedWithError:error];
}
}
}
}
- (BOOL) hasWhiteBalance
{
AVCaptureDevice *device = [[self videoInput] device];
return [device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeLocked] ||
[device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeAutoWhiteBalance];
}
- (AVCaptureWhiteBalanceMode) whiteBalanceMode
{
return [[[self videoInput] device] whiteBalanceMode];
}
- (void) setWhiteBalanceMode:(AVCaptureWhiteBalanceMode)whiteBalanceMode
{
if (whiteBalanceMode == 1) {
whiteBalanceMode = 2;
}
AVCaptureDevice *device = [[self videoInput] device];
if ([device isWhiteBalanceModeSupported:whiteBalanceMode] && [device whiteBalanceMode] != whiteBalanceMode) {
NSError *error;
if ([device lockForConfiguration:&error]) {
[device setWhiteBalanceMode:whiteBalanceMode];
[device unlockForConfiguration];
} else {
id delegate = [self delegate];
if ([delegate respondsToSelector:@selector(acquiringDeviceLockFailedWithError:)]) {
[delegate acquiringDeviceLockFailedWithError:error];
}
}
}
}
- (BOOL) hasFocus
{
AVCaptureDevice *device = [[self videoInput] device];
return [device isFocusModeSupported:AVCaptureFocusModeLocked] ||
[device isFocusModeSupported:AVCaptureFocusModeAutoFocus] ||
[device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus];
}
- (AVCaptureFocusMode) focusMode
{
return [[[self videoInput] device] focusMode];
}
- (void) setFocusMode:(AVCaptureFocusMode)focusMode
{
AVCaptureDevice *device = [[self videoInput] device];
if ([device isFocusModeSupported:focusMode] && [device focusMode] != focusMode) {
NSError *error;
printf(" setFocusMode \n");
if ([device lockForConfiguration:&error]) {
[device setFocusMode:focusMode];
[device unlockForConfiguration];
} else {
id delegate = [self delegate];
if ([delegate respondsToSelector:@selector(acquiringDeviceLockFailedWithError:)]) {
[delegate acquiringDeviceLockFailedWithError:error];
}
}
}
}