gpt4 book ai didi

iphone - AVFoundation 图像变得异常黑暗

转载 作者:行者123 更新时间:2023-11-29 11:24:09 24 4
gpt4 key购买 nike

我正在使用 AVFoundation 自动拍照,但拍出来的照片很暗。如果你在 iPhone 4 上使用闪光灯,后置摄像头还可以,但前置摄像头基本上是一个黑色方 block ,只有图片中物体最模糊的轮廓。

我为两个相机设置了以下设置,但似乎没有什么区别:

if (device.hasFlash) {
NSLog(@"device.hasFlash turning flash mode on");
[device lockForConfiguration:&deviceError];
device.flashMode = AVCaptureFlashModeOn;
[device unlockForConfiguration];
}
else {
NSLog(@"Device does not have Flash");
}

if ([device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) {
NSLog(@"Enabling ContinuousAutoFocus");
[device lockForConfiguration:&deviceError];
device.focusMode = AVCaptureFocusModeContinuousAutoFocus;
[device unlockForConfiguration];
}
else {
NSLog(@"Device does not support ContinuousAutoFocus");
}

if ([device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) {
NSLog(@"Enabling ContinuousAutoExposure");
[device lockForConfiguration:&deviceError];
device.exposureMode = AVCaptureExposureModeContinuousAutoExposure;
[device unlockForConfiguration];
}
else {
NSLog(@"Device does not support ContinuousAutoExposure");
}

if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) {
NSLog(@"Enabling ContinuousAutoWhiteBalance");
[device lockForConfiguration:&deviceError];
device.whiteBalanceMode = AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance;
[device unlockForConfiguration];
}
else {
NSLog(@"Device does not support ContinuousAutoWhiteBalance");
}

有什么想法吗?

最佳答案

前置摄像头需要一段时间来调整其白平衡。您可能需要 KVO isAdjustingWhiteBalance 设备属性,并且仅在属性第一次从 NO 变为 YES 并返回 NO 后触发捕获。

关于iphone - AVFoundation 图像变得异常黑暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4550271/

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