我使用AVFoundation来捕获图像,但我无法太快地捕获图像(我将时间间隔设置为0.1秒)。它显示“NULL样本缓冲区”。问题出在哪里?谢谢。
[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:] - 空样本缓冲区。'