Zac*_*los 10 iphone avfoundation ios
我目前正在使用AVFoundation来运行我的相机,但我希望能够检测到相机何时完成对焦.有没有办法做到这一点?
非常感谢!!
在初始化中:
[[[captureManager videoInput] device] addObserver:self forKeyPath:@"adjustingFocus" options:NSKeyValueObservingOptionNew context:nil];
Run Code Online (Sandbox Code Playgroud)
然后:
bool focusing = false;
bool finishedFocus = false;
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
//[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
if( [keyPath isEqualToString:@"adjustingFocus"] ){
BOOL adjustingFocus = [ [change objectForKey:NSKeyValueChangeNewKey] isEqualToNumber:[NSNumber numberWithInt:1] ];
if (adjustingFocus) {
focusing=true;
}
else {
if (focusing) {
focusing = false;
finishedFocus = true;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2030 次 |
| 最近记录: |