com.google.zxing.qrcode.detector.FinderPatternInfo Java Examples
The following examples show how to use
com.google.zxing.qrcode.detector.FinderPatternInfo.
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: MultiDetector.java From ScreenCapture with MIT License | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #2
Source File: MultiDetector.java From Tesseract-OCR-Scanner with Apache License 2.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #3
Source File: MultiDetector.java From Telegram with GNU General Public License v2.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(EMPTY_DETECTOR_RESULTS); } }
Example #4
Source File: MultiDetector.java From QrCodeScanner with GNU General Public License v3.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #5
Source File: MultiDetector.java From ZXing-Orient with Apache License 2.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #6
Source File: MultiDetector.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(EMPTY_DETECTOR_RESULTS); } }
Example #7
Source File: MultiDetector.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #8
Source File: MultiDetector.java From weex with Apache License 2.0 | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #9
Source File: MultiDetector.java From reacteu-app with MIT License | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<DetectorResult>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #10
Source File: MultiDetector.java From barcodescanner-lib-aar with MIT License | 6 votes |
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException { BitMatrix image = getImage(); ResultPointCallback resultPointCallback = hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback); FinderPatternInfo[] infos = finder.findMulti(hints); if (infos.length == 0) { throw NotFoundException.getNotFoundInstance(); } List<DetectorResult> result = new ArrayList<>(); for (FinderPatternInfo info : infos) { try { result.add(processFinderPatternInfo(info)); } catch (ReaderException e) { // ignore } } if (result.isEmpty()) { return EMPTY_DETECTOR_RESULTS; } else { return result.toArray(new DetectorResult[result.size()]); } }
Example #11
Source File: MultiFinderPatternFinder.java From Telegram with GNU General Public License v2.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (3 * maxI) / (4 * MAX_MODULES); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values clearCounts(stateCount); int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j)) { // Yes // Clear state to start looking again currentState = 0; clearCounts(stateCount); } else { // No, shift counts back by two shiftCounts2(stateCount); currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ); } } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMultipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(EMPTY_RESULT_ARRAY); } }
Example #12
Source File: MultiFinderPatternFinder.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (3 * maxI) / (4 * MAX_MODULES); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values clearCounts(stateCount); int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j)) { // Yes // Clear state to start looking again currentState = 0; clearCounts(stateCount); } else { // No, shift counts back by two shiftCounts2(stateCount); currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ); } } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMultipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(EMPTY_RESULT_ARRAY); } }
Example #13
Source File: MultiFinderPatternFinder.java From reacteu-app with MIT License | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount)) { // Yes boolean confirmed = handlePossibleCenter(stateCount, i, j); if (!confirmed) { do { // Advance to next black pixel j++; } while (j < maxJ && !image.get(j, i)); j--; // back up to that last white pixel } // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<FinderPatternInfo>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #14
Source File: MultiFinderPatternFinder.java From barcodescanner-lib-aar with MIT License | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #15
Source File: MultiFinderPatternFinder.java From weex with Apache License 2.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #16
Source File: MultiFinderPatternFinder.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #17
Source File: MultiFinderPatternFinder.java From ZXing-Orient with Apache License 2.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #18
Source File: MultiFinderPatternFinder.java From QrCodeScanner with GNU General Public License v3.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #19
Source File: MultiFinderPatternFinder.java From Tesseract-OCR-Scanner with Apache License 2.0 | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }
Example #20
Source File: MultiFinderPatternFinder.java From ScreenCapture with MIT License | 4 votes |
public FinderPatternInfo[] findMulti(Map<DecodeHintType,?> hints) throws NotFoundException { boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); boolean pureBarcode = hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE); BitMatrix image = getImage(); int maxI = image.getHeight(); int maxJ = image.getWidth(); // We are looking for black/white/black/white/black modules in // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the // image, and then account for the center being 3 modules in size. This gives the smallest // number of pixels the center could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } int[] stateCount = new int[5]; for (int i = iSkip - 1; i < maxI; i += iSkip) { // Get a row of black/white values stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; int currentState = 0; for (int j = 0; j < maxJ; j++) { if (image.get(j, i)) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; } stateCount[currentState]++; } else { // White pixel if ((currentState & 1) == 0) { // Counting black pixels if (currentState == 4) { // A winner? if (foundPatternCross(stateCount) && handlePossibleCenter(stateCount, i, j, pureBarcode)) { // Yes // Clear state to start looking again currentState = 0; stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; stateCount[3] = 0; stateCount[4] = 0; } else { // No, shift counts back by two stateCount[0] = stateCount[2]; stateCount[1] = stateCount[3]; stateCount[2] = stateCount[4]; stateCount[3] = 1; stateCount[4] = 0; currentState = 3; } } else { stateCount[++currentState]++; } } else { // Counting white pixels stateCount[currentState]++; } } } // for j=... if (foundPatternCross(stateCount)) { handlePossibleCenter(stateCount, i, maxJ, pureBarcode); } // end if foundPatternCross } // for i=iSkip-1 ... FinderPattern[][] patternInfo = selectMutipleBestPatterns(); List<FinderPatternInfo> result = new ArrayList<>(); for (FinderPattern[] pattern : patternInfo) { ResultPoint.orderBestPatterns(pattern); result.add(new FinderPatternInfo(pattern)); } if (result.isEmpty()) { return EMPTY_RESULT_ARRAY; } else { return result.toArray(new FinderPatternInfo[result.size()]); } }