vod*_*ang 2 iphone objective-c avfoundation autofocus ipad
我正试图在我的应用程序中进行自动对焦工作,在iPad2中进行测试.我的问题是,当我调用check方法时isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus,它总是返回NO.但是,我可以点击其他相机应用程序在我的设备中
devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *tempDevice in devices) {
[tempDevice lockForConfiguration:nil];
if ([tempDevice isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {
NSLog(@"Here");
}
if ([tempDevice isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
NSLog(@"Here");
}
if ([tempDevice isFocusModeSupported:AVCaptureFocusModeLocked]) {
NSLog(@"Here");
}
if ([tempDevice isFocusPointOfInterestSupported]) {
NSLog(@"Here");
}
[tempDevice unlockForConfiguration];
}
Run Code Online (Sandbox Code Playgroud)
我今晚只是在调查这个问题.根据我收集的内容,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];
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3999 次 |
| 最近记录: |