kao yi
/
Bov3
wu
Fork of CCC by
Diff: camera_api.cpp
- Revision:
- 3:c5f2281b3ed2
- Parent:
- 2:c51647d3c14d
- Child:
- 4:05b21dbca0c7
--- a/camera_api.cpp Wed Jun 04 12:56:52 2014 +0000 +++ b/camera_api.cpp Wed Jun 04 14:41:28 2014 +0000 @@ -16,6 +16,273 @@ } +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; + + + 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 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; + + } + + + + + + + + + + + void BX_camera::read(void){