LCD (4.3inch) Shield sample. While USER_BUTTON0 is pressed, it will save the image to the USB memory.When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Dependencies:   GR-PEACH_video GraphicsFramework R_BSP USBHost mbed

License

When you use this program, we judge you have agreed to the following contents.

本プログラムを使用する際は、以下の内容に合意した事になります。

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Information

Japanese version is available in lower part of this page.

このページの後半に日本語版が用意されています.

What is this ?

This is a sample program that displays the image captured by the camera to the LCD by using the GR-PEACH AUDIO CAMERA Shield and GR-PEACH LCD Shield.
This program displays the NTSC input from NTSC1A on the screen of LCD shield.
When you touch on the screen of LCD Shield, the touch coordinates are displayed on the PC terminal software. You can touch the two points at the same time.
Inaddition, while you press USER_BUTTON0, th image is saved to the USB memory.

Composition

GR-PEACH, AUDIO CAMERA Shield, LCD Shield, Camera and USB memory.

Please refer to following link about Audio/Camera Shield.
https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield

MT9V111 is being used for a camera by this sample program. When using a camera besides MT9V111, please change the setting according to the used camera.

main.cpp (camera input config 1)

/**** User Selection *********/
#define VIDEO_INPUT_METHOD     (VIDEO_CMOS_CAMERA) /* Select  VIDEO_CVBS or VIDEO_CMOS_CAMERA                       */
#define VIDEO_INPUT_FORMAT     (VIDEO_YCBCR422)    /* Select  VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565        */
#define USE_VIDEO_CH           (0)                 /* Select  0 or 1            If selecting VIDEO_CMOS_CAMERA, should be 0.)               */
#define VIDEO_PAL              (0)                 /* Select  0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */

main.cpp (camera input config 2)

    /* MT9V111 camera input config */
    ext_in_config.inp_format     = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */
    ext_in_config.inp_pxd_edge   = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing data          */
    ext_in_config.inp_vs_edge    = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing Vsync signals */
    ext_in_config.inp_hs_edge    = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing Hsync signals */
    ext_in_config.inp_endian_on  = DisplayBase::OFF;                      /* External input bit endian change on/off       */
    ext_in_config.inp_swap_on    = DisplayBase::OFF;                      /* External input B/R signal swap on/off         */
    ext_in_config.inp_vs_inv     = DisplayBase::SIG_POL_NOT_INVERTED;     /* External input DV_VSYNC inversion control     */
    ext_in_config.inp_hs_inv     = DisplayBase::SIG_POL_INVERTED;         /* External input DV_HSYNC inversion control     */
    ext_in_config.inp_f525_625   = DisplayBase::EXTIN_LINE_525;           /* Number of lines for BT.656 external input */
    ext_in_config.inp_h_pos      = DisplayBase::EXTIN_H_POS_CRYCBY;       /* Y/Cb/Y/Cr data string start timing to Hsync reference */
    ext_in_config.cap_vs_pos     = 6;                                     /* Capture start position from Vsync */
    ext_in_config.cap_hs_pos     = 150;                                   /* Capture start position form Hsync */
    ext_in_config.cap_width      = 640;                                   /* Capture width  */
    ext_in_config.cap_height     = 468u;                                  /* Capture height Max 468[line]
                                                                             Due to CMOS(MT9V111) output signal timing and VDC5 specification */


When you save a camera image to a USB memory, the image is converted along the following conversion method.

Value of "VIDEO_INPUT_FORMAT" in main.cppConversion method
VIDEO_YCBCR422JPEG
VIDEO_RGB888bitmap
VIDEO_RGB565binary (RAW data)


If you use a USB, according to the USB port to use, make the following changes and the jumper short. (define 0:USB0、define 1:USB1)

USBHost\USBHost\TARGET_RENESAS\TARGET_RZ_A1H\usb_host_setting.h

#define USB_HOST_CH                           0
↓
#define USB_HOST_CH                           1


If you use the GR-PEACH's USB connector (USB0), please close GR-PEACH's JP3.
/media/uploads/RyoheiHagimoto/usb.jpg

If you use the GR-PEACH AUDIO CAMERA Shield's USB connector (USB1), please close Audio/Camera Shield's JP1.
/media/uploads/dkato/audiocamerashield_jp1.jpg


概要

GR-PEACH AUDIO CAMERA ShieldとGR-PEACH LCD Shieldを使って、カメラで取り込んだ画像をLCDへ表示するサンプルプログラムです。
このプログラムは、NTSC1AからのNTSC入力をLCDシールドの画面上に表示します。
画面をタッチすると、タッチ座標がPCターミナルソフト上に表示されます。2点まで同時にタッチできます。
また、GR-PEACHのUSER_BOTTON0を押している間、カメラで取り込んだ画像をUSBメモリへ保存することができます。

構成

GR-PEACH、AUDIO CAMERA Shield、LCD Shield、 カメラ、USBメモリ

GR-PEACH AUDIO CAMERA Shieldについては下記を参照ください。
https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield

サンプルプログラムではCameraにMT9V111を使用しています。MT9V111以外のCameraを使用する際は使用するCameraにあわせて設定を変更して下さい。

main.cpp (camera input config 1)

/**** User Selection *********/
#define VIDEO_INPUT_METHOD     (VIDEO_CMOS_CAMERA) /* Select  VIDEO_CVBS or VIDEO_CMOS_CAMERA                       */
#define VIDEO_INPUT_FORMAT     (VIDEO_YCBCR422)    /* Select  VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565        */
#define USE_VIDEO_CH           (0)                 /* Select  0 or 1            If selecting VIDEO_CMOS_CAMERA, should be 0.)               */
#define VIDEO_PAL              (0)                 /* Select  0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */

main.cpp (camera input config 2)

    /* MT9V111 camera input config */
    ext_in_config.inp_format     = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */
    ext_in_config.inp_pxd_edge   = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing data          */
    ext_in_config.inp_vs_edge    = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing Vsync signals */
    ext_in_config.inp_hs_edge    = DisplayBase::EDGE_RISING;              /* Clock edge select for capturing Hsync signals */
    ext_in_config.inp_endian_on  = DisplayBase::OFF;                      /* External input bit endian change on/off       */
    ext_in_config.inp_swap_on    = DisplayBase::OFF;                      /* External input B/R signal swap on/off         */
    ext_in_config.inp_vs_inv     = DisplayBase::SIG_POL_NOT_INVERTED;     /* External input DV_VSYNC inversion control     */
    ext_in_config.inp_hs_inv     = DisplayBase::SIG_POL_INVERTED;         /* External input DV_HSYNC inversion control     */
    ext_in_config.inp_f525_625   = DisplayBase::EXTIN_LINE_525;           /* Number of lines for BT.656 external input */
    ext_in_config.inp_h_pos      = DisplayBase::EXTIN_H_POS_CRYCBY;       /* Y/Cb/Y/Cr data string start timing to Hsync reference */
    ext_in_config.cap_vs_pos     = 6;                                     /* Capture start position from Vsync */
    ext_in_config.cap_hs_pos     = 150;                                   /* Capture start position form Hsync */
    ext_in_config.cap_width      = 640;                                   /* Capture width  */
    ext_in_config.cap_height     = 468u;                                  /* Capture height Max 468[line]
                                                                             Due to CMOS(MT9V111) output signal timing and VDC5 specification */


カメラ画像をUSBメモリへ保存する際、以下の変換方法に沿って変換を行なって保存します。

main.cpp内の"VIDEO_INPUT_FORMAT"の値変換方法
VIDEO_YCBCR422JPEG
VIDEO_RGB888bitmap
VIDEO_RGB565binary (RAW data)


USBを使用する場合、使用するUSB口に合わせて、以下の変更とジャンパーショートを行なって下さい。
(define 0:USB0、define 1:USB1)

USBHost\USBHost\TARGET_RENESAS\TARGET_RZ_A1H\usb_host_setting.h

#define USB_HOST_CH                           0
↓
#define USB_HOST_CH                           1


GR-PEACH側のUSB0を使用する場合は、JP3をショートして下さい。
/media/uploads/RyoheiHagimoto/usb.jpg

GR-PEACH AUDIO CAMERA Shield側のUSB1を使用する場合は、JP1をショートして以下の変更を行なって下さい。
/media/uploads/dkato/audiocamerashield_jp1.jpg

Committer:
1050186
Date:
Mon Apr 18 06:52:31 2016 +0000
Revision:
0:a8ad8fee330b
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
1050186 0:a8ad8fee330b 1 /** @file bitmap.h */
1050186 0:a8ad8fee330b 2 #include "mbed.h"
1050186 0:a8ad8fee330b 3
1050186 0:a8ad8fee330b 4 /** A class to communicate a bitmap
1050186 0:a8ad8fee330b 5 *
1050186 0:a8ad8fee330b 6 */
1050186 0:a8ad8fee330b 7 class bitmap {
1050186 0:a8ad8fee330b 8 public:
1050186 0:a8ad8fee330b 9
1050186 0:a8ad8fee330b 10 /** convert RGB888 to bitmap
1050186 0:a8ad8fee330b 11 *
1050186 0:a8ad8fee330b 12 * @param file_name save file name
1050186 0:a8ad8fee330b 13 * @param buf data buffer address
1050186 0:a8ad8fee330b 14 * @param pic_width picture width
1050186 0:a8ad8fee330b 15 * @param pic_height picture height
1050186 0:a8ad8fee330b 16 * @return save data size
1050186 0:a8ad8fee330b 17 */
1050186 0:a8ad8fee330b 18 int Rgb888ToBmp(char * file_name, uint8_t * buf, unsigned long pic_width, unsigned long pic_height) {
1050186 0:a8ad8fee330b 19 unsigned long offset_size = 54;
1050186 0:a8ad8fee330b 20 unsigned long buf_stride = (((pic_width * 4u) + 31u) & ~31u);
1050186 0:a8ad8fee330b 21 unsigned long pic_size = buf_stride * pic_height;
1050186 0:a8ad8fee330b 22 unsigned long file_size = 0;
1050186 0:a8ad8fee330b 23 int save_file_size = 0;
1050186 0:a8ad8fee330b 24 int write_index = (buf_stride * pic_height) - buf_stride;
1050186 0:a8ad8fee330b 25 unsigned long cnt;
1050186 0:a8ad8fee330b 26 uint8_t wk_bitmap_buf[16];
1050186 0:a8ad8fee330b 27 FILE * fp = fopen(file_name, "w");
1050186 0:a8ad8fee330b 28
1050186 0:a8ad8fee330b 29 if (fp != NULL) {
1050186 0:a8ad8fee330b 30 file_size = pic_size + offset_size;
1050186 0:a8ad8fee330b 31
1050186 0:a8ad8fee330b 32 /* BITMAPFILEHEADER */
1050186 0:a8ad8fee330b 33 wk_bitmap_buf[0] = 'B';
1050186 0:a8ad8fee330b 34 wk_bitmap_buf[1] = 'M';
1050186 0:a8ad8fee330b 35 wk_bitmap_buf[2] = (unsigned char)(file_size >> 0); /* bfSize */
1050186 0:a8ad8fee330b 36 wk_bitmap_buf[3] = (unsigned char)(file_size >> 8); /* bfSize */
1050186 0:a8ad8fee330b 37 wk_bitmap_buf[4] = (unsigned char)(file_size >> 16); /* bfSize */
1050186 0:a8ad8fee330b 38 wk_bitmap_buf[5] = (unsigned char)(file_size >> 24); /* bfSize */
1050186 0:a8ad8fee330b 39 wk_bitmap_buf[6] = 0; /* bfReserved1 */
1050186 0:a8ad8fee330b 40 wk_bitmap_buf[7] = 0; /* bfReserved1 */
1050186 0:a8ad8fee330b 41 wk_bitmap_buf[8] = 0; /* bfReserved2 */
1050186 0:a8ad8fee330b 42 wk_bitmap_buf[9] = 0; /* bfReserved2 */
1050186 0:a8ad8fee330b 43 wk_bitmap_buf[10] = (unsigned char)(offset_size >> 0); /* bfOffBits */
1050186 0:a8ad8fee330b 44 wk_bitmap_buf[11] = (unsigned char)(offset_size >> 8); /* bfOffBits */
1050186 0:a8ad8fee330b 45 wk_bitmap_buf[12] = (unsigned char)(offset_size >> 16); /* bfOffBits */
1050186 0:a8ad8fee330b 46 wk_bitmap_buf[13] = (unsigned char)(offset_size >> 24); /* bfOffBits */
1050186 0:a8ad8fee330b 47 fwrite(wk_bitmap_buf, sizeof(char), 14, fp);
1050186 0:a8ad8fee330b 48
1050186 0:a8ad8fee330b 49 /* BITMAPINFOHEADER */
1050186 0:a8ad8fee330b 50 wk_bitmap_buf[0] = 40; /* biSize */
1050186 0:a8ad8fee330b 51 wk_bitmap_buf[1] = 0; /* biSize */
1050186 0:a8ad8fee330b 52 wk_bitmap_buf[2] = 0; /* biSize */
1050186 0:a8ad8fee330b 53 wk_bitmap_buf[3] = 0; /* biSize */
1050186 0:a8ad8fee330b 54 wk_bitmap_buf[4] = (unsigned char)(pic_width >> 0); /* biWidth */
1050186 0:a8ad8fee330b 55 wk_bitmap_buf[5] = (unsigned char)(pic_width >> 8); /* biWidth */
1050186 0:a8ad8fee330b 56 wk_bitmap_buf[6] = (unsigned char)(pic_width >> 16); /* biWidth */
1050186 0:a8ad8fee330b 57 wk_bitmap_buf[7] = (unsigned char)(pic_width >> 24); /* biWidth */
1050186 0:a8ad8fee330b 58 wk_bitmap_buf[8] = (unsigned char)(pic_height >> 0); /* biHeight */
1050186 0:a8ad8fee330b 59 wk_bitmap_buf[9] = (unsigned char)(pic_height >> 8); /* biHeight */
1050186 0:a8ad8fee330b 60 wk_bitmap_buf[10] = (unsigned char)(pic_height >> 16); /* biHeight */
1050186 0:a8ad8fee330b 61 wk_bitmap_buf[11] = (unsigned char)(pic_height >> 24); /* biHeight */
1050186 0:a8ad8fee330b 62 wk_bitmap_buf[12] = 1; /* biPlanes */
1050186 0:a8ad8fee330b 63 wk_bitmap_buf[13] = 0; /* biPlanes */
1050186 0:a8ad8fee330b 64 wk_bitmap_buf[14] = 32; /* biBitCount */
1050186 0:a8ad8fee330b 65 wk_bitmap_buf[15] = 0; /* biBitCount */
1050186 0:a8ad8fee330b 66 fwrite(wk_bitmap_buf, sizeof(char), 16, fp);
1050186 0:a8ad8fee330b 67
1050186 0:a8ad8fee330b 68 wk_bitmap_buf[0] = 0; /* biCopmression */
1050186 0:a8ad8fee330b 69 wk_bitmap_buf[1] = 0; /* biCopmression */
1050186 0:a8ad8fee330b 70 wk_bitmap_buf[2] = 0; /* biCopmression */
1050186 0:a8ad8fee330b 71 wk_bitmap_buf[3] = 0; /* biCopmression */
1050186 0:a8ad8fee330b 72 wk_bitmap_buf[4] = (unsigned char)(pic_size >> 0); /* biSizeImage */
1050186 0:a8ad8fee330b 73 wk_bitmap_buf[5] = (unsigned char)(pic_size >> 8); /* biSizeImage */
1050186 0:a8ad8fee330b 74 wk_bitmap_buf[6] = (unsigned char)(pic_size >> 16); /* biSizeImage */
1050186 0:a8ad8fee330b 75 wk_bitmap_buf[7] = (unsigned char)(pic_size >> 24); /* biSizeImage */
1050186 0:a8ad8fee330b 76 wk_bitmap_buf[8] = 0; /* biXPixPerMeter */
1050186 0:a8ad8fee330b 77 wk_bitmap_buf[9] = 0; /* biXPixPerMeter */
1050186 0:a8ad8fee330b 78 wk_bitmap_buf[10] = 0; /* biXPixPerMeter */
1050186 0:a8ad8fee330b 79 wk_bitmap_buf[11] = 0; /* biXPixPerMeter */
1050186 0:a8ad8fee330b 80 wk_bitmap_buf[12] = 0; /* biYPixPerMeter */
1050186 0:a8ad8fee330b 81 wk_bitmap_buf[13] = 0; /* biYPixPerMeter */
1050186 0:a8ad8fee330b 82 wk_bitmap_buf[14] = 0; /* biYPixPerMeter */
1050186 0:a8ad8fee330b 83 wk_bitmap_buf[15] = 0; /* biYPixPerMeter */
1050186 0:a8ad8fee330b 84 fwrite(wk_bitmap_buf, sizeof(char), 16, fp);
1050186 0:a8ad8fee330b 85
1050186 0:a8ad8fee330b 86 wk_bitmap_buf[0] = 0; /* biClrUsed */
1050186 0:a8ad8fee330b 87 wk_bitmap_buf[1] = 0; /* biClrUsed */
1050186 0:a8ad8fee330b 88 wk_bitmap_buf[2] = 0; /* biClrUsed */
1050186 0:a8ad8fee330b 89 wk_bitmap_buf[3] = 0; /* biClrUsed */
1050186 0:a8ad8fee330b 90 wk_bitmap_buf[4] = 0; /* biCirImportant */
1050186 0:a8ad8fee330b 91 wk_bitmap_buf[5] = 0; /* biCirImportant */
1050186 0:a8ad8fee330b 92 wk_bitmap_buf[6] = 0; /* biCirImportant */
1050186 0:a8ad8fee330b 93 wk_bitmap_buf[7] = 0; /* biCirImportant */
1050186 0:a8ad8fee330b 94 fwrite(wk_bitmap_buf, sizeof(char), 8, fp);
1050186 0:a8ad8fee330b 95
1050186 0:a8ad8fee330b 96 save_file_size = 54;
1050186 0:a8ad8fee330b 97 for (cnt = 0; cnt < pic_height; cnt ++) {
1050186 0:a8ad8fee330b 98 save_file_size += fwrite(&buf[write_index], sizeof(char), buf_stride, fp);
1050186 0:a8ad8fee330b 99 write_index -= buf_stride;
1050186 0:a8ad8fee330b 100 }
1050186 0:a8ad8fee330b 101 fclose(fp);
1050186 0:a8ad8fee330b 102 }
1050186 0:a8ad8fee330b 103
1050186 0:a8ad8fee330b 104 return (int)save_file_size;
1050186 0:a8ad8fee330b 105 };
1050186 0:a8ad8fee330b 106 };