我使用avfoundation来捕获图像,但是我不能捕获太快(我将间隔时间设置为0.1s)。它说“空样本缓冲区”。问题是什么?谢谢。
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments)
{
// Do something with the attachments.
// NSLog(@"attachements: %@", exifAttachments);
}
else
NSLog(@"no attachments");
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
//use the image
}];
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“*+[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:] - NULL 样本缓冲区。
嗯,它在文档中说:
如果 jpegSampleBuffer 为 NULL 或不是 JPEG 格式,此方法将引发 NSInvalidArgumentException。
所以要么你检查你的imageSampleBuffer
for NULL
或者我所做的,我将整个事情包装在 if 语句检查中:CMSampleBufferIsValid(imageSampleBuffer)
但真的不知道这是否是正确的调用。文档有点稀疏。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)