RT1170 camera CSI Y8 format modification

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

RT1170 camera CSI Y8 format modification

RT1170 camera CSI Y8 format modification

RT1170 camera CSI Y8 format modification

1.Abstract

RT1170's CSI can support YUV format. The so-called YUV is divided into three components: Y represents luminance, that is, grayscale value; UV represents chrominance, which describes chroma and saturation. Similar to RGB, YUV is also a color encoding method, which can separate luminance information Y from chroma information UV. If you want to display black and white, you can have no UV information, only Y information, that is, Y800=Y8, and you can also display the complete image. For RT1170 YUV, the official SDK provides demo based on the YUV444 format, but in actual use, some customers need the function of the Y8 format, so how should they configure it based on the existing YUV SDK?

From the reference manual of RT1170, you can see the following information:

1.jpg

Fig 1

This description can be understood as requiring the Y8 mode, as long as the configuration:

CSI_CR20[BINARY_EN]=0
CSI_CR20[BIG_END]=1

However, in reality, with this configuration, the original YUV code cannot display the camera data. So how should the camera's Y8 configuration be done to display black and white images on the LCD? This article will give a detailed explanation.

2. RT1170 CSI Camera Y8 format configuration and testing

2.1 Hardware and software situation

Board:MIMXRT1170-EVK REV C4

LCD:  RK055AHD091

Camera:OV5640

Code:SDK_2_15_000_MIMXRT1170-EVK\boards\evkmimxrt1170\driver_examples\csi\mipi_yuv\cm7

IDE: MCUXPresso IDE v11.9.0

2.2 Y8 formation configuration

  In fact, for CSI_CR20 configuration, you also need to enable the Histogram function, which is the following register bits:

2.jpg

Fig 2

Here, based on the current SDK demo evkmimxrt1170_csi_mipi_yuv_cm7 demo, modify it to the Y8 format, list the modification points, mainly modify the file:csi_mipi_yuv.c

(1) static void DEMO_InitPxp(void)

Modify:

   PXP_SetCsc1Mode(DEMO_PXP, kPXP_Csc1YCbCr2RGB);

To:

    PXP_SetCsc1Mode(DEMO_PXP, kPXP_Csc1YUV2RGB);

If this item is not modified, LCD will just display the Green color.

(2)static void DEMO_InitCamera(void)

Before BOARD_InitMipiCsi(); Add the this code:

CSI->CR20 |= CSI_CR20_QRCODE_EN_MASK | CSI_CR20_HISTOGRAM_EN_MASK;

Here, didn’t configure CSI_CR20[BINARY_EN]=0, as after reseting, this bit is default to 0. If in the practical usage, this bit is modified to 1, then here, need to modify BINARY_EN to 0, it means the format is Y8, not Y1.

The reason that can’t display the correct Y8 previously, is caused by the bit HISTOGRAM_EN is not set.

(3) static void DEMO_CSI_MIPI_YUV(void)

Modify structure psBufferConfig as follows:

    pxp_ps_buffer_config_t psBufferConfig = {
        .pixelFormat = kPXP_PsPixelFormatY8, //kPXP_PsPixelFormatYUV1P444, /* Note: This is 32-bit per pixel */
        .swapByte    = false,
        .bufferAddrU = 0U,
        .bufferAddrV = 0U,
        .pitchBytes  = DEMO_CAMERA_WIDTH,//DEMO_CAMERA_WIDTH * DEMO_CAMERA_BUFFER_BPP,//
};

Mainly 2 points:

.pixelFormat = kPXP_PsPixelFormatY8,

.pitchBytes  = DEMO_CAMERA_WIDTH,

If you only change the pixel format to Y8, but pitchBytes is not changed to the camera width, the resulting LCD display will be a small strip on the top, instead of the entire LCD screen showing the camera's Y8 format black and white image.

So far, all Y8-related modification projects have been completed.

Finally, it should be noted that the default SDK LCD display is not the one selected in this article: RK055AHD091.

So you need to modify the DEMO_PANEL macro in display_support.h to the following:

#define DEMO_PANEL DEMO_PANEL_RK055AHD091

Then, build the project, and download it to the board MIMXRT1170-EVK.

2.3 Test result after modification

Below we use the same color picture to test the YUV and Y8 display effects in front of the camera. here are the pictures: 

en.jpg

the camera format of the picture on the left is YUV444, and the picture on the right is in Y8 format. You can see that the left one is in color, and the right one is in black and white. The black and white Y8 camera data acquisition and LCD display have been successfully completed.

Attachments
No ratings
Version history
Last update:
Thursday
Updated by: