| 70 | } |
| 71 | |
| 72 | bool |
| 73 | BitMatrix::findBoundingBox(int &left, int& top, int& width, int& height, int minSize) const |
| 74 | { |
| 75 | int right, bottom; |
| 76 | if (!getTopLeftOnBit(left, top) || !getBottomRightOnBit(right, bottom) || bottom - top + 1 < minSize) |
| 77 | return false; |
| 78 | |
| 79 | for (int y = top; y <= bottom; y++ ) { |
| 80 | for (int x = 0; x < left; ++x) |
| 81 | if (get(x, y)) { |
| 82 | left = x; |
| 83 | break; |
| 84 | } |
| 85 | for (int x = _width-1; x > right; x--) |
| 86 | if (get(x, y)) { |
| 87 | right = x; |
| 88 | break; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | width = right - left + 1; |
| 93 | height = bottom - top + 1; |
| 94 | return width >= minSize && height >= minSize; |
| 95 | } |
| 96 | |
| 97 | static auto isSet = [](auto v) { return bool(v); }; |
| 98 |
no test coverage detected