Example programs for GR-MANGO

Dependencies:   opencv-lib mbed-http

This is a collection of sample programs that work on RZ/A2M boards. You can try Mbed OS for RZ/A2M with GR-MANGO board.

Overview

Sample program files are located under the sample_programs folder. You can try each sample program by changing the following macro in sample_select.h.

insample_select.h

#define SAMPLE_PROGRAM_NO  0
No.Program fileDescription
0sample_00_led_rtc_analogin.cppDigitalOut, InterruptIn, RTC, Timer and AnalogIn
1sample_01_flash_write.cppFlashAPI sample
2sample_02_ssif_loop_back.cppSSIF loop back sample
4sample_04_ssif_wav_playback.cppSSIF wav playback sample (use USB memory or SD card)
7sample_07_usb_func_serial.cppUSBSerial (CDC) sample
8sample_08_usb_func_mouse.cppUSBMouse sample
9sample_09_usb_func_keyboard.cppUSBKeyboard sample
10sample_10_usb_func_midi.cppUSBMIDI sample
11sample_11_usb_func_audio_1.cppUSBAudio sample
12sample_12_usb_func_audio_2.cppUSBAudio and SSIF sample
13sample_13_ether_http.cppEther HTTP sample
14sample_14_ether_https.cppEther HTTPS sample
16sample_16_usb_func_msd_1.cppUSBMSD and FlashAPI sample
17sample_17_usb_func_msd_2.cppUSBMSD and FlashAPI sample advanced version
18sample_18_mipi_drp_lcd.cppMIPI, DRP and LCD sample
19sample_19_mipi_drp_diplayapp.cppMIPI, DRP and USBSerial (CDC) sample (use "DisplayApp")
20sample_20_drp_dynamic_loading.cppDRP Dynamic Loading Sample
21sample_21_deep_standby_alarm.cppDeep standby and RTC alarm sample
22sample_22_hdmi_disp_ssif.cppHDMI output and SSIF wav playback Sample
23sample_23_mipi_hdmi.cppHDMI output and MIPI Sample
24sample_24_facedetection.cppHDMI output and face detection using OpenCV
25sample_25_hdmi_mouse.cppHDMI output and Mouse Sample

Notice

sample_24_facedetection.cpp only can be compiled with GNU Compiler Collection.

About sample_24_facedetection.cpp, this is a demonstration that can detect the face of a person without a mask. It will surround the face of a person without a mask with a red rectangle and sound alarm at the same time. To use OpenCV for face recognition, you need to prepare the followings:
・USB drive or SD card
・ Raspberry Pi Camera Module V2
・ HDMI monitor

Perform the following steps to complete face recognition sample.
1. Copy the lbpcascade_frontalface.xml to the root folder of USB drive or SD card and save it.
2. Copy the alarm.wav to the root folder of USB drive or SD card and save it.
3. Set "camera-type" value to "CAMERA_RASPBERRY_PI_832X480" in mbed_app.json

About custom boot loaders

This sample uses custom bootloader revision 5, and you can drag & drop the "xxxx_application.bin" file to write the program. Please see here for the detail.

How to write program

When using DAPLink, please use xxxx.bin as following.

  1. Connect the micro USB type B terminal to the PC using a USB cable.
  2. You can find the MBED directory.
  3. Drag & drop xxxx.bin to the MBED directory.
  4. When writing is completed, press the reset button.

When using custom bootloader, please use xxxx_application.bin as following.

  1. Connect the USB type C terminal to the PC using a USB cable.
  2. Hold down USB0 and press the reset button.
  3. You can find the GR-MANG directory.
  4. Drag & drop xxxx_application.bin to the GR-MANGO directory.

When writing is completed, press the reset button.

Attention!

For the first time only, you need to write a custom bootloader using DAPLink.

Terminal setting

If you want to confirm the serial communication the terminal soft on your PC, please specify the below values. You can change the baud rate by platform.stio-baud-rate of mbed_app.json.

Baud rate115,200
Data8bit
Paritynone
Stop1bit
Flow controlnone
Committer:
luyao@os.mbed.com
Date:
Thu Mar 04 18:22:21 2021 +0900
Revision:
16:f4798796b4a2
Parent:
4:2da9e0f275a1
Modified EP952 Parameters.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 1 /*******************************************************************************
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 2 * DISCLAIMER
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 3 * This software is supplied by Renesas Electronics Corporation and is only
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 4 * intended for use with Renesas products. No other uses are authorized. This
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 5 * software is owned by Renesas Electronics Corporation and is protected under
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 6 * all applicable laws, including copyright laws.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 16 * Renesas reserves the right, without notice, to make changes to this software
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 17 * and to discontinue the availability of this software. By using this software,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 18 * you agree to the additional terms and conditions found by accessing the
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 19 * following link:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 20 * http://www.renesas.com/disclaimer
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 21 *
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 22 * Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 23 *******************************************************************************/
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 24 #include "sample_select.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 25
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 26 #if (SAMPLE_PROGRAM_NO == 20)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 27 // SAMPLE_PROGRAM_NO 20 : DRP Dynamic Loading Sample
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 28 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 29 // Detects the edges of the input image from MIPI camera by Canny method using DRP and outputs to display.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 30 // Please refer to the document for details. (RZ_A2M_Mbed\drp-for-mbed\r_drp\doc)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 31 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 32 // Please set the value of "camera-type" in "mbed_app.json" to null or "CAMERA_RASPBERRY_PI".
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 33 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 34 // "camera-type":{
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 35 // "help": "Please see EasyAttach_CameraAndLCD/README.md",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 36 // "value": null
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 37 // },
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 38 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 39 // or
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 40 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 41 // "camera-type":{
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 42 // "help": "Please see EasyAttach_CameraAndLCD/README.md",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 43 // "value": "CAMERA_RASPBERRY_PI"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 44 // },
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 45 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 46 // Requirements
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 47 // RZ/A2M Evaluation Board Kit : Display Output Board
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 48 // SBEV-RZ/A2M : LVDS To HDMI Board
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 49 // SEMB1402 : LVDS To HDMI Board
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 50
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 51 #if !defined(TARGET_RZ_A2XX)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 52 #error "DRP and MIPI are not supported."
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 53 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 54 #if MBED_CONF_APP_CAMERA_TYPE != CAMERA_RASPBERRY_PI
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 55 #error Please set the value of "camera-type" in "mbed_app.json" to "CAMERA_RASPBERRY_PI" and build.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 56 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 57
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 58 #include "mbed.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 59 #include "EasyAttach_CameraAndLCD.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 60 #include "dcache-control.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 61 #include "AsciiFont.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 62 #include "r_dk2_if.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 63 #include "r_drp_bayer2grayscale.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 64 #include "r_drp_median_blur.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 65 #include "r_drp_canny_calculate.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 66 #include "r_drp_canny_hysterisis.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 67
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 68 #define RAM_TABLE_DYNAMIC_LOADING 1
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 69
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 70 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 71 in accordance with the frame buffer burst transfer mode. */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 72 #define VIDEO_PIXEL_HW (640)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 73 #define VIDEO_PIXEL_VW (480)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 74
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 75 #define DATA_SIZE_PER_PIC (1u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 76 #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 77 #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 78
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 79 #define DRP_FLG_TILE_ALL (R_DK2_TILE_0 | R_DK2_TILE_1 | R_DK2_TILE_2 | R_DK2_TILE_3 | R_DK2_TILE_4 | R_DK2_TILE_5)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 80 #define DRP_FLG_CAMER_IN (0x00000100)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 81
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 82 static DisplayBase Display;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 83 static uint8_t fbuf_bayer[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(128)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 84 static uint8_t fbuf_work0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 85 static uint8_t fbuf_work1[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 86 static uint8_t fbuf_clat8[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 87 static uint8_t fbuf_overlay[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 88 static uint8_t drp_work_buf[((FRAME_BUFFER_STRIDE * ((FRAME_BUFFER_HEIGHT / 3) + 2)) * 2) * 3]__attribute((section("NC_BSS")));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 89 static uint8_t nc_memory[512] __attribute((section("NC_BSS")));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 90 static uint8_t drp_lib_id[R_DK2_TILE_NUM] = {0};
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 91 static Thread drpTask(osPriorityHigh);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 92
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 93 #if RAM_TABLE_DYNAMIC_LOADING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 94 static uint8_t ram_drp_lib_bayer2grayscale[sizeof(g_drp_lib_bayer2grayscale)]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 95 static uint8_t ram_drp_lib_median_blur[sizeof(g_drp_lib_median_blur)]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 96 static uint8_t ram_drp_lib_canny_calculate[sizeof(g_drp_lib_canny_calculate)]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 97 static uint8_t ram_drp_lib_canny_hysterisis[sizeof(g_drp_lib_canny_hysterisis)]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 98 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 99
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 100 static const uint32_t clut_data_resut[] = {0x00000000, 0xff00ff00}; // ARGB8888
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 101
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 102 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 103 drpTask.flags_set(DRP_FLG_CAMER_IN);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 104 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 105
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 106 static void cb_drp_finish(uint8_t id) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 107 uint32_t tile_no;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 108 uint32_t set_flgs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 109
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 110 // Change the operation state of the DRP library notified by the argument to finish
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 111 for (tile_no = 0; tile_no < R_DK2_TILE_NUM; tile_no++) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 112 if (drp_lib_id[tile_no] == id) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 113 set_flgs |= (1 << tile_no);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 114 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 115 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 116 drpTask.flags_set(set_flgs);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 117 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 118
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 119 static void Start_Video_Camera(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 120 // Video capture setting (progressive form fixed)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 121 Display.Video_Write_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 122 DisplayBase::VIDEO_INPUT_CHANNEL_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 123 DisplayBase::COL_SYS_NTSC_358,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 124 (void *)fbuf_bayer,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 125 FRAME_BUFFER_STRIDE,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 126 DisplayBase::VIDEO_FORMAT_RAW8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 127 DisplayBase::WR_RD_WRSWA_NON,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 128 VIDEO_PIXEL_VW,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 129 VIDEO_PIXEL_HW
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 130 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 131 EasyAttach_CameraStart(Display, DisplayBase::VIDEO_INPUT_CHANNEL_0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 132 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 133
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 134 static void Start_LCD_Display(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 135 DisplayBase::rect_t rect;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 136 DisplayBase::clut_t clut_param;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 137
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 138 rect.vs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 139 rect.vw = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 140 rect.hs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 141 rect.hw = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 142 Display.Graphics_Read_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 143 DisplayBase::GRAPHICS_LAYER_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 144 (void *)fbuf_clat8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 145 FRAME_BUFFER_STRIDE,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 146 DisplayBase::GRAPHICS_FORMAT_CLUT8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 147 DisplayBase::WR_RD_WRSWA_32_16_8BIT,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 148 &rect
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 149 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 150 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 151
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 152 memset(fbuf_overlay, 0, sizeof(fbuf_overlay));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 153 clut_param.color_num = sizeof(clut_data_resut) / sizeof(uint32_t);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 154 clut_param.clut = clut_data_resut;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 155
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 156 rect.vs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 157 rect.vw = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 158 rect.hs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 159 rect.hw = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 160 Display.Graphics_Read_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 161 DisplayBase::GRAPHICS_LAYER_2,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 162 (void *)fbuf_overlay,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 163 FRAME_BUFFER_STRIDE,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 164 DisplayBase::GRAPHICS_FORMAT_CLUT8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 165 DisplayBase::WR_RD_WRSWA_32_16_8BIT,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 166 &rect,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 167 &clut_param
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 168 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 169 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 170
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 171 ThisThread::sleep_for(50);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 172 EasyAttach_LcdBacklight(true);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 173 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 174
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 175 static void drp_task(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 176 uint32_t idx;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 177 uint32_t drp_time[8];
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 178 char str[64];
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 179 Timer t;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 180 AsciiFont ascii_font(fbuf_overlay, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, FRAME_BUFFER_STRIDE, DATA_SIZE_PER_PIC);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 181
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 182 EasyAttach_Init(Display);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 183 Start_LCD_Display();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 184 // Interrupt callback function setting (Field end signal for recording function in scaler 0)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 185 Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 186 Start_Video_Camera();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 187
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 188 #if RAM_TABLE_DYNAMIC_LOADING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 189 // Copy to RAM to increase the speed of dynamic loading.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 190 memcpy(ram_drp_lib_bayer2grayscale, g_drp_lib_bayer2grayscale, sizeof(ram_drp_lib_bayer2grayscale));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 191 memcpy(ram_drp_lib_median_blur, g_drp_lib_median_blur, sizeof(ram_drp_lib_median_blur));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 192 memcpy(ram_drp_lib_canny_calculate, g_drp_lib_canny_calculate, sizeof(ram_drp_lib_canny_calculate));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 193 memcpy(ram_drp_lib_canny_hysterisis, g_drp_lib_canny_hysterisis, sizeof(ram_drp_lib_canny_hysterisis));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 194 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 195
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 196 R_DK2_Initialize();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 197
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 198 t.start();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 199
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 200 while (true) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 201 ThisThread::flags_wait_all(DRP_FLG_CAMER_IN);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 202
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 203 /* Load DRP Library */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 204 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 205 /* tile 0 | Bayer2Grayscale | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 206 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 207 /* tile 1 | Bayer2Grayscale | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 208 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 209 /* tile 2 | Bayer2Grayscale | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 210 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 211 /* tile 3 | Bayer2Grayscale | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 212 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 213 /* tile 4 | Bayer2Grayscale | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 214 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 215 /* tile 5 | Bayer2Grayscale | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 216 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 217 /* fbuf_bayer -> fbuf_work0 */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 218 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 219 R_DK2_Load(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 220 #if RAM_TABLE_DYNAMIC_LOADING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 221 ram_drp_lib_bayer2grayscale,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 222 #else
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 223 g_drp_lib_bayer2grayscale,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 224 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 225 R_DK2_TILE_0 | R_DK2_TILE_1 | R_DK2_TILE_2 | R_DK2_TILE_3 | R_DK2_TILE_4 | R_DK2_TILE_5,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 226 R_DK2_TILE_PATTERN_1_1_1_1_1_1, NULL, &cb_drp_finish, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 227 R_DK2_Activate(0, 0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 228 drp_time[0] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 229
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 230 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 231 r_drp_bayer2grayscale_t * param_b2g = (r_drp_bayer2grayscale_t *)nc_memory;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 232 for (idx = 0; idx < R_DK2_TILE_NUM; idx++) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 233 param_b2g[idx].src = (uint32_t)fbuf_bayer + (VIDEO_PIXEL_HW * (VIDEO_PIXEL_VW / R_DK2_TILE_NUM) * idx);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 234 param_b2g[idx].dst = (uint32_t)fbuf_work0 + (VIDEO_PIXEL_HW * (VIDEO_PIXEL_VW / R_DK2_TILE_NUM) * idx);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 235 param_b2g[idx].width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 236 param_b2g[idx].height = VIDEO_PIXEL_VW / R_DK2_TILE_NUM;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 237 param_b2g[idx].top = (idx == 0) ? 1 : 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 238 param_b2g[idx].bottom = (idx == 5) ? 1 : 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 239 R_DK2_Start(drp_lib_id[idx], (void *)&param_b2g[idx], sizeof(r_drp_bayer2grayscale_t));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 240 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 241 ThisThread::flags_wait_all(DRP_FLG_TILE_ALL);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 242 R_DK2_Unload(0, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 243 drp_time[1] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 244
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 245
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 246 /* Load DRP Library */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 247 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 248 /* tile 0 | MedianBlur | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 249 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 250 /* tile 1 | MedianBlur | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 251 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 252 /* tile 2 | MedianBlur | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 253 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 254 /* tile 3 | MedianBlur | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 255 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 256 /* tile 4 | MedianBlur | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 257 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 258 /* tile 5 | MedianBlur | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 259 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 260 /* fbuf_work0 -> fbuf_work1 */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 261 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 262 R_DK2_Load(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 263 #if RAM_TABLE_DYNAMIC_LOADING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 264 ram_drp_lib_median_blur,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 265 #else
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 266 g_drp_lib_median_blur,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 267 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 268 R_DK2_TILE_0 | R_DK2_TILE_1 | R_DK2_TILE_2 | R_DK2_TILE_3 | R_DK2_TILE_4 | R_DK2_TILE_5,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 269 R_DK2_TILE_PATTERN_1_1_1_1_1_1, NULL, &cb_drp_finish, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 270 R_DK2_Activate(0, 0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 271 drp_time[2] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 272
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 273 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 274 r_drp_median_blur_t * param_median = (r_drp_median_blur_t *)nc_memory;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 275 for (idx = 0; idx < R_DK2_TILE_NUM; idx++) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 276 param_median[idx].src = (uint32_t)fbuf_work0 + (VIDEO_PIXEL_HW * (VIDEO_PIXEL_VW / R_DK2_TILE_NUM) * idx);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 277 param_median[idx].dst = (uint32_t)fbuf_work1 + (VIDEO_PIXEL_HW * (VIDEO_PIXEL_VW / R_DK2_TILE_NUM) * idx);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 278 param_median[idx].width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 279 param_median[idx].height = VIDEO_PIXEL_VW / R_DK2_TILE_NUM;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 280 param_median[idx].top = (idx == 0) ? 1 : 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 281 param_median[idx].bottom = (idx == 5) ? 1 : 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 282 R_DK2_Start(drp_lib_id[idx], (void *)&param_median[idx], sizeof(r_drp_median_blur_t));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 283 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 284 ThisThread::flags_wait_all(DRP_FLG_TILE_ALL);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 285 R_DK2_Unload(0, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 286 drp_time[3] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 287
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 288
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 289 /* Load DRP Library */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 290 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 291 /* tile 0 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 292 /* + CannyCalculate + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 293 /* tile 1 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 294 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 295 /* tile 2 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 296 /* + CannyCalculate + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 297 /* tile 3 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 298 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 299 /* tile 4 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 300 /* + CannyCalculate + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 301 /* tile 5 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 302 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 303 /* fbuf_work1 -> fbuf_work0 */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 304 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 305 R_DK2_Load(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 306 #if RAM_TABLE_DYNAMIC_LOADING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 307 ram_drp_lib_canny_calculate,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 308 #else
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 309 g_drp_lib_canny_calculate,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 310 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 311 R_DK2_TILE_0 | R_DK2_TILE_2 | R_DK2_TILE_4,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 312 R_DK2_TILE_PATTERN_2_2_2, NULL, &cb_drp_finish, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 313 R_DK2_Activate(0, 0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 314 drp_time[4] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 315
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 316 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 317 r_drp_canny_calculate_t * param_canny_cal = (r_drp_canny_calculate_t *)nc_memory;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 318 for (idx = 0; idx < 3; idx++) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 319 param_canny_cal[idx].src = (uint32_t)fbuf_work1 + (VIDEO_PIXEL_HW * (VIDEO_PIXEL_VW / 3) * idx);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 320 param_canny_cal[idx].dst = (uint32_t)fbuf_work0 + (VIDEO_PIXEL_HW * (VIDEO_PIXEL_VW / 3) * idx);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 321 param_canny_cal[idx].width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 322 param_canny_cal[idx].height = (VIDEO_PIXEL_VW / 3);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 323 param_canny_cal[idx].top = ((idx * 2) == 0) ? 1 : 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 324 param_canny_cal[idx].bottom = ((idx * 2) == 4) ? 1 : 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 325 param_canny_cal[idx].work = (uint32_t)&drp_work_buf[((VIDEO_PIXEL_HW * ((VIDEO_PIXEL_VW / 3) + 2)) * 2) * idx];
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 326 param_canny_cal[idx].threshold_high = 0x28;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 327 param_canny_cal[idx].threshold_low = 0x18;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 328 R_DK2_Start(drp_lib_id[(idx * 2)], (void *)&param_canny_cal[idx], sizeof(r_drp_canny_calculate_t));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 329 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 330 ThisThread::flags_wait_all(DRP_FLG_TILE_ALL);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 331 R_DK2_Unload(0, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 332 drp_time[5] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 333
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 334
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 335 /* Load DRP Library */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 336 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 337 /* tile 0 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 338 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 339 /* tile 1 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 340 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 341 /* tile 2 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 342 /* + CannyHysterisis + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 343 /* tile 3 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 344 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 345 /* tile 4 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 346 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 347 /* tile 5 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 348 /* +------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 349 /* fbuf_work0 -> fbuf_clat8 */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 350 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 351 R_DK2_Load(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 352 #if RAM_TABLE_DYNAMIC_LOADING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 353 ram_drp_lib_canny_hysterisis,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 354 #else
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 355 g_drp_lib_canny_hysterisis,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 356 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 357 R_DK2_TILE_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 358 R_DK2_TILE_PATTERN_6, NULL, &cb_drp_finish, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 359 R_DK2_Activate(0, 0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 360 drp_time[6] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 361
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 362 t.reset();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 363 r_drp_canny_hysterisis_t * param_canny_hyst = (r_drp_canny_hysterisis_t *)nc_memory;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 364 param_canny_hyst[0].src = (uint32_t)fbuf_work0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 365 param_canny_hyst[0].dst = (uint32_t)fbuf_clat8;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 366 param_canny_hyst[0].width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 367 param_canny_hyst[0].height = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 368 param_canny_hyst[0].work = (uint32_t)drp_work_buf;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 369 param_canny_hyst[0].iterations = 2;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 370 R_DK2_Start(drp_lib_id[0], (void *)&param_canny_hyst[0], sizeof(r_drp_canny_hysterisis_t));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 371 ThisThread::flags_wait_all(DRP_FLG_TILE_ALL);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 372 R_DK2_Unload(0, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 373 drp_time[7] = t.read_us();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 374
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 375
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 376 // Display DRP time
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 377 sprintf(str, "Bayer2Grayscale : Load %2.1fms + Run %2.1fms",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 378 (float_t)drp_time[0] / 1000, (float_t)drp_time[1] / 1000);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 379 ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 0, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 380 sprintf(str, "MedianBlur : Load %2.1fms + Run %2.1fms",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 381 (float_t)drp_time[2] / 1000, (float_t)drp_time[3] / 1000);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 382 ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 2, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 383 sprintf(str, "CannyCalculate : Load %2.1fms + Run %2.1fms",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 384 (float_t)drp_time[4] / 1000, (float_t)drp_time[5] / 1000);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 385 ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 4, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 386 sprintf(str, "CannyHysterisis : Load %2.1fms + Run %2.1fms",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 387 (float_t)drp_time[6] / 1000, (float_t)drp_time[7] / 1000);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 388 ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 6, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 389
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 390 uint32_t time_sum = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 391 for (int i = 0; i < 8; i++) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 392 time_sum += drp_time[i];
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 393 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 394 sprintf(str, "Total : %2.1fms", (float_t)time_sum / 1000);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 395 ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 8, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 396 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 397 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 398
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 399 int main(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 400 // Start DRP task
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 401 drpTask.start(callback(drp_task));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 402
RyoheiHagimoto@os.mbed.com 4:2da9e0f275a1 403 ThisThread::sleep_for(osWaitForever);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 404 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 405
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 406 #endif