【发布时间】:2017-10-06 17:47:00
【问题描述】:
我想捕获原始像素数据以使用 GPUImage 框架进行操作。我像这样捕获数据:
CVImageBufferRef cameraFrame = CMSampleBufferGetImageBuffer(imageSampleBuffer);
CVPixelBufferLockBaseAddress(cameraFrame, 0);
GLubyte *rawImageBytes = CVPixelBufferGetBaseAddress(cameraFrame);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(cameraFrame);
NSData *dataForRawBytes = [NSData dataWithBytes:rawImageBytes length:bytesPerRow * CVPixelBufferGetHeight(cameraFrame)];
//raw values
UInt32 *values = [dataForRawBytes bytes];//, cnt = [dataForRawBytes length]/sizeof(int);
//test out dropbox upload here
[self uploadDropbox:dataForRawBytes];
//end of dropbox upload
// Do whatever with your bytes
// [self processImages:dataForRawBytes];
CVPixelBufferUnlockBaseAddress(cameraFrame, 0); }];
我正在使用以下相机设置:
NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecJPEG, AVVideoCodecKey,[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil];
出于测试目的,我想将捕获的图像保存到保管箱,为此我需要将其保存到 tmp 目录,我将如何保存 dataForRawBytes? 任何帮助将不胜感激!
【问题讨论】:
-
'UIImage *image = [UIImage imageWithData:[self imageToBuffer:sampleBuffer]];'我正在尝试这个,但它给了我零,我不知道为什么?
标签: ios iphone uiimage avcapturesession