fastest way to get yuv table in firmware developing

Discussion related to "under the hood" OpenMV topics.
kidswong999
Posts: 33
Joined: Sun Apr 02, 2017 1:12 pm

fastest way to get yuv table in firmware developing

Postby kidswong999 » Mon Oct 22, 2018 1:37 am

Hi, I am developing ntsc/pal shield. And writing driver in C.

viewtopic.php?f=6&t=948

I have done everything, except to send yuv table.

the vs23 chip need VUY 224 streaming,(other format 8bit is OK by setting the chip).

I don't know how to get YUV is the most convenient and most efficient.
User avatar
kwagyeman
Posts: 2401
Joined: Sun May 24, 2015 2:10 pm

Re: fastest way to get yuv table in firmware developing

Postby kwagyeman » Mon Oct 22, 2018 2:04 am

https://github.com/openmv/openmv/blob/m ... rgb2yuv.py ?

https://github.com/openmv/openmv/blob/m ... /yuv_tab.c ?

Um, the best way to send data to the chip is to fb _alloc a large array of bytes for the image size (3 bytes per pixel) and then send that buffer using SPI to the chip. See the py_lcd.c file (under src/omv/py) to see what to do. It's pretty straight forward. The LUT is already on chip with our firmware so just use (for RGB565 image only):

COLOR_RGB565_TO_Y(pixel)
COLOR_RGB565_TO_U(pixel)
COLOR_RGB565_TO_V(pixel)

And you'd put the values in the order they need to be in the buffer and then call the SPI write method to send them in one blast.
Nyamekye,
kidswong999
Posts: 33
Joined: Sun Apr 02, 2017 1:12 pm

Re: fastest way to get yuv table in firmware developing

Postby kidswong999 » Mon Oct 22, 2018 3:10 am

my code:

Code: Select all

uint8_t pixel = IM_GET_GS_PIXEL(arg_img, x, y);
uint8_t y = COLOR_RGB565_TO_Y(pixel);
uint8_t u = COLOR_RGB565_TO_U(pixel);
uint8_t v = COLOR_RGB565_TO_V(pixel);
uint8_t v2 = (v>>0)&0b11000000;        //this maybe wrong
uint8_t u2 = (u>>2)&0b00110000;
uint8_t y4 = (y>>4)&0b00001111;
uint8_t color = y4+u2+v2;
SpiSendReceiveByte(color);
COLOR_RGB565_TO_Y function is a macro.
Maybe the process of packaging yuv into a byte is wrong. :shock:
kidswong999
Posts: 33
Joined: Sun Apr 02, 2017 1:12 pm

Re: fastest way to get yuv table in firmware developing

Postby kidswong999 » Mon Oct 22, 2018 7:16 am

I solved it.
TV can already display the image, then I will adjust the color, and optimize the efficiency :D
Thanks.

Code: Select all

            uint16_t pixel = IM_GET_RGB565_PIXEL(arg_img, x, y);
            //uint8_t pixel = IM_GET_GS_PIXEL(arg_img, x, y);
            int8_t y8 = COLOR_RGB565_TO_Y(pixel);
            int8_t u8 = COLOR_RGB565_TO_U(pixel);
            int8_t v8 = COLOR_RGB565_TO_V(pixel);
            uint8_t y4 = (y8+128)>>4;
            uint8_t v2 = v8>>6;
            uint8_t u2 = u8>>6;
            int8_t color = y4+(u2<<6)+(v2<<4);
            SpiSendReceiveByte(color);
User avatar
kwagyeman
Posts: 2401
Joined: Sun May 24, 2015 2:10 pm

Re: fastest way to get yuv table in firmware developing

Postby kwagyeman » Mon Oct 22, 2018 12:08 pm

Post a video.
Nyamekye,
kidswong999
Posts: 33
Joined: Sun Apr 02, 2017 1:12 pm

Re: fastest way to get yuv table in firmware developing

Postby kidswong999 » Tue Oct 23, 2018 5:30 am

I used a 16bit color and it was slower. The color is wrong and the red color will be displayed in green.
IMG_3704.mov
(5.31 MiB) Downloaded 12 times
User avatar
kwagyeman
Posts: 2401
Joined: Sun May 24, 2015 2:10 pm

Re: fastest way to get yuv table in firmware developing

Postby kwagyeman » Tue Oct 23, 2018 12:01 pm

Mmm, the SPI freq seems to slow?
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests