【问题标题】:AVCaptureOutput takes dark picture even with flash on即使打开闪光灯,AVCaptureOutput 也会拍摄暗照片
【发布时间】:2011-06-11 00:48:31
【问题描述】:

我提出了 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);

                                                }

                                            }

                                        }];

有什么东西会导致拍摄的图像不包括闪光灯吗?

【问题讨论】:

    标签: ios ios4 avfoundation


    【解决方案1】:

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

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

    【讨论】:

    • 你是怎么做到的?如果我同时观察到adjustingExposure 和adjustingWhiteBalance - 我应该什么时候调用captureStillImageAsynchronouslyFromConnection?直接来自observeValueForKeyPath?
    • 你找到方法了吗?因为我现在在 iPhone 6 上遇到了完全相同的问题。
    猜你喜欢
    • 2016-02-26
    • 2011-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多