Image processing using GR Kaede

The below code is an example available in the web compiler. The image library does not seem to work as expected. If anyone tried running the below code, please help how to capture image using the board and camera.

#include <Arduino.h>
#include "Image.h"
#include "SD.h"
#include "RTC.h"

Image image[3];
RTC_TIMETYPE t;
void dateTime(uint16_t* date, uint16_t* time);

void setup(){
Serial.begin(9600);
while(!Serial.available()); // wait to press key
Serial.read(); //dummy
Serial.println("start");

pinMode(SS, OUTPUT);
if(!SD.begin(SS)){
Serial.println("Card failed, or not present.");
} else {
Serial.println("Success to access SD.");
}

rtc_init();
t.year = 15;
t.mon = 9;
t.day = 2;
t.weekday = RTC_WEEK_WEDNESDAY;
t.hour = 17;
t.min = 0;
t.second = 0;
rtc_set_time(&t);


for(int i = 0; i < 2; i++){
image[i].begin();
}

SdFile::dateTimeCallback( &dateTime );

}

void loop(){

static int cnt = 0;

for(int i = 0; i < 3; i++){
Serial.print("Capturing image");
Serial.println();
image[i].captureStart();
while(!image[i].isCaptureFinished());
image[i].createGrayImage();
}
if( 0 == image[2].movingDetection(image[0].getCreatedGrayImage(), image[1].getCreatedGrayImage())){
Serial.println("finish detection");
Serial.print("Moving Number is:");
Serial.println(image[2].getMovingNumber());
Serial.print("The biggest moving is in area:");
Serial.println(image[2].getMovingArea(0));
}
image[2].createJpg();

Serial.println("Write jpg to SD:");

char fn[50];
cnt++;
sprintf (fn, "test%d.jpg", cnt);
File file = SD.open(fn, FILE_WRITE);
uint8_t* adr = image[2].getCreatedJpg();
int32_t size = image[2].getCreatedJpgSize();
for (int i = 0; i < size; i++){
file.write(*adr);
adr++;
}
file.close();

Serial.println("Done.");
}

void dateTime(uint16_t* date, uint16_t* time)
{
rtc_get_time(&t);

*date = FAT_DATE(t.year+2000, t.mon, t.day);
*time = FAT_TIME(t.hour, t.min, t.second);
}

  • Hi Gautham,

    This code example above is working perfectly.

    Follow the below steps -

    I am assuming you have connected the camera and micro SD card properly.

    Step 1: Build the project.

    Step 2: Download sketch.bin file to local drive.

    Step 3: Connect GR-KAEDE board to PC/LAPTOP using USB cable (J9) and press RESET button.

    Step 4: Paste "sketch.bin"  file inside GR-KAEDE drive.

    Step 5: Install USB driver for virtual com port. Download the driver from web compiler under your project folder >> USB driver >> GR-KAEDE_USBCDC.inf (driver file). Open device manager, find the device name under Ports >> "Gadget Renesas KAEDE (COM30)". If you able to see the device name, means driver installed successfully.

    [This STEP is required only once when you connect board first time  to PC/Laptop]

    Step 6: Open Hyper-terminal (or any other COM port software)- Set COM port (got from step-5), set baud rate 9600.

    Step 7: Unplug and plug the USB cable.Press any keyboard button. You can see the log on Hyper-terminal. Board will start capturing images.

    Step 8: Disconnect the board and check the SD card, you will found images named as -- TEST1,TEST2.....

  • In reply to Pratyush:

    Oh is it. I have connected the camera and sd card correctly, but when i see the hyperteminal it just displays

    start

    Success to access SD. and then stops.I mean its does not show anything further.

  • In reply to Gautham:

    Yes, sometimes i also observed same behavior. Don't know the reason.

    Not a good advice but in above condition just tap top board (on which camera is mounted),and check.

    for me it works after... :-)

    Log ::::

    ------------

    start

    Success to access SD.

    Capturing image

    Capturing image

    Capturing image

    finish detection

    Moving Number is : 0

    The biggest moving is in area : 0

    Write jpg to SD:

    Done

    Capturing image

    Capturing image

    Capturing image

    .....

    ....

  • In reply to Pratyush:

    No it still seems to have the same problem. Doesn't go beyond detecting the sd card. Could there be a technical reason for that.

  • In reply to Gautham:

    Is anyone facing the similar kind of problem with image processing using the board.

  • In reply to Gautham:

    yes, I also facing the same problem.

    after pressing key of keyboard.

    start

    success to SD card.

    and then nothing happens.

  • In reply to Pratyush:

    Thanks Pratyush. It worked for me

  • In reply to electron:

    Hi Electron ,

    Please try pressing the key again after "success to SD card" message.

  • In reply to Pratyush:

    usbdriver not working for me :( im using windows8..downloaded the inf file and installed but couldnt find com30 in ports. pls help

  • In reply to Priya:

    It does work if we press the key again but i don't see a line  in the above code that requires for us to press the key again after the "success to SD card". Please explain that part. Thanks.

  • In reply to Boss:

    @BOSS Once you have downloaded the usb inf file go to device manager and see the GR Kaede under the ports list. Now right click on that and do update device driver. Then follow the steps and install the driver. This should work.

  • In reply to Gautham:

    the camera module worked , and started capturing the image after pressing the key second time.

    thanks , PRIYA

  • In reply to electron:

    Hi All, As raised by Gautham, pressing key second time its not a logical answer and hence even I tested the sample code for the Camera module. Following is the scenario you guys can test.

    1. First time press any key on serial terminal, which should start detecting SD card. Basically this will initiate the program.

    2. Wait for approx 10sec as the next process takes a while, then it should automatically start capturing the image, without pressing key another time.

    Below is the log with timestamp you can see first pressed '1' key to start the program and then it automatically starts capturing as it should be the case

    [Fri Sep 25 08:41:18.910 2015] 1start

    [Fri Sep 25 08:41:19.435 2015] Success to access SD.

    [Fri Sep 25 08:41:28.585 2015] Capturing image

    [Fri Sep 25 08:41:29.088 2015] Capturing image

    [Fri Sep 25 08:41:29.588 2015] Capturing image

    [Fri Sep 25 08:41:30.595 2015] finish detection

    [Fri Sep 25 08:41:30.613 2015] Moving Number is:1

    [Fri Sep 25 08:41:30.633 2015] The biggest moving is in area:5

    [Fri Sep 25 08:41:31.260 2015] Write jpg to SD:

    [Fri Sep 25 08:41:33.078 2015] Done.

    [Fri Sep 25 08:41:33.085 2015] Capturing image

    [Fri Sep 25 08:41:33.578 2015] Capturing image

    [Fri Sep 25 08:41:34.078 2015] Capturing image

    [Fri Sep 25 08:41:35.080 2015] finish detection

    [Fri Sep 25 08:41:35.098 2015] Moving Number is:1

    [Fri Sep 25 08:41:35.118 2015] The biggest moving is in area:5

    [Fri Sep 25 08:41:35.748 2015] Write jpg to SD:

    [Fri Sep 25 08:41:37.548 2015] Done.

    [Fri Sep 25 08:41:37.555 2015] Capturing image

    [Fri Sep 25 08:41:38.070 2015] Capturing image

    [Fri Sep 25 08:41:38.568 2015] Capturing image

    [Fri Sep 25 08:41:39.570 2015] finish detection

    [Fri Sep 25 08:41:39.588 2015] Moving Number is:1

    [Fri Sep 25 08:41:39.608 2015] The biggest moving is in area:5

    [Fri Sep 25 08:41:40.230 2015] Write jpg to SD:

    [Fri Sep 25 08:41:42.018 2015] Done.

    [Fri Sep 25 08:41:42.030 2015] Capturing image

    [Fri Sep 25 08:41:42.558 2015] Capturing image

    [Fri Sep 25 08:41:43.055 2015] Capturing image

    [Fri Sep 25 08:41:43.995 2015] finish detection

    [Fri Sep 25 08:41:44.013 2015] Moving Number is:2

    [Fri Sep 25 08:41:44.033 2015] The biggest moving is in area:5

    [Fri Sep 25 08:41:44.708 2015] Write jpg to SD:

    [Fri Sep 25 08:41:46.485 2015] Done.

    [Fri Sep 25 08:41:46.495 2015] Capturing image

    [Fri Sep 25 08:41:46.946 2015] Capturing image

    [Fri Sep 25 08:41:47.446 2015] Capturing image

    [Fri Sep 25 08:41:48.301 2015] finish detection

    [Fri Sep 25 08:41:48.318 2015] Moving Number is:5

    [Fri Sep 25 08:41:48.338 2015] The biggest moving is in area:2

    [Fri Sep 25 08:41:49.048 2015] Write jpg to SD:

    [Fri Sep 25 08:41:50.843 2015] Done.

    [Fri Sep 25 08:41:50.856 2015] Capturing image

    [Fri Sep 25 08:41:51.338 2015] Capturing image

    [Fri Sep 25 08:41:51.836 2015] Capturing image

    [Fri Sep 25 08:41:52.698 2015] finish detection

    [Fri Sep 25 08:41:52.718 2015] Moving Number is:3

    [Fri Sep 25 08:41:52.738 2015] The biggest moving is in area:2

    [Fri Sep 25 08:41:53.453 2015] Write jpg to SD:

    [Fri Sep 25 08:41:55.248 2015] Done.

    [Fri Sep 25 08:41:55.253 2015] Capturing image

    [Fri Sep 25 08:41:55.728 2015] Capturing image

    [Fri Sep 25 08:41:56.228 2015] Capturing image

    Regards,

    Shrenik

  • In reply to Shrenik:

    Hello Guys,

    If I do not convert to image to .jpg (i.e if I remove the line of code image[i].CreateJpg ), and still try to store the same in the SD-Card, what will be the file-format of the Raw-data?

    The spec says that the Camera-Output will be RAW-RGB or YUV Images. Has anyone tried this already?

    Regards,

    Yuvaraj

  • In reply to Yuvaraj:

    This will be of use to all of us --> Product brief of the CMOS Camera - OV7740.

    www.ovt.com/.../OV7740_PB(1.0)_web.pdf