我嘗試將樣本緩衝區而不是UIImage保存到數組,以便稍後進行轉換。這可以加快圖像捕獲速度,並且可能不會獲得內存警告。我只是不知道如何將其保存到數組,然後再次使用它來調用[self imageFromSampleBuffer:sampleBuffer]。我嘗試過這樣的事情,但是如何將數據轉換回CMSampleBufferRef對象?將sampleBuffer保存在數組中(AVFoundation)
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection {
// Create a UIImage from the sample buffer data
// UIImage *image = [self imageFromSampleBuffer:sampleBuffer];
// [arrCaptures addObject:image];
[arrImageBuffer addObject:[NSData dataWithBytes:sampleBuffer length:sizeof(sampleBuffer)] ];}
謝謝,以及我真的不知道如何做到這一點。我試圖把它放在一個NSValue對象中,並且幾乎讓它工作。我想我有些功課要做。 – Snilleblixten
嘗試製作CFMutableArray,然後執行CFArrayAppendValue(arr,sampleBuffer)。 http://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFMutableArrayRef/Reference/reference.html#//apple_ref/c/func/CFArrayAppendValue – Icydog
它似乎工作與\t \t存儲CFArrayAppendValue(arrCFImageBuffer ,sampleBuffer); 但是,我沒有找到方法讓它回來。這是行不通的:\t \t CMSampleBufferRef imageBuffer = CFArrayGetValueAtIndex(arrCFImageBuffer,currImageIdx); – Snilleblixten