convert YUV(4:2:2) format to BMP file

edited November 2016 in How To...

Hello anyone

I working on OV9655 camera modul that is connected to stm32f4discover evaluation board. I am able to capture a picture from the OV9655 module where the video output format is based on RGB565 and save as BMP file on SD cart.

The picture size is 120*160. As I am is aware does YUV(4:2:2) format consist of 4 byte: Yo,Uo,Y1,Vo.

The following register setting is use in OV9655 image chip.

ifdef YUV_MODE

DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OV9655_COM7, OUTPUT_FORMAT_YUV|FORMAT_CTRL_30fpsVGA_VArioPixel); Delay(2); // Line Buffer Test Option // Set up YUV output sequence to UYVY mode DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS,OV9655_TSLB,PCLK_DELAY_6|YUV_OUT_UYVY_MODE); Delay(2); // setup OV9655 Normale RGB mode output mode with data output range [01] to [FE] DCMI_SingleRandomWrite(OV9655_DEVICE_WRITE_ADDRESS, OV9655_COM15, 0x10);

endif

But I am not sure about that above setting for OV9655 is correct.

Follow code is use transform YUV(4:2:2) format to BMP file. The same code work fine during conversation of RGB565 to BMP file.

But is it possible to use the same formular during the conversation of YUV(4:2:2) format to BMP file? Can the same BMP header that is use for RGB565 be use on the YUV(4:2:2) video format?

// QQVGA size(120160). for (j = 0; j < 120; j++) { for(i=0;i<160;i++) { data_temp = frameptr[counter]; // MSB Byte of 16 bit image_buf[i2+1] = (data_temp&0xff00) >> 8; // LSB Byte of 16 bit image_buf[i2+0] = data_temp & 0x00ff; counter++; } ret = f_write(&file, image_buf, 320,(UINT)&bw); }

endif

Tagged:

Answers

Sign In or Register to comment.