chr*_*ysb 5 xcode avfoundation ios
我正在使用AVFoundation构建自定义相机.除了之外,一切都很好setExposurePointOfInterest.
我在iPhone 5上测试,AVCaptureDevice告诉我BackCamera不支持AVCaptureExposureModeAutoExpose.
然后我如何实施水龙头来调整曝光?
这是我的代码:
- (void)didTapCameraPreview:(UITapGestureRecognizer *)recognizer {
CGPoint point = [recognizer locationInView:self.view];
CGRect screenRect = [self.view bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
double focus_x = point.x/screenWidth;
double focus_y = point.y/screenHeight;
CGPoint touchPoint = CGPointMake(focus_x, focus_y);
AVCaptureDevice *device = (self.captureSession.inputs[0] == self.backCamera) ? self.backCamera.device : self.frontCamera.device;
if (device.isFocusPointOfInterestSupported) {
NSError *error;
if ([device lockForConfiguration:&error]) {
[device setFocusPointOfInterest:touchPoint];
[device setExposurePointOfInterest:touchPoint];
[device setFocusMode:AVCaptureFocusModeAutoFocus];
if ([device isExposureModeSupported:AVCaptureExposureModeAutoExpose]){
[device setExposureMode:AVCaptureExposureModeAutoExpose];
}
[device unlockForConfiguration];
}
}
Run Code Online (Sandbox Code Playgroud)
}
我在 Apple 开发者论坛中提出了类似的问题,并得到了 Brad Ford(核心媒体工程)的回答,他是 Apple WWDC 中 Camera Capture with AV Foundation 的发言人。
这是他的回答:
正确的。AVCaptureExposureModeAutoExpose 虽然在标头中定义,但目前尚未在任何 iOS 设备上实现。
但是,您可以在自己的代码中实现它,方法是设置所需的兴趣点,然后调用 setExposureMode:AVCaptureExposureModeContinouslyAutoExposure,然后监听(键值观察)AVCaptureDevice 的“isAdjustingExposure”属性以了解曝光何时完成调整。一旦完成,将ExposureMode 设置为AVCaptureExposureModeLocked。
希望它能澄清并有所帮助!
| 归档时间: |
|
| 查看次数: |
590 次 |
| 最近记录: |