我正在尝试使用 AVFoundation 实现相机应用程序。我想使用 AVCaptureExposureModeAutoFocus 在某个点设置 exposurePointOfInterest,然后按照 Apple 文档的说明锁定曝光:
AVCaptureExposureModeAutoExpose: the device automatically adjusts the exposure once and then changes the exposure mode to AVCaptureExposureModeLocked.
这是我使用的函数:
-(void)autoExposeAtPoint:(CGPoint)point
{
AVCaptureDevice *device = [videoInput device];
if([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:AVCaptureExposureModeAutoExpose]){
if([device lockForConfiguration:NULL]){
[device setExposurePointOfInterest:point];
[device setExposureMode:AVCaptureExposureModeAutoExpose];
[device unlockForConfiguration];
NSLog(@"Exposure point of intereset has been set to (%f,%f)",point.x, point.y);
}
}
}
然而,所需点的自动曝光从未发生过。当我使用下面的 NSLog 进行调试时,结果发现 AVCaputreExposureModeAutoExpose 不受支持。然而,如果我使用 AVCaptureExposureModeContinuousAutoExpose,它将完美运行。
我不明白这个;运行 iOS7 的 iPhone 5 后置摄像头不支持 AVCaputreExposureModeAutoExpose 是真的吗?有人有任何线索吗?谢谢!
调试代码:
NSLog(@"issupported: %hhd", [device isExposurePointOfInterestSupported]);
NSLog(@"ismodesupported: %hhd" ,[device isExposureModeSupported:AVCaptureExposureModeAutoExpose]);
**Result:**
issupported: 1
ismodesupported: 0
最佳答案
我在 Apple 开发者论坛上发布了这个问题,并得到了 Apple WWDC Camera with AV Foundation 发言人 Brad Ford(Core Media Engineering)的回答。
这是他的 answer :
Correct. AVCaptureExposureModeAutoExpose, while defined in the header, is not currently implemented on any iOS device.
You can however implement it in your own code by setting your desired point of interest, then calling setExposureMode:AVCaptureExposureModeContinuousAutoExposure, and then listen (key-value observe) the "isAdjustingExposure" property of AVCaptureDevice to know when the exposure finishes adjusting. As soon as it does, setExposureMode to AVCaptureExposureModeLocked.
关于ios - iPhone 5 : AVCaptureExposureModeAutoFocus not supported in iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21361087/