修改曝光持续时间后返回AVCaptureExposureModeContinuousAutoExposure后出现奇怪的行为 [英] Strange behaviour after modifying exposure duration and going back to AVCaptureExposureModeContinuousAutoExposure

查看:1043
本文介绍了修改曝光持续时间后返回AVCaptureExposureModeContinuousAutoExposure后出现奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,它使用iOS 8中引入的新API公开相机的手动控件,我正在使用示例应用作为参考。

I am working on an app that exposes manual controls for the camera with the new APIs introduced in iOS 8, and I am using this sample app from WWDC 2014 as a reference.

但是我注意到一个奇怪的行为(在我的5s和6上):将曝光模式设置为自定义然后再返回自动后,图像继续滞后,就像曝光持续时间不受此更改影响一样。

However I noticed a strange bahaviour (on my 5s and on a 6): after setting the exposure mode to "custom" and then back to "auto" the image continues to lag as if the exposure duration was not affected by this change.

以下是每个步骤中涉及的代码(来自示例应用程序,未经任何修改):

Here is the code involved in each step (from the sample app, without any modification):

- (IBAction)changeExposureMode:(id)sender
{
    UISegmentedControl *control = sender;
    NSError *error = nil;
    AVCaptureExposureMode mode = (AVCaptureExposureMode)[self.exposureModes[control.selectedSegmentIndex] intValue];

    if ([self.videoDevice lockForConfiguration:&error])
    {
        if ([self.videoDevice isExposureModeSupported:mode])
        {
            [self.videoDevice setExposureMode:mode];
        }
        else
        {
            NSLog(@"Exposure mode %@ is not supported. Exposure mode is %@.", [self stringFromExposureMode:mode], [self stringFromExposureMode:self.videoDevice.exposureMode]);
        }
    }
    else
    {
        NSLog(@"%@", error);
    }
}


- (IBAction)changeExposureDuration:(id)sender
{
    UISlider *control = sender;
    NSError *error = nil;

    double p = pow( control.value, EXPOSURE_DURATION_POWER ); // Apply power function to expand slider's low-end range
    double minDurationSeconds = MAX(CMTimeGetSeconds(self.videoDevice.activeFormat.minExposureDuration), EXPOSURE_MINIMUM_DURATION);
    double maxDurationSeconds = CMTimeGetSeconds(self.videoDevice.activeFormat.maxExposureDuration);
    double newDurationSeconds = p * ( maxDurationSeconds - minDurationSeconds ) + minDurationSeconds; // Scale from 0-1 slider range to actual duration

    if (self.videoDevice.exposureMode == AVCaptureExposureModeCustom)
    {
        if ( newDurationSeconds < 1 )
        {
            int digits = MAX( 0, 2 + floor( log10( newDurationSeconds ) ) );
            self.exposureDurationValueLabel.text = [NSString stringWithFormat:@"1/%.*f", digits, 1/newDurationSeconds];
        }
        else
        {
            self.exposureDurationValueLabel.text = [NSString stringWithFormat:@"%.2f", newDurationSeconds];
        }
    }

    if ([self.videoDevice lockForConfiguration:&error])
    {
        [self.videoDevice setExposureModeCustomWithDuration:CMTimeMakeWithSeconds(newDurationSeconds, 1000*1000*1000)  ISO:AVCaptureISOCurrent completionHandler:nil];
    }
    else
    {
        NSLog(@"%@", error);
    }
}


推荐答案

我尝试了相同的示例应用程序,并尝试重现该问题,但无法看起来他们现在已修复它。

I tried the same sample app and tried to reproduce the issue but was not able to it looks like they have fixed it now.

这篇关于修改曝光持续时间后返回AVCaptureExposureModeContinuousAutoExposure后出现奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆