问题描述
我不知道使用哪个值来获取原始YUV420p数据。下面第一个代码:
AVCaptureVideoDataOutput *输出= [[AVCaptureVideoDataOutput的alloc]初始化];
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];
我注意到kCVPixelFormatType具有一定的价值,是否有人知道哪个值是正确的,取原始YUV420P数据?
kCVPixelFormatType_420YpCbCr8Planar
kCVPixelFormatType_420YpCbCr8PlanarFullRange
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
解决方案这取决于你想得到的特定YUV420:
Planar
/Biplanar
亮度和色度分量,Planar
意味着每个组件都在一个缓冲区中,连续或不连续,Biplanar
到两个缓冲器,一个用于亮度,另一个用于色度,通常是交织的。的一个例子平面
YUV420 格式和示例双平面
NV21 或
VideoRange
和FullRange
是指luma组件的值,Video
引用[16,235]接受的级别,并将FullRange
更改为[0,255]。这种混乱的协议来自于MPEG标准()...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?
解决方案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, andBiplanar
pointing to two buffers, one for luma and another for chroma, usually interleaved. An example ofPlanar
is YUV420 format and an example ofBiplanar
is NV21 or NV12
VideoRange
andFullRange
refers to the values of the luma component,Video
referring to [16,235] accepted levels andFullRange
to [0,255]. This confusing agreement comes from the MPEG standard (see here)...这篇关于如何获取原始YUV420p相机数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!