Java Code Examples for com.google.zxing.common.BitArray#isRange()
The following examples show how to use
com.google.zxing.common.BitArray#isRange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UPCEANReader.java From barcodescanner-lib-aar with MIT License | 6 votes |
static int[] findStartGuardPattern(BitArray row) throws NotFoundException { boolean foundStart = false; int[] startRange = null; int nextStart = 0; int[] counters = new int[START_END_PATTERN.length]; while (!foundStart) { Arrays.fill(counters, 0, START_END_PATTERN.length, 0); startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); int start = startRange[0]; nextStart = startRange[1]; // Make sure there is a quiet zone at least as big as the start pattern before the barcode. // If this check would run off the left edge of the image, do not accept this barcode, // as it is very likely to be a false positive. int quietStart = start - (nextStart - start); if (quietStart >= 0) { foundStart = row.isRange(quietStart, start, false); } } return startRange; }
Example 2
Source File: UPCEANReader.java From ScreenCapture with MIT License | 6 votes |
static int[] findStartGuardPattern(BitArray row) throws NotFoundException { boolean foundStart = false; int[] startRange = null; int nextStart = 0; int[] counters = new int[START_END_PATTERN.length]; while (!foundStart) { Arrays.fill(counters, 0, START_END_PATTERN.length, 0); startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); int start = startRange[0]; nextStart = startRange[1]; // Make sure there is a quiet zone at least as big as the start pattern before the barcode. // If this check would run off the left edge of the image, do not accept this barcode, // as it is very likely to be a false positive. int quietStart = start - (nextStart - start); if (quietStart >= 0) { foundStart = row.isRange(quietStart, start, false); } } return startRange; }
Example 3
Source File: UPCEANReader.java From reacteu-app with MIT License | 6 votes |
static int[] findStartGuardPattern(BitArray row) throws NotFoundException { boolean foundStart = false; int[] startRange = null; int nextStart = 0; int[] counters = new int[START_END_PATTERN.length]; while (!foundStart) { Arrays.fill(counters, 0, START_END_PATTERN.length, 0); startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); int start = startRange[0]; nextStart = startRange[1]; // Make sure there is a quiet zone at least as big as the start pattern before the barcode. // If this check would run off the left edge of the image, do not accept this barcode, // as it is very likely to be a false positive. int quietStart = start - (nextStart - start); if (quietStart >= 0) { foundStart = row.isRange(quietStart, start, false); } } return startRange; }
Example 4
Source File: UPCEANReader.java From weex with Apache License 2.0 | 6 votes |
static int[] findStartGuardPattern(BitArray row) throws NotFoundException { boolean foundStart = false; int[] startRange = null; int nextStart = 0; int[] counters = new int[START_END_PATTERN.length]; while (!foundStart) { Arrays.fill(counters, 0, START_END_PATTERN.length, 0); startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); int start = startRange[0]; nextStart = startRange[1]; // Make sure there is a quiet zone at least as big as the start pattern before the barcode. // If this check would run off the left edge of the image, do not accept this barcode, // as it is very likely to be a false positive. int quietStart = start - (nextStart - start); if (quietStart >= 0) { foundStart = row.isRange(quietStart, start, false); } } return startRange; }
Example 5
Source File: UPCEANReader.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
static int[] findStartGuardPattern(BitArray row) throws NotFoundException { boolean foundStart = false; int[] startRange = null; int nextStart = 0; int[] counters = new int[START_END_PATTERN.length]; while (!foundStart) { Arrays.fill(counters, 0, START_END_PATTERN.length, 0); startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); int start = startRange[0]; nextStart = startRange[1]; // Make sure there is a quiet zone at least as big as the start pattern before the barcode. // If this check would run off the left edge of the image, do not accept this barcode, // as it is very likely to be a false positive. int quietStart = start - (nextStart - start); if (quietStart >= 0) { foundStart = row.isRange(quietStart, start, false); } } return startRange; }
Example 6
Source File: UPCEANReader.java From ZXing-Orient with Apache License 2.0 | 6 votes |
static int[] findStartGuardPattern(BitArray row) throws NotFoundException { boolean foundStart = false; int[] startRange = null; int nextStart = 0; int[] counters = new int[START_END_PATTERN.length]; while (!foundStart) { Arrays.fill(counters, 0, START_END_PATTERN.length, 0); startRange = findGuardPattern(row, nextStart, false, START_END_PATTERN, counters); int start = startRange[0]; nextStart = startRange[1]; // Make sure there is a quiet zone at least as big as the start pattern before the barcode. // If this check would run off the left edge of the image, do not accept this barcode, // as it is very likely to be a false positive. int quietStart = start - (nextStart - start); if (quietStart >= 0) { foundStart = row.isRange(quietStart, start, false); } } return startRange; }
Example 7
Source File: UPCEANReader.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
static int[] a(BitArray bitarray) { int ai[] = new int[b.length]; int j = 0; int ai1[] = null; boolean flag = false; do { if (flag) { break; } Arrays.fill(ai, 0, b.length, 0); ai1 = a(bitarray, j, false, b, ai); int k = ai1[0]; j = ai1[1]; int l = k - (j - k); if (l >= 0) { flag = bitarray.isRange(l, k, false); } } while (true); return ai1; }
Example 8
Source File: Code39Reader.java From reacteu-app with MIT License | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) { return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 9
Source File: Code39Reader.java From barcodescanner-lib-aar with MIT License | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 10
Source File: Code39Reader.java From weex with Apache License 2.0 | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 11
Source File: Code39Reader.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 12
Source File: Code39Reader.java From ZXing-Orient with Apache License 2.0 | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 13
Source File: Code39Reader.java From QrCodeScanner with GNU General Public License v3.0 | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) != isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { return new int[]{patternStart, i}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, counterPosition - 1); counters[counterPosition - 1] = 0; counters[counterPosition] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 14
Source File: Code39Reader.java From RipplePower with Apache License 2.0 | 5 votes |
private static int[] findAsteriskPattern(BitArray row, int[] counters) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { // Look for whitespace before start pattern, >= 50% of width // of start pattern if (toNarrowWidePattern(counters) == ASTERISK_ENCODING && row.isRange(Math.max(0, patternStart - ((i - patternStart) / 2)), patternStart, false)) { return new int[] { patternStart, i }; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 15
Source File: Code128Reader.java From RipplePower with Apache License 2.0 | 4 votes |
private static int[] findStartPattern(BitArray row) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int[] counters = new int[6]; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { float bestVariance = MAX_AVG_VARIANCE; int bestMatch = -1; for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) { float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE); if (variance < bestVariance) { bestVariance = variance; bestMatch = startCode; } } // Look for whitespace before start pattern, >= 50% of width // of start pattern if (bestMatch >= 0 && row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { return new int[] { patternStart, i, bestMatch }; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 16
Source File: Code128Reader.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 4 votes |
private static int[] findStartPattern(BitArray row) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int[] counters = new int[6]; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { float bestVariance = MAX_AVG_VARIANCE; int bestMatch = -1; for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) { float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE); if (variance < bestVariance) { bestVariance = variance; bestMatch = startCode; } } // Look for whitespace before start pattern, >= 50% of width of start pattern if (bestMatch >= 0 && row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { return new int[]{patternStart, i, bestMatch}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 17
Source File: Code128Reader.java From QrCodeScanner with GNU General Public License v3.0 | 4 votes |
private static int[] findStartPattern(BitArray row) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int[] counters = new int[6]; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) != isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { float bestVariance = MAX_AVG_VARIANCE; int bestMatch = -1; for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) { float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE); if (variance < bestVariance) { bestVariance = variance; bestMatch = startCode; } } // Look for whitespace before start pattern, >= 50% of width of start pattern if (bestMatch >= 0 && row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { return new int[]{patternStart, i, bestMatch}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, counterPosition - 1); counters[counterPosition - 1] = 0; counters[counterPosition] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 18
Source File: Code128Reader.java From weex with Apache License 2.0 | 4 votes |
private static int[] findStartPattern(BitArray row) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int[] counters = new int[6]; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { float bestVariance = MAX_AVG_VARIANCE; int bestMatch = -1; for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) { float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE); if (variance < bestVariance) { bestVariance = variance; bestMatch = startCode; } } // Look for whitespace before start pattern, >= 50% of width of start pattern if (bestMatch >= 0 && row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { return new int[]{patternStart, i, bestMatch}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }
Example 19
Source File: Code128Reader.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
private static int[] a(BitArray bitarray) { int i1 = bitarray.getSize(); int j1 = bitarray.getNextSet(0); int ai[] = new int[6]; int k1 = ai.length; int l1 = j1; boolean flag = false; int i2 = j1; int j2 = 0; while (l1 < i1) { int k2; boolean flag1; if (flag ^ bitarray.get(l1)) { ai[j2] = 1 + ai[j2]; flag1 = flag; k2 = j2; } else { if (j2 == k1 - 1) { int i3 = 64; int j3 = -1; int k3 = 103; while (k3 <= 105) { int l3 = patternMatchVariance(ai, a[k3], 179); int l2; if (l3 < i3) { j3 = k3; } else { l3 = i3; } k3++; i3 = l3; } if (j3 >= 0 && bitarray.isRange(Math.max(0, i2 - (l1 - i2) / 2), i2, false)) { return (new int[] { i2, l1, j3 }); } l2 = i2 + (ai[0] + ai[1]); System.arraycopy(ai, 2, ai, 0, k1 - 2); ai[k1 - 2] = 0; ai[k1 - 1] = 0; k2 = j2 - 1; } else { k2 = j2 + 1; l2 = i2; } ai[k2] = 1; if (!flag) { flag1 = true; } else { flag1 = false; } i2 = l2; } l1++; flag = flag1; j2 = k2; } throw NotFoundException.getNotFoundInstance(); }
Example 20
Source File: Code128Reader.java From barcodescanner-lib-aar with MIT License | 4 votes |
private static int[] findStartPattern(BitArray row) throws NotFoundException { int width = row.getSize(); int rowOffset = row.getNextSet(0); int counterPosition = 0; int[] counters = new int[6]; int patternStart = rowOffset; boolean isWhite = false; int patternLength = counters.length; for (int i = rowOffset; i < width; i++) { if (row.get(i) ^ isWhite) { counters[counterPosition]++; } else { if (counterPosition == patternLength - 1) { float bestVariance = MAX_AVG_VARIANCE; int bestMatch = -1; for (int startCode = CODE_START_A; startCode <= CODE_START_C; startCode++) { float variance = patternMatchVariance(counters, CODE_PATTERNS[startCode], MAX_INDIVIDUAL_VARIANCE); if (variance < bestVariance) { bestVariance = variance; bestMatch = startCode; } } // Look for whitespace before start pattern, >= 50% of width of start pattern if (bestMatch >= 0 && row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) { return new int[]{patternStart, i, bestMatch}; } patternStart += counters[0] + counters[1]; System.arraycopy(counters, 2, counters, 0, patternLength - 2); counters[patternLength - 2] = 0; counters[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } counters[counterPosition] = 1; isWhite = !isWhite; } } throw NotFoundException.getNotFoundInstance(); }