private int findStartPattern() throws NotFoundException { for (int i = 1; i < counterLength; i += 2) { int charOffset = toNarrowWidePattern(i); if (charOffset != -1 && arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { // Look for whitespace before start pattern, >= 50% of width of start pattern // We make an exception if the whitespace is the first element. int patternSize = 0; for (int j = i; j < i + 7; j++) { patternSize += counters[j]; } if (i == 1 || counters[i - 1] >= patternSize / 2) { return i; } } } throw NotFoundException.getNotFoundInstance(); }
setCounters(row); int startOffset = findStartPattern(); int nextStart = startOffset; int charOffset = toNarrowWidePattern(nextStart); if (charOffset == -1) { throw NotFoundException.getNotFoundInstance(); arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { break; validatePattern(startOffset); if (!arrayContains(STARTEND_ENCODING, startchar)) { throw NotFoundException.getNotFoundInstance(); if (!arrayContains(STARTEND_ENCODING, endchar)) { throw NotFoundException.getNotFoundInstance();
public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws NotFoundException { int[] start = findAsteriskPattern(row); start[1] = 0; // BAS: settings this to 0 improves the recognition rate somehow? int nextStart = start[1]; recordPattern(row, nextStart, counters); char decodedChar = toNarrowWidePattern(counters); if (decodedChar == '!') { throw NotFoundException.getNotFoundInstance(); if (!arrayContains(STARTEND_ENCODING, startchar))
readers.add(new CodaBarReader()); readers.add(new MultiFormatUPCEANReader(hints)); readers.add(new Code39Reader()); readers.add(new CodaBarReader()); readers.add(new Code93Reader()); readers.add(new Code128Reader());
boolean startsNormal = CodaBarReader.arrayContains(START_END_CHARS, firstChar); boolean endsNormal = CodaBarReader.arrayContains(START_END_CHARS, lastChar); boolean startsAlt = CodaBarReader.arrayContains(ALT_START_END_CHARS, firstChar); boolean endsAlt = CodaBarReader.arrayContains(ALT_START_END_CHARS, lastChar); if (startsNormal) { if (!endsNormal) { if (Character.isDigit(contents.charAt(i)) || contents.charAt(i) == '-' || contents.charAt(i) == '$') { resultLength += 9; } else if (CodaBarReader.arrayContains(CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED, contents.charAt(i))) { resultLength += 10; } else {
/** * Records the size of all runs of white and black pixels, starting with white. * This is just like recordPattern, except it records all the counters, and * uses our builtin "counters" member for storage. * @param row row to count from */ private void setCounters(BitArray row) throws NotFoundException { counterLength = 0; // Start from the first white bit. int i = row.getNextUnset(0); int end = row.getSize(); if (i >= end) { throw NotFoundException.getNotFoundInstance(); } boolean isWhite = true; int count = 0; while (i < end) { if (row.get(i) != isWhite) { count++; } else { counterAppend(count); count = 1; isWhite = !isWhite; } i++; } counterAppend(count); }
setCounters(row); int startOffset = findStartPattern(); int nextStart = startOffset; int charOffset = toNarrowWidePattern(nextStart); if (charOffset == -1) { throw NotFoundException.getNotFoundInstance(); arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { break; validatePattern(startOffset); if (!arrayContains(STARTEND_ENCODING, startchar)) { throw NotFoundException.getNotFoundInstance(); if (!arrayContains(STARTEND_ENCODING, endchar)) { throw NotFoundException.getNotFoundInstance();
readers.add(new CodaBarReader()); readers.add(new MultiFormatUPCEANReader(hints)); readers.add(new Code39Reader()); readers.add(new CodaBarReader()); readers.add(new Code93Reader()); readers.add(new Code128Reader());
boolean startsNormal = CodaBarReader.arrayContains(START_END_CHARS, firstChar); boolean endsNormal = CodaBarReader.arrayContains(START_END_CHARS, lastChar); boolean startsAlt = CodaBarReader.arrayContains(ALT_START_END_CHARS, firstChar); boolean endsAlt = CodaBarReader.arrayContains(ALT_START_END_CHARS, lastChar); if (startsNormal) { if (!endsNormal) { if (Character.isDigit(contents.charAt(i)) || contents.charAt(i) == '-' || contents.charAt(i) == '$') { resultLength += 9; } else if (CodaBarReader.arrayContains(CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED, contents.charAt(i))) { resultLength += 10; } else {
/** * Records the size of all runs of white and black pixels, starting with white. * This is just like recordPattern, except it records all the counters, and * uses our builtin "counters" member for storage. * @param row row to count from */ private void setCounters(BitArray row) throws NotFoundException { counterLength = 0; // Start from the first white bit. int i = row.getNextUnset(0); int end = row.getSize(); if (i >= end) { throw NotFoundException.getNotFoundInstance(); } boolean isWhite = true; int count = 0; while (i < end) { if (row.get(i) != isWhite) { count++; } else { counterAppend(count); count = 1; isWhite = !isWhite; } i++; } counterAppend(count); }
private int findStartPattern() throws NotFoundException { for (int i = 1; i < counterLength; i += 2) { int charOffset = toNarrowWidePattern(i); if (charOffset != -1 && arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) { // Look for whitespace before start pattern, >= 50% of width of start pattern // We make an exception if the whitespace is the first element. int patternSize = 0; for (int j = i; j < i + 7; j++) { patternSize += counters[j]; } if (i == 1 || counters[i - 1] >= patternSize / 2) { return i; } } } throw NotFoundException.getNotFoundInstance(); }
readers.addElement(new CodaBarReader());
if (counterPosition == patternLength - 1) { try { if (arrayContains(STARTEND_ENCODING, toNarrowWidePattern(counters))) {