c++ - How to use Magick++ to convert YUYV to RGB? -
reading images device via v4l2. images in yuv 4:2:2 format, aka v4l2_pix_fmt_yuyv, aka yuy2.
what i'd either convert blob of bytes rgb, or better yet how instantiate magick++ image object , tell data in yuyv instead of rgb24.
can done? magick++ documentation bare-bones , provides 0 help: http://www.imagemagick.org/api/magick++/classmagick_1_1image.html
you can convert yuv422
rgb888
. let data
image data load in yuv422
format then:
u = data[0]; y1 = data[1]; v = data[2]; y2 = data[3]; ... ...
and then:
rgb[0] = yuv2rgb(y1, u, v); rgb[1] = yuv2rgb(y2, u, v); ... ...
using following formula yuv2rgb
:
r = y + 1.140*v g = y - 0.395*u - 0.581*v b = y + 2.032*u
Comments
Post a Comment