IPhone6介绍了两种聚焦检测方法: 1.对比度检测2.相位检测
在iphone 6.6+中,它使用相位检测。
我想要得到当前的焦点系统
self.format = [[AVCaptureDeviceFormat alloc] init];
[self.currentDevice setActiveFormat:self.format];
AVCaptureAutoFocusSystem currentSystem = [self.format autoFocusSystem];
if (currentSystem == AVCaptureAutoFocusSystemPhaseDetection)
{
[self.currentDevice addObserver:self forKeyPath:@"lensPosition" options:NSKeyValueObservingOptionNew context:nil];
}
else if(currentSystem == AVCaptureAutoFocusSystemContrastDetection)
{
[self.currentDevice addObserver:self forKeyPath:@"adjustingFocus" options:NSKeyValueObservingOptionNew context:nil];
}
else{
NSLog(@"No observers added");
}但是现在它在下面这一行崩溃了
AVCaptureAutoFocusSystem currentSystem = [self.format autoFocusSystem];我找不到坠机的适当描述。
发布于 2015-01-05 03:14:19
您正在创建一些"AVCaptureDeviceFormat",但实际上在默认情况下不会使用它设置任何内容。它只是无法使用的垃圾(这就是为什么你要崩溃)。
每个捕获设备都有一到两种可以使用的格式。
你可以通过做这样的事情来看到它们:
for (AVCaptureDeviceFormat *format in [self.currentDevice formats]) {
CFStringRef formatName = CMFormatDescriptionGetExtension([format formatDescription], kCMFormatDescriptionExtension_FormatName);
NSLog(@"format name is %@", (NSString *)formatName);
}您应该做的是决定要使用哪个AVCaptureDevice (例如,前摄像头、后置摄像头等),从那里获取的格式,然后设置[self.currentDevice setActiveFormat:self.format]“。
WWDC 2013年的会议“什么是新的相机捕捉”视频有更多关于如何做到这一点的信息。
https://stackoverflow.com/questions/27772728
复制相似问题