how to fetch raw YUV420p camera data

蹲街弑〆低调 提交于 2019-12-25 02:32:45

问题


I don't know which value to use to fetch raw YUV420p data. code below first:

AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
output.alwaysDiscardsLateVideoFrames = YES;
output.videoSettings = @{(id)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]};
//output.videoSettings = @{(id)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]};

dispatch_queue_t queue;
queue = dispatch_queue_create("CameraQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];

[session addOutput:output];

I noticed that kCVPixelFormatType has some values, does somebody know which value is right to fetch raw YUV420p data?

kCVPixelFormatType_420YpCbCr8Planar
kCVPixelFormatType_420YpCbCr8PlanarFullRange
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
kCVPixelFormatType_420YpCbCr8BiPlanarFullRange

can be one of them?


回答1:


It depends on which particular YUV420 you want to get: Planar/Biplanar refers to the arrangement of the luma and chroma components in memory, Planar meaning that each component comes in a buffer, contiguous or not, and Biplanar pointing to two buffers, one for luma and another for chroma, usually interleaved. An example of Planar is YUV420 format and an example of Biplanar is NV21 or NV12

VideoRange and FullRange refers to the values of the luma component, Video referring to [16,235] accepted levels and FullRange to [0,255]. This confusing agreement comes from the MPEG standard (see here)...



来源:https://stackoverflow.com/questions/24113392/how-to-fetch-raw-yuv420p-camera-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!