title: image receiving in microcontroller
body: <p>I have bought LinkSprite JPEG Color Camera and a LPC1768 mbed microcontroller. By "LinkSprite" camera i can take image in jpeg format and according to their provided tutorial i can transfer and see these image on desktop.But i want to process these image in "LPC1768 mbed" micro-controller.For example i want to loop through each row and column of that image to match a color. Can anyone tell me how can i receive the whole image into an 2D-array and then loop through the array to match with a color like red . Another problem when i transfer the image the data looks like. ff d8 ff e0 00 10 ...........40 c6 81 90 b9 aa ee 68 19 ff d9. I know that jpeg image starts with ff d9 and ends with ff d9. But how can i identify a pixel among those values and how can i compare a color whether it match with red color???</p>
  
  <p>Code for camera to take picture and transfer the image byte by byte </p>
  
  <pre><code>int main() {
  JPEGCamera camera(p9, p10); // TX, RX
  LocalFileSystem local("local"); //save images on mbed
  Timer timer;
  timer.start();
  if(camera.setPictureSize(JPEGCamera::SIZE160x120))
  {
    myled1 = 1;
    wait(2.0);
    myled1 = 0; 
    wait(2.0); 
  }
  for (int i = 1; i &lt; 3; i++) {
      if (camera.isReady()) {
          char filename[32];
          sprintf(filename, "/local/pict%03d.jpg", i);
          printf("Picture: %s \n", filename);
          if (camera.takePicture(filename)) {
              while (camera.isProcessing()) {
                  camera.processPicture();
              }
  
  
              myled1 = 1; //show successful picture was taken 
              wait(2.0);
              myled1 = 0;
          } else {
              printf("take picture failed\n");
              myled3 = 1; //show picture take failed
              wait(2.0);
              myled3 = 0;
          }
      } else {
          printf("camera is not ready\n");
          myled4 = 1; //show camera is not ready
          wait(2.0);
          myled4 = 0;
      }
  }
  </code></pre>
  
  <p>In JPEGCamera.cpp</p>
  
  <pre><code>bool JPEGCamera::processPicture() {
  if (state == PROCESSING) {
      bt.printf("\n\nNew Image \n\n");
      if (address &lt; imageSize) {
          char data[2048];
          int size = readData(data, min(sizeof(data), imageSize - address), address);
          int ret = fwrite(data, size, 1, fp);
          for (int i=0; i&lt;size; i++) bt.printf("%x ",data[i]);
          if (ret &gt; 0)
              address += size;
          if (ret == 0 || address &gt;= imageSize) {
              stopPictures();
              fclose(fp);
              wait(0.1); // ????
              state = ret &gt; 0 ? READY : ERROR;
          }
      }
  }
  
  return state == PROCESSING || state == READY;
  </code></pre>
  
  <p>}</p>
  
  <p>Is there any way that i can store the image bytes in an array at "processPicture" function??
  Is there any way that i can simply read the stored image ???</p>