我想出了一个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);
}
}
}];有没有什么东西可以导致拍摄的图像不包括闪存?
发布于 2012-06-03 00:07:27
我发现,如果AVCaptureSession是在这次通话之前设置的,我有时会得到较暗的图像。也许自动曝光和白平衡设置需要一段时间才能自动调整。
解决方案是设置AVCaptureSession,然后等待AVCaptureDevice的adjustingExposure和adjustingWhiteBalance属性都为NO (使用KVO观察它们),然后再调用-[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection: completionHandler:]。
https://stackoverflow.com/questions/6313359
复制相似问题