Arduino Yun and Camera.

Hi, I was trying for more than a week to use a camera from RadioShack with my new YUN, finally works but now I have a different problem now it is taking to long to save the picture (1 hour) that I took and I don't know what to do.

The camera works fine with Arduino UNO and save the picture in less than 30 seconds.

/*******************************************************************************

  • Function Name : capture_photo
  • Description : capture a photo and store the file named temp.jpg into SD
  • Input : None
  • Output : None
  • Return : None
    *******************************************************************************/
    void capture_photo(){
    String dir = "/mnt/sd/";
    String filename = getTimeStamp();
    //NOTE I need to fix this problem.
    String extencion = "KC01.jpg "; //For some reason this name has to have a extra space at the end in order to be completed.

String nombreArchivoCompleto = (dir+filename+extencion);
int nombreArchivoCompletoLength = nombreArchivoCompleto.length();

char fileNameCharArray[nombreArchivoCompletoLength];
nombreArchivoCompleto.toCharArray(fileNameCharArray, nombreArchivoCompletoLength);
File dataFile = FileSystem.open(fileNameCharArray, FILE_WRITE);
delay(10);

VC0706_compression_ratio(63);
delay(100);

VC0706_frame_control(3);
delay(10);

VC0706_frame_control(0);
delay(10);
rx_ready=false;
rx_counter=0;

mySerial.end(); // clear all rx buffer
delay(50);
mySerial.begin(115200);

//get frame buffer length
VC0706_get_framebuffer_length(0);
delay(100);
buffer_read();

//while(1){};

// store frame buffer length for coming reading
frame_length=(VC0706_rx_buffer[5]<<8)+VC0706_rx_buffer[6];
frame_length=frame_length<<16;
frame_length=frame_length+(0x0ff00&(VC0706_rx_buffer[7]<<8))+VC0706_rx_buffer[8];

vc_frame_address =READ_DATA_BLOCK_NO;

// make a string that start with a timestamp for assembling the data to log:

while(vc_frame_address<frame_length){
VC0706_read_frame_buffer(vc_frame_address-READ_DATA_BLOCK_NO, READ_DATA_BLOCK_NO);
delay(6);

//get the data with length=READ_DATA_BLOCK_NObytes
rx_ready=false;
rx_counter=0;
buffer_read();

// write data to temp.jpg
dataFile.write(VC0706_rx_buffer+5,READ_DATA_BLOCK_NO);

//read next READ_DATA_BLOCK_NO bytes from frame buffer
vc_frame_address=vc_frame_address+READ_DATA_BLOCK_NO;
}

// get the last data
vc_frame_address=vc_frame_address-READ_DATA_BLOCK_NO;

last_data_length=frame_length-vc_frame_address;

VC0706_read_frame_buffer(vc_frame_address,last_data_length);
delay(6);
//get the data
rx_ready=false;
rx_counter=0;
buffer_read();

dataFile.write(VC0706_rx_buffer+5,last_data_length);
dataFile.close();
//Serial.print("Imagen lista para ser vista y esperando para la siguiente");
}

Is there a solution.
Thank you so much.

Please use code tag for code.

http://forum.arduino.cc/index.php?topic=209335.msg1541048#msg1541048

to save picture at SD is much faster at linino side. even HD (1280x720) image could only take seconds. all you need is USB webcam with UVC support .

http://wiki.openwrt.org/doc/howto/usb.video

for save image into local SD

fswebcam --png 2 -r 1280x720 --save /mnt/sda1/test.png

RadioShack® JPEG Color Camera Board $44.99

for fraction cost of that you could buy nice USB webcam which support 1280x720 v.s. RS's 640x480 resolution.

I bought that camera with one idea on mind and that was to process that raw image before sending it through WIFI to a computer to play with it, I think all those steps can be avoided thanks to YUN, now I just need a new usb camera.

Thanks for the fast support.