AVCaptureDevice exposureMode不支持?

时间:2013-12-04 23:44:54

标签: iphone objective-c avcapturedevice

我很困惑!

我正在尝试手动调整曝光以使CGPoint适合预览的中心。我正在使用设备对象并使用setExposureMode和setExposurePointOfInterest来进行操作。我要做的第一件事是检查设备是否支持曝光模式。如果不支持则返回。如果支持,则设置值。我的困惑源于设备的值isExposureModeSupported:exposureMode返回NO。但它支持!我有一台iPhone 5c。如果我忽略return语句,我没有收到任何错误。

- (void)device:(AVCaptureDevice *)device exposureMode:(AVCaptureExposureMode)exposureMode  atPoint:(CGPoint)point
{
    BOOL exposureModeSupported = [device isExposureModeSupported:exposureMode];
    if (!exposureModeSupported)
        return;

    if ([device lockForConfiguration:&error]) {
        [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
        [device setExposurePointOfInterest:point];

        CALayer *exposeRect = [CALayer layer];
        exposeRect.frame = CGRectMake(self.center.x-30, self.center.y-30, 60, 60);
        exposeRect.borderColor = [UIColor whiteColor].CGColor;
        exposeRect.borderWidth = 2;
        exposeRect.name = @"exposeRect";
        [self.previewLayer addSublayer:exposeRect];
        [NSTimer scheduledTimerWithTimeInterval: 1
                                         target: self
                                       selector: @selector(dismissExposeRect)
                                       userInfo: nil
                                        repeats: NO];
        [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
        [device unlockForConfiguration];
    }
}

如果我不相信返回的值,如何检查是否支持曝光模式?

我结束了检查,但我不确定这是检查的正确方法。现在的情况如下:

if (![device isExposurePointOfInterestSupported] && ![device isExposureModeSupported:exposureMode])
    return;

有没有其他人遇到过这个问题,有没有人知道如何正确处理这个问题?

提前谢谢。

2 个答案:

答案 0 :(得分:1)

是的,您应该检查exposurePointOfInterestSupportedisExposureModeSupported:

在您的情况下,您正在检查是否支持在函数中作为参数给出的AVCaptureExposureMode,但将曝光设置为AVCaptureExposureModeContinuousAutoExposure,这不一定受支持。

答案 1 :(得分:0)

我想没有人想在这个问题上插话。我结束了检查,但我不确定这是检查的正确方法,但它有效。