Tested on Nucleo F411RE Based on OV7670 without FIFO, SCCB protocol rewritten. View on TFT ILI9341, possible capture picture on sd Around 3 frames per second Basic image treatment: zoom, rotation, etc Very basic pattern recognition, pattern being stored on SD, after camera capture, or from .bmp file (rgb 565, 120x160 max)

Dependencies:   FastPWM SDFileSystem SPI_TFT_ILI9341 TFT_fonts imagetrlib mbed ov7670s

Dependents:   Practica4_Camara

Revision:
2:7e06db0773c1
Parent:
1:7fbc24ad0958
Child:
3:19b0a9d60055
--- a/main.cpp	Tue Feb 16 14:44:01 2016 +0000
+++ b/main.cpp	Wed Feb 17 16:37:01 2016 +0000
@@ -358,7 +358,7 @@
 
 }
 
-void searchp(void)
+void searchp(char name[])
 {
     bool c = false;
     float ad;
@@ -370,7 +370,7 @@
 
     }
     meas1 = analog_value1.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
-    meas1 =  meas1 * 1000000;   // 0 a 4000
+    meas1 =  meas1 * 100000;   // 0 a 100 000 -    50 000 is appropriate usually
     if( fabs(meas1-measold1)>200 ) {
         c=true;
     }
@@ -392,15 +392,15 @@
         TFT.foreground(White);
         //pc.printf("x: %d, y: %d, angle: %.2f zoom: %.2f \r\n", int(meas0),int(meas1), meas2, meas3);
         TFT.locate(170,45);
-        printf("x %3d",int(meas0));
+        printf("x %4d",int(meas0));
         TFT.locate(170,65);
         printf("threshold %6d",int(meas1));
         TFT.locate(170,105);
-        printf("zoom %.2f",meas3);
+        printf("zoom %4.2f",meas3);
         TFT.locate(170,85);
-        printf("angle %.2f",ad);
+        printf("angle %4.2f",ad);
         imagetr.affine(0,meas0,meas2, meas3);
-        imagetr.searchpat(meas1);
+        imagetr.searchpat(meas1, name);
     }
 }
 void viewf(void)
@@ -472,6 +472,10 @@
 void loadpat(const char pat[])
 {
     imagetr.getimage(pat);
+    for  (int i=0; i<25; i++) {
+       if (pat[i+4]!='.') { filename[i]=pat[i+4];} else {break;}
+    }
+    pc . printf("f : %s\r\n", filename);
     TFT.Bitmap(160,0,ncta,nlta,bank);
     imagetr.rgbtoyta();
     for (int i = 0; i<7; i++) {
@@ -482,6 +486,10 @@
 void loadpated(const char pat[])
 {
     imagetr.getimage(pat);
+    for  (int i=0; i<25; i++) {
+       if (pat[i+4]!='.') { filename[i]=pat[i+4];} else {break;}
+    }
+    pc . printf("f : %s\r\n", filename);
     TFT.Bitmap(160,0,ncta,nlta,bank);
     imagetr.rgbtoytaed();
     for (int i = 0; i<7; i++) {
@@ -565,26 +573,15 @@
 
 void epatternmatch(const char tar[],const char pat[])
 {
-    int i=0;
     loadtarget(tar);
     loadpat(pat);
-    for  (i=0; i<25; i++) {
-        filename[i]=pat[i+4];
-    }
-
-    pc . printf("f : %s\r\n", filename);
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.foreground(Red);
 }
 void epatternmatched(const char tar[],const char pat[])
 {
-    int i=0;
     loadtargeted(tar);
     loadpated(pat);
-    for  (i=0; i<25; i++) {
-        filename[i]=pat[i+4];
-    }
-    pc . printf("f : %s\r\n", filename);
     TFT.set_font((unsigned char*) Arial12x12);
     TFT.foreground(Red);
 }
@@ -653,14 +650,14 @@
     pc.printf("Hello World !\r\n");
 //////////////////////////////////////////////////////////
 // to view camera
-
+/*
     my_button.fall(&pressed);
 
     while (1) {
         capturecycle("/sd/picture.txt");
     }
 }
-
+*/
 //////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////
 // to create a target from a .bmp to sd
@@ -676,14 +673,14 @@
 */
 //////////////////////////////////////////////////////////
 // to recognise a target from bmp and target on sd
-/*
+
      epatternmatch("/sd/manchodou.bmp","/sd/manchodou.txt");
      while (1) {
          viewf();
-         searchp();
+         searchp(filename);
      }
  }
- */
+ 
 //////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////
 // to recognise a target from bmp and target on sd, on edge
@@ -692,7 +689,7 @@
     while (1) {
 
         viewf();
-        searchp();
+        searchp(filename);
     }
 }
 */
@@ -706,7 +703,6 @@
         if (statc==0) {
             loadnewca();
         }
-
         affinem(true);
         __enable_irq();     // Enable Interrupts
 
@@ -722,7 +718,7 @@
  epatca("/sd/man.txt","/sd/man2.txt");
   while (1) {
      viewf();
-    searchp();
+    searchp(filename);
  }
 }
 */
@@ -734,7 +730,7 @@
         loadnewca();
          viewf();
         if (statc==0) {
-            searchp();
+            searchp(filename);
         }  else {
             affinem(false);
         }
@@ -750,4 +746,4 @@
         extedgem();
     }
 }
-*/
\ No newline at end of file
+*/