gpt4 book ai didi

ios - 即使打开闪光灯,AVCaptureOutput 也会拍出黑暗的照片

转载 作者:技术小花猫 更新时间:2023-10-29 11:17:14 24 4
gpt4 key购买 nike

我想出了一个 AVFoundation 和 ImageIO 的实现来处理我的应用程序中的照片拍摄。但是,我对此有疑问。我拍摄的图像总是很暗,即使闪光灯熄灭也是如此。这是我使用的代码:

        [[self currentCaptureOutput] captureStillImageAsynchronouslyFromConnection:[[self currentCaptureOutput].connections lastObject]
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

[[[blockSelf currentPreviewLayer] session] stopRunning];
if (!error) {
NSData *data = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef) data, NULL);

if (source) {

UIImage *image = [blockSelf imageWithSource:source];
[blockSelf updateWithCapturedImage:image];
CFRelease(source);

}

}

}];

是否有任何可能导致拍摄的图像不包括闪光灯?

最佳答案

我发现如果在此调用之前立即设置 AVCaptureSession,我有时会得到暗图像。自动曝光和白平衡设置可能需要一段时间才能自行调整。

解决方案是设置 AVCaptureSession,然后等到 AVCaptureDevice 的 adjustingExposureadjustingWhiteBalance 属性都为 NO(用 KVO 观察这些) 在调用 -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection: completionHandler:] 之前。

关于ios - 即使打开闪光灯,AVCaptureOutput 也会拍出黑暗的照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6313359/

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