| 489 | } |
| 490 | |
| 491 | float ScanThread::GetReferenceLaserLocation(vector<float> *laserCenterPx) |
| 492 | { |
| 493 | // find the laser in the top 25 pixels in the image |
| 494 | |
| 495 | // average the top 25 pixel locations to find the center |
| 496 | float refSum = 0; |
| 497 | int numRefHits = 0; |
| 498 | |
| 499 | for (int h=0;h<25;h++) |
| 500 | { |
| 501 | // this means that we don't accept the laser line on the exact left edge of the image |
| 502 | if ((*laserCenterPx)[h] > 0) |
| 503 | { |
| 504 | refSum += (*laserCenterPx)[h]; |
| 505 | numRefHits ++; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | if (numRefHits < 10) |
| 510 | { |
| 511 | // we probably don't have a good idea where the laser is |
| 512 | if (DEBUG_ON == 1) |
| 513 | { |
| 514 | DisplayText(wxT("\nWanring: failed to find reference laser.")); |
| 515 | } |
| 516 | |
| 517 | return -1; |
| 518 | } |
| 519 | |
| 520 | float refCenter = refSum/float(numRefHits); |
| 521 | |
| 522 | return refCenter; |
| 523 | } |
| 524 | |
| 525 | // NOTE: this function also sets pixelsPerCmOnFlatReference which is required for operation |
| 526 | float ScanThread::GetDistanceToReferenceWall(vector<float> *laserCenterPx) |
nothing calls this directly
no outgoing calls
no test coverage detected