加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – AVFoundation:isExposureModeSupported为AVCaptureExpos

发布时间:2020-12-14 19:23:34 所属栏目:百科 来源:网络整理
导读:我正在使用AVFoundation构建自定义相机.除了setExposurePointOfInterest之外,一切都很好用. 我在iPhone 5上测试,AVCaptureDevice告诉我BackCamera不支持AVCaptureExposureModeAutoExpose. 然后我如何实施水龙头来调整曝光? 这是我的代码: - (void)didTapCa
我正在使用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];
    }
}

}

解决方法

我在Apple开发者论坛上质疑了类似的问题,并得到了Brad Ford(核心媒体工程)的回答,他是苹果公司WWDC中AV Foundation的Camera Capture发言人.

这是他的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.

希望它澄清并帮助!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读