how to convert image from YUV422 to BGR format using IPU in I.MX6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to convert image from YUV422 to BGR format using IPU in I.MX6

2,160 Views
MrHoon89
Contributor I

Hello, I am currently using the i.mx6 quard.

I'm using V4l2 to get image from camera, but I have one problem.

The input image format is YUV 422 format with a size of 1280x720.

I want to convert this image to BGR format, so I converted it to BGR24 using IPU, but the colors are output differently as shown below.

struct v4l2_format fmt;
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24;
fmt.fmt.pix.width = 1280;
fmt.fmt.pix.height = 720;

capture1.PNG

 

However, if the image is received by YUV 422 format and the BGR is converted directly in the application, it is converted well.

struct v4l2_format fmt;
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
fmt.fmt.pix.width = 1280;
fmt.fmt.pix.height = 720;

capture2.PNG

What should i do?

Please help me!!!

Labels (3)
0 Kudos
Reply
3 Replies

2,126 Views
joanxie
NXP TechSupport
NXP TechSupport

you can refer to the IPU CSC source code as attached

0 Kudos
Reply

2,118 Views
MrHoon89
Contributor I

Isn't the IPU CSC code for display?

I don't use the display processor (driver /dev/fb0).

I use only v4l2 capture to get the image buffer and check the RGB values in the image.

Do I need to modify the ipu_ic.c code below?

/*     R = (1.164 * (Y - 16)) + (1.596 * (Cr - 128));
G = (1.164 * (Y - 16)) - (0.392 * (Cb - 128)) - (0.813 * (Cr - 128));
B = (1.164 * (Y - 16)) + (2.017 * (Cb - 128); */
static const uint32_t ycbcr2rgb_coeff[4][3] = {
{149, 0, 204},
{149, 462, 408},
{149, 255, 0},
{8192 - 446, 266, 8192 - 554}, /* A0, A1, A2 */
};

 

0 Kudos
Reply

2,047 Views
joanxie
NXP TechSupport
NXP TechSupport

yes you need to use csc to do the image conversion

0 Kudos
Reply