QQQ

Dependencies:   mbed-rtos mbed

Fork of BX-car_s by Tony Lin

Revision:
7:fd976e1ced33
Parent:
6:5a39bde2e016
Child:
8:8e49e21d80a2
--- a/camera_api.cpp	Wed Jun 11 14:41:52 2014 +0000
+++ b/camera_api.cpp	Sun Jun 22 13:58:01 2014 +0000
@@ -16,6 +16,10 @@
 int BX_camera::black_centerR(void)
 {
 
+    int l_care=10;
+    int r_care=118;
+
+
     // find center
     // case 1      //  |  //
     // case 2       /  |  /
@@ -26,14 +30,15 @@
     int b_start=0;
 
     int b_w=0;
-
+    int b_center=0;
 
     int b2_end=0;
     int b2_start=0;
+    int b2_center=0;
 
     int b2_w=0;
 
-    int center;
+    int center=30;
     int j=64;
     bool f1=false;
     bool f2=false;
@@ -48,7 +53,7 @@
         find_type=0x01;
 
 
-    for(int i=64; i<128; i++,j--) {
+    for(int i=64; i<r_care; i++,j--) {
 
 
         switch(find_type) {
@@ -120,26 +125,33 @@
     b_w=b_start-b_end;
     b2_w=b2_start-b2_end;
     
-    debugV=b_start;
-    debugV2=b_end;
-    
+    de_v=b_start;
+    de_v2=b_end;    
 
     switch(find_type) {
 
         case 0x01:
+                b_center=(b_end+b_start)/2;
+                b2_center=(b2_end+b2_start)/2;
+                
+                
+                if(w_thr_up>b_w&&(b_center-64)<(64-b2_center))
+                      center=b_center;                   
+                else
+                      center=b2_center;
 
 
 
 
 
-            if( ( w_thr_up- (b_w))>0  &&( ( w_thr_up- (b_w)) < (w_thr_up-(b2_w)) )           ) {
+/*            if( ( w_thr_up- (b_w))>0  &&( ( w_thr_up- (b_w)) < (w_thr_up-(b2_w)) )           ) {
                 center=(b_end+b_start)/2;
 
 
 
-            } else if( ( w_thr_up- (b2_w) )>0 ) {
+  //          } else if( ( w_thr_up- (b2_w) )>0 ) {
                 center=(b2_end+b2_start)/2;
-            } else {
+//            } else {
 
                 center=65;
 
@@ -147,7 +159,7 @@
 
             }
 
-
+*/
             break;
 
         case 0x02:
@@ -157,9 +169,9 @@
             break;
     }
 
-
+    de_v=center;
     return center;
-
+   
 }