Moved to Team 9.
Fork of LineScan by
Diff: LineScan.cpp
- Revision:
- 21:68db1d0a5534
- Parent:
- 13:c17cf029d899
- Child:
- 22:0136520fe249
--- a/LineScan.cpp Fri Apr 10 00:38:31 2015 +0000 +++ b/LineScan.cpp Sat Apr 18 07:03:00 2015 +0000 @@ -40,6 +40,8 @@ int total = 0; int h_idx = frameLen/2; int l_idx = frameLen/2; + int left_bound = SKIP; + int right_bound = NUM_PIX - SKIP; //for AGC float exposureChange; @@ -76,8 +78,12 @@ *exposure = 30; } //valid if white line on black and not blinded - if(h_idx > l_idx && (highest - lowest) > THRESH) - return ((float)(h_idx + l_idx)) / (2.0 * (float)frameLen); //0.5 is center + if (highest > THRESH && -1 * lowest > THRESH) + return ((float) h_idx + (float) l_idx) / (2*(float)frameLen); + else if(highest > THRESH && -1 * lowest < THRESH ) + return ((float) h_idx + left_bound) / (2*(float)frameLen); //0.5 is center + else if (-1*lowest > THRESH && highest < THRESH ) + return ((float) l_idx + right_bound) / (2*(float)frameLen); else return -1.0; //invalid read }