作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我想出了一个 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);
}
}
}];
是否有任何可能导致拍摄的图像不包括闪光灯?
最佳答案
我发现如果在此调用之前立即设置 AVCaptureSession,我有时会得到暗图像。自动曝光和白平衡设置可能需要一段时间才能自行调整。
解决方案是设置 AVCaptureSession,然后等到 AVCaptureDevice 的 adjustingExposure
和 adjustingWhiteBalance
属性都为 NO
(用 KVO 观察这些) 在调用 -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection: completionHandler:]
之前。
关于ios - 即使打开闪光灯,AVCaptureOutput 也会拍出黑暗的照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6313359/
我正在.vimrc中用这些配置我的vim colorscheme。 "Color scheme syntax enable set background = dark colorsche
我是一名优秀的程序员,十分优秀!