首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >即使开着闪光灯,AVCaptureOutput也能拍出黑暗的照片

即使开着闪光灯,AVCaptureOutput也能拍出黑暗的照片
EN

Stack Overflow用户
提问于 2011-06-11 08:48:31
回答 1查看 2K关注 0票数 9

我想出了一个AVFoundation和ImageIO的实现来处理我的应用程序中的照片拍摄。然而,我对它有一个问题。即使闪光灯熄灭,我拍摄的照片也总是很暗。下面是我使用的代码:

代码语言:javascript
复制
        [[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);

                                                }

                                            }

                                        }];

有没有什么东西可以导致拍摄的图像不包括闪存?

EN

回答 1

Stack Overflow用户

发布于 2012-06-03 00:07:27

我发现,如果AVCaptureSession是在这次通话之前设置的,我有时会得到较暗的图像。也许自动曝光和白平衡设置需要一段时间才能自动调整。

解决方案是设置AVCaptureSession,然后等待AVCaptureDevice的adjustingExposureadjustingWhiteBalance属性都为NO (使用KVO观察它们),然后再调用-[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection: completionHandler:]

票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6313359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档