| 15 | }; |
| 16 | |
| 17 | bool DetectionManual::checkSignalDetectionManual(Image<ColorRgb>& image) |
| 18 | { |
| 19 | // check signal (only in center of the resulting image, because some grabbers have noise values along the borders) |
| 20 | bool noSignal = true; |
| 21 | |
| 22 | // top left |
| 23 | unsigned xOffset = image.width() * _x_frac_min; |
| 24 | unsigned yOffset = image.height() * _y_frac_min; |
| 25 | |
| 26 | // bottom right |
| 27 | unsigned xMax = image.width() * _x_frac_max; |
| 28 | unsigned yMax = image.height() * _y_frac_max; |
| 29 | |
| 30 | |
| 31 | for (unsigned x = xOffset; noSignal && x < xMax; ++x) |
| 32 | { |
| 33 | for (unsigned y = yOffset; noSignal && y < yMax; ++y) |
| 34 | { |
| 35 | noSignal &= (ColorRgb&)image(x, y) <= _noSignalThresholdColor; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | if (noSignal) |
| 40 | { |
| 41 | ++_noSignalCounter; |
| 42 | } |
| 43 | else |
| 44 | { |
| 45 | if (_noSignalCounter >= _noSignalCounterThreshold) |
| 46 | { |
| 47 | _noSignalDetected = true; |
| 48 | Info(_log, "Signal detected"); |
| 49 | } |
| 50 | |
| 51 | _noSignalCounter = 0; |
| 52 | } |
| 53 | |
| 54 | if (_noSignalCounter < _noSignalCounterThreshold) |
| 55 | { |
| 56 | return true; |
| 57 | } |
| 58 | else if (_noSignalCounter == _noSignalCounterThreshold) |
| 59 | { |
| 60 | _noSignalDetected = false; |
| 61 | Info(_log, "Signal lost"); |
| 62 | } |
| 63 | |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | void DetectionManual::setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold) |
| 68 | { |