如何从CVImageBufferRef类型的每个像素获取信息?(OSX)

Ema*_*llo 3 macos isight buffer image pixel

我正在尝试从QT电影的各个帧中提取像素数据.

我想我需要使用CV,因为QTKit和NSImage会太慢......

我需要比较包含网络摄像头当前帧(iSight)的缓冲区(CVImageBufferRef)中图像的每个像素.所以我需要速度.

抱歉我的英语不好,我是意大利语.

Rob*_*ier 6

请参阅问题中的代码如何将CVImageBufferRef转换为UIImage,这是一个更大的问题,但涵盖相同的基础.这是您需要的基本代码(来自该问题的OP):

CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); 
/*Lock the image buffer*/
CVPixelBufferLockBaseAddress(imageBuffer,0); 
/*Get information about the image*/
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer); 
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); 
size_t width = CVPixelBufferGetWidth(imageBuffer); 
size_t height = CVPixelBufferGetHeight(imageBuffer); 

/*We unlock the  image buffer*/
CVPixelBufferUnlockBaseAddress(imageBuffer,0);
Run Code Online (Sandbox Code Playgroud)

请务必阅读已接受的答案,以便更全面地解释数据格式.