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

Function ReadCodeWord

czxing/src/main/cpp/zxing/src/pdf417/PDFReader.cpp:119–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118template<typename POINT>
119CodeWord ReadCodeWord(BitMatrixCursor<POINT>& cur, int expectedCluster = -1)
120{
121 auto readCodeWord = [expectedCluster](auto& cur) -> CodeWord {
122 auto np = NormalizedPattern<8, 17>(cur.template readPattern<Pattern417>());
123 int cluster = (np[0] - np[2] + np[4] - np[6] + 9) % 9;
124 int code = expectedCluster == -1 || cluster == expectedCluster ? CodewordDecoder::GetCodeword(ToInt(np)) : -1;
125
126 return {cluster, code};
127 };
128
129 auto curBackup = cur;
130 auto cw = readCodeWord(cur);
131 if (!cw) {
132 for (auto offset : {curBackup.left(), curBackup.right()}) {
133 auto curAlt = curBackup.movedBy(offset);
134 if (!curAlt.isIn()) // curBackup might be the first or last image row
135 continue;
136 if (auto cwAlt = readCodeWord(curAlt)) {
137 cur = curAlt;
138 return cwAlt;
139 }
140 }
141 }
142 return cw;
143}
144
145static int Row(CodeWord rowIndicator)
146{

Callers 2

ReadSymbolInfoFunction · 0.85
ReadCodeWordsFunction · 0.85

Calls 5

leftMethod · 0.80
rightMethod · 0.80
movedByMethod · 0.80
ToIntFunction · 0.50
isInMethod · 0.45

Tested by

no test coverage detected