namespace zxing {
namespace oned {
- const int CODE_PATTERNS_LENGHT = 107;
- const int countersLenght = 6;
- static const int CODE_PATTERNS[CODE_PATTERNS_LENGHT][countersLenght] = {
+ const int CODE_PATTERNS_LENGTH = 107;
+ const int countersLength = 6;
+ static const int CODE_PATTERNS[CODE_PATTERNS_LENGTH][countersLength] = {
{2, 1, 2, 2, 2, 2}, /* 0 */
{2, 2, 2, 1, 2, 2},
{2, 2, 2, 2, 2, 1},
}
int counterPosition = 0;
- int counters[countersLenght] = {0,0,0,0,0,0};
+ int counters[countersLength] = {0,0,0,0,0,0};
int patternStart = rowOffset;
bool isWhite = false;
int patternLength = sizeof(counters) / sizeof(int);
recordPattern(row, rowOffset, counters, countersCount);
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
int bestMatch = -1;
- for (int d = 0; d < CODE_PATTERNS_LENGHT; d++) {
- int pattern[countersLenght];
+ for (int d = 0; d < CODE_PATTERNS_LENGTH; d++) {
+ int pattern[countersLength];
- for(int ind = 0; ind< countersLenght; ind++){
+ for(int ind = 0; ind< countersLength; ind++){
pattern[ind] = CODE_PATTERNS[d][ind];
}
-// memcpy(pattern, CODE_PATTERNS[d], countersLenght);
+// memcpy(pattern, CODE_PATTERNS[d], countersLength);
int variance = patternMatchVariance(counters, countersCount, pattern, MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
codeSet = CODE_CODE_C;
break;
default:
+ delete [] startPatternInfo;
throw ReaderException("");
}
int lastStart = startPatternInfo[0];
int nextStart = startPatternInfo[1];
- int counters[countersLenght] = {0,0,0,0,0,0};
+ int counters[countersLength] = {0,0,0,0,0,0};
int lastCode = 0;
int code = 0;
lastCode = code;
// Decode another code from image
+ try {
code = decodeCode(row, counters, sizeof(counters)/sizeof(int), nextStart);
+ } catch (ReaderException re) {
+ delete [] startPatternInfo;
+ throw re;
+ }
// Remember whether the last code was printable or not (excluding CODE_STOP)
if (code != CODE_STOP) {
// Advance to where the next code will to start
lastStart = nextStart;
- int _countersLenght = sizeof(counters) / sizeof(int);
- for (int i = 0; i < _countersLenght; i++) {
+ int _countersLength = sizeof(counters) / sizeof(int);
+ for (int i = 0; i < _countersLength; i++) {
nextStart += counters[i];
}
case CODE_START_A:
case CODE_START_B:
case CODE_START_C:
+ delete [] startPatternInfo;
throw ReaderException("");
}
nextStart++;
}
if (!row->isRange(nextStart, fminl(width, nextStart + (nextStart - lastStart) / 2), false)) {
+ delete [] startPatternInfo;
throw ReaderException("");
}
checksumTotal -= multiplier * lastCode;
// lastCode is the checksum then:
if (checksumTotal % 103 != lastCode) {
+ delete [] startPatternInfo;
throw ReaderException("");
}
// String resultString(tmpResultString);
if (tmpResultString.length() == 0) {
+ delete [] startPatternInfo;
// Almost surely a false positive
throw ReaderException("");
}