QQQQQQQQQ

Dependencies:   mbed

Fork of Boboobooo by kao yi

Revision:
6:b046d6ff3745
Parent:
5:e32b091aa1fb
--- a/camera_api.cpp	Thu Jun 05 10:32:55 2014 +0000
+++ b/camera_api.cpp	Mon Jul 07 08:16:46 2014 +0000
@@ -14,242 +14,37 @@
  
 int BX_camera::black_centerR(void){
        
-         // find center 
-         // case 1      //  |  //
-         // case 2       /  |  /
-    
-     char find_type=0x00;
-     
-     int b_end=0;
-     int b_start=0;
-     
-     int b2_end=0;
-     int b2_start=0;
-     
-     
-     int center;
-     int j=64;
-     bool f1=false;
-     bool f2=false;
-     bool f3=false;
-     bool f4=false;
+    int black_R_left = 0;
+    for(int i = 120; i >=8; i--){
+        if(sign_line_imageR[i] == 'O' && sign_line_imageR[i-1] == ' ' && sign_line_imageR[i-2] == ' '){
+            return i;
+        }
+    } 
+    return black_R_left;
     
          
-            if(sign_line_imageR[64]==' ')
-              find_type=0x02;
-            else
-              find_type=0x01;  
-            
-          
-           for(int i=64;i<128; i++,j--){
-               
-                
-               switch(find_type){
-                   
-                   
-                   case 0x01:
-                       
-                         if(f1==false&&sign_line_imageR[i]==' '){ 
-                                  if(f1==false){
-                                      b_start=i;
-                                      f1=true;
-                                  }
-                                  
-                         }
-                         if(f1== true&& f2==false&&sign_line_imageR[i]=='O'){ 
-                                  if(f2==false){
-                                      b_end=i-1;
-                                      f2=true;
-                                  }
-                                  
-                         }
-                         
-                         if(f3==false&&sign_line_imageR[j]==' '){ 
-                                  if(f3==false){
-                                      b2_end=j;
-                                      f3=true;
-                                  }
-                                  
-                         }
-                         if(f3==true&&f4==false&&sign_line_imageR[j]=='O'){ 
-                                  if(f4==false){
-                                      b2_start=j-1;
-                                      f4=true;
-                                  }
-                                  
-                         }
-                         
-                   
-                   break;
-                   
-                   
-                   case 0x02:
-                   
-                         if(sign_line_imageR[i]=='O'){         
-                    
-                                  if(f1==false){
-                                      b_end=i;
-                                      f1=true;
-                                  }
-                         }  
-                    
-                         if(sign_line_imageR[j]=='O'){
-                        
-                                   if(f2==false){
-                                       b_start=j;     
-                                      f2=true;
-                                  }
-       
-                        }
-                   
-                   
-                   break;    
-      
-               }
-        
-               
-           }
-       
-            
-          switch(find_type){
-         
-             case 0x01:
-                
-               if((b_end-b_start)>(b2_end-b2_start)    )
-                     center=(b_end+b_start)/2;
-                     
-               else  
-                     center=(b2_end+b2_start)/2;
-             break;
-             
-             case 0x02:
-               center=(b_end+b_start)/2;
-              
-             break;
-         }
+
     
-    
-      return center;
-    
-    }
+}
 
 
 
 
 int BX_camera::black_centerL(void){
          
-         // find center 
-         // case 1      //  |  //
-         //case 2         / |  /
-         
-         
-     char find_type=0x00;
-     
-     int b_end=0;
-     int b_start=0;
-     int b2_end=0;
-     int b2_start=0;
+     int black_L_right = 128;
+     for(int i = 8; i <121 ; i++){
+        if(sign_line_imageL[i] == 'O' && sign_line_imageL[i+1] == ' ' && sign_line_imageL[i+2] == ' '){
+            return i;
+        }
+    }
+    return black_L_right;
      
      
-     int center;
-     int j=64;
-     bool f1=false;
-     bool f2=false;
-     bool f3=false;
-     bool f4=false;
-
-            if(sign_line_imageL[64]==' ')
-              find_type=0x02;
-            else
-              find_type=0x01;  
-            
-           
-           for(int i=64;i<128; i++,j--){
-               
-                
-               switch(find_type){
-                   
-                   
-                   case 0x01:
-                       
-                         if(f1==false&&sign_line_imageL[i]==' '){ 
-                                  if(f1==false){
-                                      b_start=i;
-                                      f1=true;
-                                  }
-                                  
-                         }
-                         if(f1== true&& f2==false&&sign_line_imageL[i]=='O'){ 
-                                  if(f2==false){
-                                      b_end=i-1;
-                                      f2=true;
-                                  }
-                                  
-                         }
-                         
-                         if(f3==false&&sign_line_imageL[j]==' '){ 
-                                  if(f3==false){
-                                      b2_end=j;
-                                      f3=true;
-                                  }
-                                  
-                         }
-                         if(f3==true&&f4==false&&sign_line_imageL[j]=='O'){ 
-                                  if(f4==false){
-                                      b2_start=j-1;
-                                      f4=true;
-                                  }
-                                  
-                         }
-                                    
-                   break;
-                   
-                   
-                   case 0x02:
-                   
-                         if(sign_line_imageL[i]=='O'){         
-                    
-                                  if(f1==false){
-                                      b_end=i;
-                                      f1=true;
-                                  }
-                         }  
-                    
-                         if(sign_line_imageL[j]=='O'){
-                        
-                                   if(f2==false){
-                                       b_start=j;     
-                                      f2=true;
-                                  }
-       
-                        }
-                   
-                   
-                   break;               
-                   
-               }
-         
-           }
-       
-            
-          switch(find_type){
-         
-             case 0x01:
-                
-               if((b_end-b_start)>(b2_end-b2_start)    )
-                     center=(b_end+b_start)/2;
-                     
-               else  
-                     center=(b2_end+b2_start)/2;             
-             break;
-             
-             case 0x02:
-               center=(b_end+b_start)/2;
-              
-             break;
-         }
- 
-    return center;
+    
+          
+                 
+     
  
  }