MCPcopy Create free account
hub / github.com/devilsen/CZXing / ExtractPureBits

Function ExtractPureBits

czxing/src/main/cpp/zxing/src/maxicode/MCReader.cpp:25–45  ·  view source on GitHub ↗

* This method detects a code in a "pure" image -- that is, pure monochrome image * which contains only an unrotated, unskewed, image of a code, with some white border * around it. This is a specialized method that works exceptionally fast in this special * case. */

Source from the content-addressed store, hash-verified

23* case.
24*/
25static BitMatrix ExtractPureBits(const BitMatrix& image)
26{
27 int left, top, width, height;
28 if (!image.findBoundingBox(left, top, width, height, BitMatrixParser::MATRIX_WIDTH))
29 return {};
30
31 // Now just read off the bits
32 BitMatrix result(BitMatrixParser::MATRIX_WIDTH, BitMatrixParser::MATRIX_HEIGHT);
33 for (int y = 0; y < BitMatrixParser::MATRIX_HEIGHT; y++) {
34 int iy = top + (y * height + height / 2) / BitMatrixParser::MATRIX_HEIGHT;
35 for (int x = 0; x < BitMatrixParser::MATRIX_WIDTH; x++) {
36 int ix = left + (x * width + width / 2 + (y & 0x01) * width / 2) / BitMatrixParser::MATRIX_WIDTH;
37 if (image.get(ix, iy)) {
38 result.set(x, y);
39 }
40 }
41 }
42
43 //TODO: need to return position info
44 return result;
45}
46
47Result
48Reader::decode(const BinaryBitmap& image) const

Callers 1

decodeMethod · 0.85

Calls 3

findBoundingBoxMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected