如何获取原始YUV420p相机数据 [英] how to fetch raw YUV420p camera data

查看:1201
本文介绍了如何获取原始YUV420p相机数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道使用哪个值来获取原始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 或 NV12



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, 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)...

这篇关于如何获取原始YUV420p相机数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆