Pie*_*ult 9 avfoundation ios4 ios
我想出了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);
}
}
}];
Run Code Online (Sandbox Code Playgroud)
有没有什么可以导致图像不包括闪光灯?
mrw*_*ker 14
我发现如果在此次通话之前立即设置了AVCaptureSession,我有时会出现黑暗图像.也许自动曝光和白平衡设置需要一段时间才能自行调整.
解决方案是设置AVCaptureSession,然后在调用之前等待AVCaptureDevice adjustingExposure和adjustingWhiteBalance属性NO(用KVO观察)-[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection: completionHandler:].
| 归档时间: |
|
| 查看次数: |
1917 次 |
| 最近记录: |