gpt4 book ai didi

ios - 修改曝光持续时间并返回 AVCaptureExposureModeContinuousAutoExposure 后的奇怪行为

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:37:54 28 4
gpt4 key购买 nike

我正在开发一个应用程序,该应用程序使用 iOS 8 中引入的新 API 公开相机的手动控制,我正在使用这个 sample app来自 WWDC 2014 作为引用。

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

bug

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

- (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);
}
}

最佳答案

我也注意到了这一点。这似乎与较慢的快门速度有关。试试这个:转到自定义。设置较快的快门速度。然后返回自动。繁荣,你就在那里。现在,转到自定义,设置较慢的快门速度(向右滑动)。返回自动,您可以看到快门速度逐渐回到合理的设置。

示例代码和我根据示例代码编写的应用程序都是这种情况。我的4s和5s也是一样的。

我认为这是因为传感器需要捕捉一定数量的图像才能选择正确的自动设置。如果快门速度非常慢(最多 1 秒),这意味着可能需要几秒钟才能找到正确的设置。有点道理,即使不是我们想要的。对我来说幸运的是,如果超过四分之一秒,我的应用程序不需要超过四分之一秒的快门速度。

关于ios - 修改曝光持续时间并返回 AVCaptureExposureModeContinuousAutoExposure 后的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26312634/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com