不使用OpenCV,将YUV2(YUYV)框架转换为RGB
我正在尝试将V4L2生成的YUV2帧转换为RGB。
我能够使用openCV将YUV2转换为rgb cv2.cvtcolor(im,cv2.color_yuv2rgb_yuyv)
使用OpenCV。
当前混淆:
在没有OPENCV的情况下,如何将YUV2帧转换为RGB。
还有什么例子吗?
I am trying to convert YUV2 frames generated by V4l2 to RGB.
I was able to convert YUV2 to RGB cv2.cvtColor(im, cv2.COLOR_YUV2RGB_YUYV)
using OpenCV.
Currently confuse :
how can I convert a YUV2 frames to RGB without OpenCV.
Also are there any examples out there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
参考此 ,看起来样本是这样的:
这应该意味着,如果您的字节在此规范的数组中排列,
则应使用y,cb和cr值以:
然后您需要调整大小CB,CR样品以匹配Y的宽度。
然后您需要进行一些数学。
Referring to this page, it looks like the samples are arranged like this:
That should mean, if your bytes are arranged in a Numpy array of this specification:
you should be able to extract the Y, Cb and Cr values with:
Then you need to resize up the Cb, Cr samples to match the width of Y.
Then you need to do some maths.
Yuy2使用4个字节来存储2个相邻像素,每个像素都有单独的亮度信息,但是两个像素之间共享颜色信息。
YUV和RGB之间的实际转换有多个定义,例如
这是我多年来一直使用的整数实现
YUY2 uses 4 bytes to store 2 adjacent pixels, where each pixel has a separate luminance information, but the colour information is shared between the two pixels.
There are multiple definitions for the actual conversion between YUV and RGB, e.g. Poynton
Here's an integer-arithmetic implementation that I've been using for years