Clark Lin
/
BX-car_s
QQQ
Fork of BX-car_s by
Diff: camera_api.cpp
- Revision:
- 12:418e39749f48
- Parent:
- 11:03d5aa2511c4
- Child:
- 17:af867c7512bb
--- a/camera_api.cpp Thu Jun 26 09:15:35 2014 +0000 +++ b/camera_api.cpp Sat Jun 28 05:43:23 2014 +0000 @@ -175,37 +175,47 @@ - int BX_camera::black_centerL(void) { + int l_care=10; + int r_care=118; + + // find center // case 1 // | // - //case 2 / | / - + // case 2 / | / char find_type=0x00; - int b_end=0; - int b_start=0; + int b_end=118; + int b_start=118; + + int b_w=0; + int b_center=0; + int b2_end=0; int b2_start=0; - + int b2_center=0; - int center; + int b2_w=0; + + int center=30; int j=64; bool f1=false; bool f2=false; bool f3=false; bool f4=false; + int w_thr_up=32; + int w_thr_dn=0; - if(sign_line_imageL[64]==' ') + if(sign_line_imageR[64]==' ') find_type=0x02; else find_type=0x01; - for(int i=64; i<128; i++,j--) { + for(int i=64; i<r_care; i++,j--) { switch(find_type) { @@ -213,14 +223,14 @@ case 0x01: - if(f1==false&&sign_line_imageL[i]==' ') { + if(f1==false&&sign_line_imageR[i]==' ') { if(f1==false) { b_start=i; f1=true; } } - if(f1== true&& f2==false&&sign_line_imageL[i]=='O') { + if(f1== true&& f2==false&&sign_line_imageR[i]=='O') { if(f2==false) { b_end=i-1; f2=true; @@ -228,14 +238,14 @@ } - if(f3==false&&sign_line_imageL[j]==' ') { + if(f3==false&&sign_line_imageR[j]==' ') { if(f3==false) { b2_end=j; f3=true; } } - if(f3==true&&f4==false&&sign_line_imageL[j]=='O') { + if(f3==true&&f4==false&&sign_line_imageR[j]=='O') { if(f4==false) { b2_start=j-1; f4=true; @@ -243,12 +253,13 @@ } + break; case 0x02: - if(sign_line_imageL[i]=='O') { + if(sign_line_imageR[i]=='O') { if(f1==false) { b_end=i; @@ -256,7 +267,7 @@ } } - if(sign_line_imageL[j]=='O') { + if(sign_line_imageR[j]=='O') { if(f2==false) { b_start=j; @@ -270,29 +281,61 @@ } + } + b_w=b_start-b_end; + b2_w=b2_start-b2_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!=0)&&(b_center-64)<(64-b2_center)) + center=b_center; + else + center=b2_center; - if((b_end-b_start)>(b2_end-b2_start) ) + + + + +/* if( ( w_thr_up- (b_w))>0 &&( ( w_thr_up- (b_w)) < (w_thr_up-(b2_w)) ) ) { center=(b_end+b_start)/2; - else + + + // } else if( ( w_thr_up- (b2_w) )>0 ) { center=(b2_end+b2_start)/2; +// } else { + + center=65; + + //???????????????? + + } + +*/ break; case 0x02: center=(b_end+b_start)/2; + break; } return center; + +} -} +