Ios AVCaptureOutput即使在闪光灯打开的情况下也会拍摄暗照片
我已经提出了一个AVFoundation和ImageIO的实现来处理我的应用程序中的照片拍摄。然而,我对此有异议。我拍摄的图像总是很暗,即使闪光灯熄灭。以下是我使用的代码:Ios AVCaptureOutput即使在闪光灯打开的情况下也会拍摄暗照片,ios,ios4,avfoundation,Ios,Ios4,Avfoundation,我已经提出了一个AVFoundation和ImageIO的实现来处理我的应用程序中的照片拍摄。然而,我对此有异议。我拍摄的图像总是很暗,即使闪光灯熄灭。以下是我使用的代码: [[self currentCaptureOutput] captureStillImageAsynchronouslyFromConnection:[[self currentCaptureOutput].connections lastObject]
[[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的
adjustingExposure
和adjustingWhiteBalance
属性都是NO
(使用KVO观察这些属性),然后调用-[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:]
你是怎么做到的?如果我同时观察到调整曝光和调整白平衡-我应该在什么时候从连接异步调用CaptureStillImageAsynchronously?直接从observeValueForKeyPath?你找到怎么做了吗?因为我的iphone6现在也有同样的问题。