react-native-nitro-zxing 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/VisionCameraZxing.podspec +48 -0
- package/android/CMakeLists.txt +43 -0
- package/android/build.gradle +150 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +7 -0
- package/android/src/main/java/com/margelo/nitro/camera/zxing/VisionCameraZxingPackage.kt +21 -0
- package/cpp/BarcodeValueTypeClassifier.cpp +70 -0
- package/cpp/BarcodeValueTypeClassifier.hpp +14 -0
- package/cpp/FrameImageView.cpp +75 -0
- package/cpp/FrameImageView.hpp +34 -0
- package/cpp/HybridBarcode.cpp +59 -0
- package/cpp/HybridBarcode.hpp +26 -0
- package/cpp/HybridBarcodeScanner.cpp +121 -0
- package/cpp/HybridBarcodeScanner.hpp +26 -0
- package/cpp/HybridBarcodeScannerFactory.cpp +11 -0
- package/cpp/HybridBarcodeScannerFactory.hpp +14 -0
- package/cpp/ImageDownscaler.cpp +34 -0
- package/cpp/ImageDownscaler.hpp +21 -0
- package/cpp/ZXingDecoder.cpp +189 -0
- package/cpp/ZXingDecoder.hpp +72 -0
- package/cpp/zxing-core/LICENSE +202 -0
- package/cpp/zxing-core/README.md +156 -0
- package/cpp/zxing-core/core/CMakeLists.txt +784 -0
- package/cpp/zxing-core/core/Version.h.in +28 -0
- package/cpp/zxing-core/core/ZXingConfig.cmake.in +9 -0
- package/cpp/zxing-core/core/src/Barcode.cpp +255 -0
- package/cpp/zxing-core/core/src/Barcode.h +191 -0
- package/cpp/zxing-core/core/src/BarcodeData.h +100 -0
- package/cpp/zxing-core/core/src/BarcodeFormat.cpp +286 -0
- package/cpp/zxing-core/core/src/BarcodeFormat.h +272 -0
- package/cpp/zxing-core/core/src/BinaryBitmap.cpp +111 -0
- package/cpp/zxing-core/core/src/BinaryBitmap.h +66 -0
- package/cpp/zxing-core/core/src/BitArray.cpp +38 -0
- package/cpp/zxing-core/core/src/BitArray.h +181 -0
- package/cpp/zxing-core/core/src/BitMatrix.cpp +175 -0
- package/cpp/zxing-core/core/src/BitMatrix.h +199 -0
- package/cpp/zxing-core/core/src/BitMatrixCursor.h +253 -0
- package/cpp/zxing-core/core/src/BitMatrixIO.cpp +101 -0
- package/cpp/zxing-core/core/src/BitMatrixIO.h +21 -0
- package/cpp/zxing-core/core/src/BitSource.cpp +77 -0
- package/cpp/zxing-core/core/src/BitSource.h +72 -0
- package/cpp/zxing-core/core/src/ByteArray.h +42 -0
- package/cpp/zxing-core/core/src/CharacterSet.cpp +78 -0
- package/cpp/zxing-core/core/src/CharacterSet.h +58 -0
- package/cpp/zxing-core/core/src/ConcentricFinder.cpp +312 -0
- package/cpp/zxing-core/core/src/ConcentricFinder.h +156 -0
- package/cpp/zxing-core/core/src/Content.cpp +471 -0
- package/cpp/zxing-core/core/src/Content.h +82 -0
- package/cpp/zxing-core/core/src/ContentType.h +19 -0
- package/cpp/zxing-core/core/src/CreateBarcode.cpp +490 -0
- package/cpp/zxing-core/core/src/CreateBarcode.h +132 -0
- package/cpp/zxing-core/core/src/DecoderResult.h +92 -0
- package/cpp/zxing-core/core/src/DetectorResult.h +44 -0
- package/cpp/zxing-core/core/src/ECI.cpp +81 -0
- package/cpp/zxing-core/core/src/ECI.h +78 -0
- package/cpp/zxing-core/core/src/Error.cpp +29 -0
- package/cpp/zxing-core/core/src/Error.h +79 -0
- package/cpp/zxing-core/core/src/Flags.h +165 -0
- package/cpp/zxing-core/core/src/GTIN.cpp +253 -0
- package/cpp/zxing-core/core/src/GTIN.h +58 -0
- package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.cpp +197 -0
- package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.h +34 -0
- package/cpp/zxing-core/core/src/GridSampler.cpp +124 -0
- package/cpp/zxing-core/core/src/GridSampler.h +59 -0
- package/cpp/zxing-core/core/src/HRI.cpp +343 -0
- package/cpp/zxing-core/core/src/HRI.h +16 -0
- package/cpp/zxing-core/core/src/HybridBinarizer.cpp +315 -0
- package/cpp/zxing-core/core/src/HybridBinarizer.h +40 -0
- package/cpp/zxing-core/core/src/ImageView.h +168 -0
- package/cpp/zxing-core/core/src/JSON.cpp +154 -0
- package/cpp/zxing-core/core/src/JSON.h +66 -0
- package/cpp/zxing-core/core/src/LocalGrid.cpp +242 -0
- package/cpp/zxing-core/core/src/LocalGrid.h +91 -0
- package/cpp/zxing-core/core/src/LogMatrix.h +105 -0
- package/cpp/zxing-core/core/src/Matrix.h +125 -0
- package/cpp/zxing-core/core/src/MultiFormatReader.cpp +107 -0
- package/cpp/zxing-core/core/src/MultiFormatReader.h +34 -0
- package/cpp/zxing-core/core/src/MultiFormatWriter.cpp +111 -0
- package/cpp/zxing-core/core/src/MultiFormatWriter.h +62 -0
- package/cpp/zxing-core/core/src/Pattern.h +472 -0
- package/cpp/zxing-core/core/src/PerspectiveTransform.cpp +81 -0
- package/cpp/zxing-core/core/src/PerspectiveTransform.h +47 -0
- package/cpp/zxing-core/core/src/Point.h +185 -0
- package/cpp/zxing-core/core/src/Quadrilateral.h +215 -0
- package/cpp/zxing-core/core/src/Range.h +112 -0
- package/cpp/zxing-core/core/src/ReadBarcode.cpp +335 -0
- package/cpp/zxing-core/core/src/ReadBarcode.h +33 -0
- package/cpp/zxing-core/core/src/Reader.h +32 -0
- package/cpp/zxing-core/core/src/ReaderOptions.h +210 -0
- package/cpp/zxing-core/core/src/ReedSolomon.cpp +100 -0
- package/cpp/zxing-core/core/src/ReedSolomon.h +66 -0
- package/cpp/zxing-core/core/src/RegressionLine.h +161 -0
- package/cpp/zxing-core/core/src/ResultPoint.cpp +20 -0
- package/cpp/zxing-core/core/src/ResultPoint.h +35 -0
- package/cpp/zxing-core/core/src/StdGenerator.h +121 -0
- package/cpp/zxing-core/core/src/StdPrint.h +38 -0
- package/cpp/zxing-core/core/src/StdScope.h +55 -0
- package/cpp/zxing-core/core/src/StructuredAppend.h +19 -0
- package/cpp/zxing-core/core/src/SymbologyIdentifier.h +29 -0
- package/cpp/zxing-core/core/src/TextDecoder.cpp +59 -0
- package/cpp/zxing-core/core/src/TextDecoder.h +23 -0
- package/cpp/zxing-core/core/src/TextEncoder.cpp +75 -0
- package/cpp/zxing-core/core/src/TextEncoder.h +31 -0
- package/cpp/zxing-core/core/src/ThresholdBinarizer.h +58 -0
- package/cpp/zxing-core/core/src/TritMatrix.h +29 -0
- package/cpp/zxing-core/core/src/Utf.cpp +276 -0
- package/cpp/zxing-core/core/src/Utf.h +26 -0
- package/cpp/zxing-core/core/src/WhiteRectDetector.cpp +276 -0
- package/cpp/zxing-core/core/src/WhiteRectDetector.h +36 -0
- package/cpp/zxing-core/core/src/WriteBarcode.cpp +213 -0
- package/cpp/zxing-core/core/src/WriteBarcode.h +72 -0
- package/cpp/zxing-core/core/src/ZXAlgorithms.h +353 -0
- package/cpp/zxing-core/core/src/ZXConfig.h +17 -0
- package/cpp/zxing-core/core/src/ZXTestSupport.h +9 -0
- package/cpp/zxing-core/core/src/ZXVersion.h +14 -0
- package/cpp/zxing-core/core/src/ZXingC.cpp +460 -0
- package/cpp/zxing-core/core/src/ZXingC.h +296 -0
- package/cpp/zxing-core/core/src/ZXingCpp.cpp +18 -0
- package/cpp/zxing-core/core/src/ZXingCpp.h +76 -0
- package/cpp/zxing-core/core/src/ZXingQt.h +606 -0
- package/cpp/zxing-core/core/src/aztec/AZDecoder.cpp +376 -0
- package/cpp/zxing-core/core/src/aztec/AZDecoder.h +20 -0
- package/cpp/zxing-core/core/src/aztec/AZDetector.cpp +508 -0
- package/cpp/zxing-core/core/src/aztec/AZDetector.h +25 -0
- package/cpp/zxing-core/core/src/aztec/AZDetectorResult.h +51 -0
- package/cpp/zxing-core/core/src/aztec/AZEncoder.cpp +318 -0
- package/cpp/zxing-core/core/src/aztec/AZEncoder.h +44 -0
- package/cpp/zxing-core/core/src/aztec/AZEncodingState.h +40 -0
- package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.cpp +377 -0
- package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.h +36 -0
- package/cpp/zxing-core/core/src/aztec/AZReader.cpp +45 -0
- package/cpp/zxing-core/core/src/aztec/AZReader.h +21 -0
- package/cpp/zxing-core/core/src/aztec/AZToken.cpp +44 -0
- package/cpp/zxing-core/core/src/aztec/AZToken.h +39 -0
- package/cpp/zxing-core/core/src/aztec/AZWriter.cpp +38 -0
- package/cpp/zxing-core/core/src/aztec/AZWriter.h +55 -0
- package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.cpp +194 -0
- package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.h +21 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.cpp +63 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.h +41 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDecoder.cpp +457 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDecoder.h +19 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDetector.cpp +1230 -0
- package/cpp/zxing-core/core/src/datamatrix/DMDetector.h +23 -0
- package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.cpp +137 -0
- package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.h +26 -0
- package/cpp/zxing-core/core/src/datamatrix/DMEncoderContext.h +128 -0
- package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.cpp +919 -0
- package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.h +29 -0
- package/cpp/zxing-core/core/src/datamatrix/DMReader.cpp +40 -0
- package/cpp/zxing-core/core/src/datamatrix/DMReader.h +21 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.cpp +141 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.h +78 -0
- package/cpp/zxing-core/core/src/datamatrix/DMSymbolShape.h +17 -0
- package/cpp/zxing-core/core/src/datamatrix/DMVersion.cpp +82 -0
- package/cpp/zxing-core/core/src/datamatrix/DMVersion.h +76 -0
- package/cpp/zxing-core/core/src/datamatrix/DMWriter.cpp +114 -0
- package/cpp/zxing-core/core/src/datamatrix/DMWriter.h +62 -0
- package/cpp/zxing-core/core/src/librscpp/README.md +65 -0
- package/cpp/zxing-core/core/src/librscpp/decode.h +258 -0
- package/cpp/zxing-core/core/src/librscpp/encode.h +124 -0
- package/cpp/zxing-core/core/src/librscpp/field.h +158 -0
- package/cpp/zxing-core/core/src/librscpp/poly.h +194 -0
- package/cpp/zxing-core/core/src/libzint/2of5inter.c +1 -0
- package/cpp/zxing-core/core/src/libzint/2of5inter_based.c +1 -0
- package/cpp/zxing-core/core/src/libzint/aztec.c +1 -0
- package/cpp/zxing-core/core/src/libzint/aztec.h +1 -0
- package/cpp/zxing-core/core/src/libzint/big5.h +1 -0
- package/cpp/zxing-core/core/src/libzint/codabar.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code128.c +1 -0
- package/cpp/zxing-core/core/src/libzint/code128.h +1 -0
- package/cpp/zxing-core/core/src/libzint/common.c +1 -0
- package/cpp/zxing-core/core/src/libzint/common.h +1 -0
- package/cpp/zxing-core/core/src/libzint/dmatrix.c +1 -0
- package/cpp/zxing-core/core/src/libzint/dmatrix.h +1 -0
- package/cpp/zxing-core/core/src/libzint/dxfilmedge.c +1 -0
- package/cpp/zxing-core/core/src/libzint/eci.c +1 -0
- package/cpp/zxing-core/core/src/libzint/eci.h +1 -0
- package/cpp/zxing-core/core/src/libzint/eci_sb.h +1 -0
- package/cpp/zxing-core/core/src/libzint/filemem.c +1 -0
- package/cpp/zxing-core/core/src/libzint/filemem.h +1 -0
- package/cpp/zxing-core/core/src/libzint/fonts/normal_woff2.h +1 -0
- package/cpp/zxing-core/core/src/libzint/fonts/upcean_woff2.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gb18030.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gb2312.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gbk.h +1 -0
- package/cpp/zxing-core/core/src/libzint/general_field.c +1 -0
- package/cpp/zxing-core/core/src/libzint/general_field.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1.c +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1.h +1 -0
- package/cpp/zxing-core/core/src/libzint/gs1_lint.h +1 -0
- package/cpp/zxing-core/core/src/libzint/iso3166.h +1 -0
- package/cpp/zxing-core/core/src/libzint/iso4217.h +1 -0
- package/cpp/zxing-core/core/src/libzint/ksx1001.h +1 -0
- package/cpp/zxing-core/core/src/libzint/large.c +1 -0
- package/cpp/zxing-core/core/src/libzint/large.h +1 -0
- package/cpp/zxing-core/core/src/libzint/library.c +1 -0
- package/cpp/zxing-core/core/src/libzint/maxicode.c +1 -0
- package/cpp/zxing-core/core/src/libzint/maxicode.h +1 -0
- package/cpp/zxing-core/core/src/libzint/medical.c +1 -0
- package/cpp/zxing-core/core/src/libzint/output.c +1 -0
- package/cpp/zxing-core/core/src/libzint/output.h +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417.c +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417.h +1 -0
- package/cpp/zxing-core/core/src/libzint/pdf417_tabs.h +1 -0
- package/cpp/zxing-core/core/src/libzint/qr.c +1 -0
- package/cpp/zxing-core/core/src/libzint/qr.h +1 -0
- package/cpp/zxing-core/core/src/libzint/raster.c +1 -0
- package/cpp/zxing-core/core/src/libzint/raster_font.h +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol.c +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol.h +1 -0
- package/cpp/zxing-core/core/src/libzint/reedsol_logs.h +1 -0
- package/cpp/zxing-core/core/src/libzint/rss.c +1 -0
- package/cpp/zxing-core/core/src/libzint/rss.h +1 -0
- package/cpp/zxing-core/core/src/libzint/sjis.h +1 -0
- package/cpp/zxing-core/core/src/libzint/stubs.c +137 -0
- package/cpp/zxing-core/core/src/libzint/svg.c +1 -0
- package/cpp/zxing-core/core/src/libzint/telepen.c +1 -0
- package/cpp/zxing-core/core/src/libzint/upcean.c +1 -0
- package/cpp/zxing-core/core/src/libzint/vector.c +1 -0
- package/cpp/zxing-core/core/src/libzint/zfiletypes.h +1 -0
- package/cpp/zxing-core/core/src/libzint/zint.h +1 -0
- package/cpp/zxing-core/core/src/libzint/zintconfig.h +1 -0
- package/cpp/zxing-core/core/src/libzueci/README.md +11 -0
- package/cpp/zxing-core/core/src/libzueci/zueci.c +1718 -0
- package/cpp/zxing-core/core/src/libzueci/zueci.h +179 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_big5.h +3884 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_common.h +31 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gb18030.h +264 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gb2312.h +2381 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_gbk.h +4047 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_ksx1001.h +2932 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_sb.h +1112 -0
- package/cpp/zxing-core/core/src/libzueci/zueci_sjis.h +2286 -0
- package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.cpp +68 -0
- package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.h +30 -0
- package/cpp/zxing-core/core/src/maxicode/MCDecoder.cpp +329 -0
- package/cpp/zxing-core/core/src/maxicode/MCDecoder.h +19 -0
- package/cpp/zxing-core/core/src/maxicode/MCReader.cpp +65 -0
- package/cpp/zxing-core/core/src/maxicode/MCReader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarReader.cpp +102 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarReader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarWriter.cpp +136 -0
- package/cpp/zxing-core/core/src/oned/ODCodabarWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Patterns.h +130 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Reader.cpp +236 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Reader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Writer.cpp +261 -0
- package/cpp/zxing-core/core/src/oned/ODCode128Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Reader.cpp +213 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Reader.h +26 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Writer.cpp +176 -0
- package/cpp/zxing-core/core/src/oned/ODCode39Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Patterns.h +80 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Reader.cpp +112 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Reader.h +21 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Writer.cpp +192 -0
- package/cpp/zxing-core/core/src/oned/ODCode93Writer.h +32 -0
- package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.cpp +246 -0
- package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.h +26 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarCommon.cpp +172 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarCommon.h +204 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.cpp +253 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.h +19 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.cpp +383 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.cpp +163 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.h +23 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarReader.cpp +240 -0
- package/cpp/zxing-core/core/src/oned/ODDataBarReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODEAN13Writer.cpp +62 -0
- package/cpp/zxing-core/core/src/oned/ODEAN13Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODEAN8Writer.cpp +51 -0
- package/cpp/zxing-core/core/src/oned/ODEAN8Writer.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODITFReader.cpp +97 -0
- package/cpp/zxing-core/core/src/oned/ODITFReader.h +33 -0
- package/cpp/zxing-core/core/src/oned/ODITFWriter.cpp +78 -0
- package/cpp/zxing-core/core/src/oned/ODITFWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.cpp +323 -0
- package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.h +32 -0
- package/cpp/zxing-core/core/src/oned/ODReader.cpp +259 -0
- package/cpp/zxing-core/core/src/oned/ODReader.h +35 -0
- package/cpp/zxing-core/core/src/oned/ODRowReader.h +222 -0
- package/cpp/zxing-core/core/src/oned/ODTelepenReader.cpp +199 -0
- package/cpp/zxing-core/core/src/oned/ODTelepenReader.h +25 -0
- package/cpp/zxing-core/core/src/oned/ODUPCAWriter.cpp +33 -0
- package/cpp/zxing-core/core/src/oned/ODUPCAWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.cpp +80 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.h +129 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEWriter.cpp +56 -0
- package/cpp/zxing-core/core/src/oned/ODUPCEWriter.h +34 -0
- package/cpp/zxing-core/core/src/oned/ODWriterHelper.cpp +39 -0
- package/cpp/zxing-core/core/src/oned/ODWriterHelper.h +48 -0
- package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.cpp +796 -0
- package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.h +23 -0
- package/cpp/zxing-core/core/src/pdf417/PDF417.cpp +85 -0
- package/cpp/zxing-core/core/src/pdf417/PDF417.h +81 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeMetadata.h +53 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.cpp +48 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.h +38 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.cpp +116 -0
- package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.h +75 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodeword.h +71 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.cpp +588 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.h +41 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCompaction.h +20 -0
- package/cpp/zxing-core/core/src/pdf417/PDFCustomData.h +32 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDecoder.cpp +725 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDecoder.h +20 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.cpp +247 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.h +74 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.cpp +321 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.h +83 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetector.cpp +371 -0
- package/cpp/zxing-core/core/src/pdf417/PDFDetector.h +45 -0
- package/cpp/zxing-core/core/src/pdf417/PDFEncoder.cpp +570 -0
- package/cpp/zxing-core/core/src/pdf417/PDFEncoder.h +182 -0
- package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.cpp +570 -0
- package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.h +32 -0
- package/cpp/zxing-core/core/src/pdf417/PDFReader.cpp +333 -0
- package/cpp/zxing-core/core/src/pdf417/PDFReader.h +28 -0
- package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.cpp +559 -0
- package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.h +41 -0
- package/cpp/zxing-core/core/src/pdf417/PDFWriter.cpp +170 -0
- package/cpp/zxing-core/core/src/pdf417/PDFWriter.h +74 -0
- package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.cpp +623 -0
- package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.h +81 -0
- package/cpp/zxing-core/core/src/pdf417/ZXNullable.h +105 -0
- package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.cpp +294 -0
- package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.h +41 -0
- package/cpp/zxing-core/core/src/qrcode/QRCodecMode.cpp +95 -0
- package/cpp/zxing-core/core/src/qrcode/QRCodecMode.h +59 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataBlock.cpp +93 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataBlock.h +52 -0
- package/cpp/zxing-core/core/src/qrcode/QRDataMask.h +50 -0
- package/cpp/zxing-core/core/src/qrcode/QRDecoder.cpp +359 -0
- package/cpp/zxing-core/core/src/qrcode/QRDecoder.h +19 -0
- package/cpp/zxing-core/core/src/qrcode/QRDetector.cpp +920 -0
- package/cpp/zxing-core/core/src/qrcode/QRDetector.h +45 -0
- package/cpp/zxing-core/core/src/qrcode/QRECB.h +52 -0
- package/cpp/zxing-core/core/src/qrcode/QREncodeResult.h +33 -0
- package/cpp/zxing-core/core/src/qrcode/QREncoder.cpp +568 -0
- package/cpp/zxing-core/core/src/qrcode/QREncoder.h +21 -0
- package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.cpp +51 -0
- package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.h +39 -0
- package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.cpp +160 -0
- package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.h +61 -0
- package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.cpp +156 -0
- package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.h +15 -0
- package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.cpp +318 -0
- package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.h +25 -0
- package/cpp/zxing-core/core/src/qrcode/QRReader.cpp +149 -0
- package/cpp/zxing-core/core/src/qrcode/QRReader.h +21 -0
- package/cpp/zxing-core/core/src/qrcode/QRVersion.cpp +754 -0
- package/cpp/zxing-core/core/src/qrcode/QRVersion.h +127 -0
- package/cpp/zxing-core/core/src/qrcode/QRWriter.cpp +51 -0
- package/cpp/zxing-core/core/src/qrcode/QRWriter.h +74 -0
- package/cpp/zxing-core/core/version.rc.in +34 -0
- package/cpp/zxing-core/core/zxing.pc.in +8 -0
- package/cpp/zxing-core/wrappers/ios/README.md +25 -0
- package/cpp/zxing-core/wrappers/ios/Sources/Wrapper/Version.h +29 -0
- package/cpp/zxing-core/zxing-cpp.podspec +45 -0
- package/lib/factory.d.ts +10 -0
- package/lib/factory.js +12 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/specs/Barcode.nitro.d.ts +63 -0
- package/lib/specs/Barcode.nitro.js +1 -0
- package/lib/specs/BarcodeFormat.d.ts +11 -0
- package/lib/specs/BarcodeFormat.js +1 -0
- package/lib/specs/BarcodeScanner.nitro.d.ts +89 -0
- package/lib/specs/BarcodeScanner.nitro.js +1 -0
- package/lib/specs/BarcodeScannerFactory.nitro.d.ts +26 -0
- package/lib/specs/BarcodeScannerFactory.nitro.js +1 -0
- package/lib/specs/BarcodeValueType.d.ts +9 -0
- package/lib/specs/BarcodeValueType.js +1 -0
- package/lib/specs/Point.d.ts +14 -0
- package/lib/specs/Point.js +1 -0
- package/lib/specs/Rect.d.ts +22 -0
- package/lib/specs/Rect.js +1 -0
- package/lib/useBarcodeScanner.d.ts +23 -0
- package/lib/useBarcodeScanner.js +25 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/VisionCameraZxing+autolinking.cmake +83 -0
- package/nitrogen/generated/android/VisionCameraZxing+autolinking.gradle +27 -0
- package/nitrogen/generated/android/VisionCameraZxingOnLoad.cpp +49 -0
- package/nitrogen/generated/android/VisionCameraZxingOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/zxing/VisionCameraZxingOnLoad.kt +35 -0
- package/nitrogen/generated/ios/VisionCameraZxing+autolinking.rb +62 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/VisionCameraZxingAutolinking.mm +35 -0
- package/nitrogen/generated/ios/VisionCameraZxingAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/BarcodeFormat.hpp +124 -0
- package/nitrogen/generated/shared/c++/BarcodeScannerOptions.hpp +85 -0
- package/nitrogen/generated/shared/c++/BarcodeValueType.hpp +120 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridBarcodeSpec.hpp +82 -0
- package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/Point.hpp +87 -0
- package/nitrogen/generated/shared/c++/Rect.hpp +95 -0
- package/nitrogen/generated/shared/c++/TargetBarcodeFormat.hpp +124 -0
- package/package.json +108 -0
- package/react-native.config.js +16 -0
- package/src/factory.ts +26 -0
- package/src/index.ts +9 -0
- package/src/specs/Barcode.nitro.ts +70 -0
- package/src/specs/BarcodeFormat.ts +31 -0
- package/src/specs/BarcodeScanner.nitro.ts +91 -0
- package/src/specs/BarcodeScannerFactory.nitro.ts +27 -0
- package/src/specs/BarcodeValueType.ts +25 -0
- package/src/specs/Point.ts +14 -0
- package/src/specs/Rect.ts +22 -0
- package/src/useBarcodeScanner.ts +36 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#include "HybridBarcodeScanner.hpp"
|
|
2
|
+
|
|
3
|
+
#include "FrameImageView.hpp"
|
|
4
|
+
#include "HybridBarcode.hpp"
|
|
5
|
+
#include "ZXingDecoder.hpp"
|
|
6
|
+
|
|
7
|
+
#include <NitroImage/PixelFormat.hpp>
|
|
8
|
+
#include <NitroImage/RawPixelData.hpp>
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
#include <cmath>
|
|
12
|
+
#include <stdexcept>
|
|
13
|
+
|
|
14
|
+
namespace margelo::nitro::camera::zxing {
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
|
|
18
|
+
using HybridBarcodes = std::vector<std::shared_ptr<HybridBarcodeSpec>>;
|
|
19
|
+
|
|
20
|
+
HybridBarcodes toHybridBarcodes(std::vector<DecodedBarcode>&& decoded) {
|
|
21
|
+
HybridBarcodes barcodes;
|
|
22
|
+
barcodes.reserve(decoded.size());
|
|
23
|
+
for (DecodedBarcode& barcode : decoded) {
|
|
24
|
+
barcodes.push_back(std::make_shared<HybridBarcode>(std::move(barcode)));
|
|
25
|
+
}
|
|
26
|
+
return barcodes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ZXing::ImageFormat toZXingImageFormat(image::PixelFormat format) {
|
|
30
|
+
switch (format) {
|
|
31
|
+
case image::PixelFormat::ARGB:
|
|
32
|
+
case image::PixelFormat::XRGB:
|
|
33
|
+
return ZXing::ImageFormat::ARGB;
|
|
34
|
+
case image::PixelFormat::BGRA:
|
|
35
|
+
case image::PixelFormat::BGRX:
|
|
36
|
+
return ZXing::ImageFormat::BGRA;
|
|
37
|
+
case image::PixelFormat::ABGR:
|
|
38
|
+
case image::PixelFormat::XBGR:
|
|
39
|
+
return ZXing::ImageFormat::ABGR;
|
|
40
|
+
case image::PixelFormat::RGBA:
|
|
41
|
+
case image::PixelFormat::RGBX:
|
|
42
|
+
return ZXing::ImageFormat::RGBA;
|
|
43
|
+
case image::PixelFormat::RGB:
|
|
44
|
+
return ZXing::ImageFormat::RGB;
|
|
45
|
+
case image::PixelFormat::BGR:
|
|
46
|
+
return ZXing::ImageFormat::BGR;
|
|
47
|
+
case image::PixelFormat::UNKNOWN:
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
throw std::runtime_error("The given Image has an unknown pixel format!");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
} // namespace
|
|
54
|
+
|
|
55
|
+
HybridBarcodeScanner::HybridBarcodeScanner(const std::vector<TargetBarcodeFormat>& formats)
|
|
56
|
+
: HybridObject(TAG), _liveDecoder(formats, ZXingDecoder::Mode::Live), _imageDecoder(formats, ZXingDecoder::Mode::Still) {}
|
|
57
|
+
|
|
58
|
+
HybridBarcodes HybridBarcodeScanner::scanCodes(const std::shared_ptr<camera::HybridFrameSpec>& frame) {
|
|
59
|
+
FrameImageView view(frame);
|
|
60
|
+
std::vector<DecodedBarcode> decoded = _liveDecoder.decode(view.imageView());
|
|
61
|
+
return toHybridBarcodes(std::move(decoded));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
std::shared_ptr<Promise<HybridBarcodes>> HybridBarcodeScanner::scanCodesAsync(const std::shared_ptr<camera::HybridFrameSpec>& frame) {
|
|
65
|
+
// Building the view has to stay on the caller's thread: on Android the Frame is a JNI-backed
|
|
66
|
+
// HybridObject and the decode threads are not attached to the JVM, so reading it there aborts the
|
|
67
|
+
// process. The view holds the Frame (and its planes) alive, so the pixel memory stays owned by
|
|
68
|
+
// the Frame for the whole async decode - no copy needed.
|
|
69
|
+
std::shared_ptr<FrameImageView> view = std::make_shared<FrameImageView>(frame);
|
|
70
|
+
std::shared_ptr<HybridBarcodeScanner> self = shared_cast<HybridBarcodeScanner>();
|
|
71
|
+
return Promise<HybridBarcodes>::async([self, view]() -> HybridBarcodes {
|
|
72
|
+
std::vector<DecodedBarcode> decoded = self->_liveDecoder.decode(view->imageView());
|
|
73
|
+
return toHybridBarcodes(std::move(decoded));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
std::shared_ptr<Promise<HybridBarcodes>> HybridBarcodeScanner::scanCodesInImageAsync(const std::shared_ptr<image::HybridImageSpec>& image) {
|
|
78
|
+
// A multi-megapixel still carries far more detail than a barcode needs, and scan cost grows
|
|
79
|
+
// with the pixel count, so shrink it first using the platform's own (optimized) scaler.
|
|
80
|
+
// Corner points are scaled back below, so callers still get coordinates in the image they passed.
|
|
81
|
+
const double longestEdge = std::max(image->getWidth(), image->getHeight());
|
|
82
|
+
std::shared_ptr<image::HybridImageSpec> source = image;
|
|
83
|
+
double cornerScale = 1.0;
|
|
84
|
+
if (longestEdge > ZXingDecoder::kStillWorkingEdge) {
|
|
85
|
+
const double ratio = ZXingDecoder::kStillWorkingEdge / longestEdge;
|
|
86
|
+
const double targetWidth = std::round(image->getWidth() * ratio);
|
|
87
|
+
const double targetHeight = std::round(image->getHeight() * ratio);
|
|
88
|
+
source = image->resize(targetWidth, targetHeight);
|
|
89
|
+
cornerScale = image->getWidth() / source->getWidth();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
image::RawPixelData raw = source->toRawPixelData(false);
|
|
93
|
+
std::shared_ptr<ArrayBuffer> buffer = raw.buffer;
|
|
94
|
+
if (!buffer->isOwner()) {
|
|
95
|
+
// A non-owning ArrayBuffer only borrows its memory, and that memory is only guaranteed to be
|
|
96
|
+
// valid for this synchronous call. Take ownership before handing it to the decode thread.
|
|
97
|
+
buffer = ArrayBuffer::copy(buffer);
|
|
98
|
+
}
|
|
99
|
+
const int width = static_cast<int>(raw.width);
|
|
100
|
+
const int height = static_cast<int>(raw.height);
|
|
101
|
+
const ZXing::ImageFormat format = toZXingImageFormat(raw.pixelFormat);
|
|
102
|
+
// Resolve the address here: a platform-backed ArrayBuffer reaches its memory through the JVM,
|
|
103
|
+
// which is only available on this thread - the decode thread just reads the resolved pointer.
|
|
104
|
+
const uint8_t* data = buffer->data();
|
|
105
|
+
return Promise<HybridBarcodes>::async([buffer, data, width, height, format, cornerScale, decoder = _imageDecoder]() -> HybridBarcodes {
|
|
106
|
+
ZXing::ImageView view(data, width, height, format);
|
|
107
|
+
std::vector<DecodedBarcode> decoded = decoder.decode(view);
|
|
108
|
+
if (cornerScale != 1.0) {
|
|
109
|
+
for (DecodedBarcode& barcode : decoded) {
|
|
110
|
+
for (ZXing::PointI& corner : barcode.corners) {
|
|
111
|
+
const int x = static_cast<int>(std::lround(corner.x * cornerScale));
|
|
112
|
+
const int y = static_cast<int>(std::lround(corner.y * cornerScale));
|
|
113
|
+
corner = ZXing::PointI{x, y};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return toHybridBarcodes(std::move(decoded));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "HybridBarcodeScannerSpec.hpp"
|
|
4
|
+
#include "TargetBarcodeFormat.hpp"
|
|
5
|
+
|
|
6
|
+
#include "ZXingDecoder.hpp"
|
|
7
|
+
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::camera::zxing {
|
|
11
|
+
|
|
12
|
+
class HybridBarcodeScanner final : public HybridBarcodeScannerSpec {
|
|
13
|
+
public:
|
|
14
|
+
explicit HybridBarcodeScanner(const std::vector<TargetBarcodeFormat>& formats);
|
|
15
|
+
|
|
16
|
+
std::vector<std::shared_ptr<HybridBarcodeSpec>> scanCodes(const std::shared_ptr<camera::HybridFrameSpec>& frame) override;
|
|
17
|
+
std::shared_ptr<Promise<std::vector<std::shared_ptr<HybridBarcodeSpec>>>> scanCodesAsync(const std::shared_ptr<camera::HybridFrameSpec>& frame) override;
|
|
18
|
+
std::shared_ptr<Promise<std::vector<std::shared_ptr<HybridBarcodeSpec>>>>
|
|
19
|
+
scanCodesInImageAsync(const std::shared_ptr<image::HybridImageSpec>& image) override;
|
|
20
|
+
|
|
21
|
+
private:
|
|
22
|
+
ZXingDecoder _liveDecoder;
|
|
23
|
+
ZXingDecoder _imageDecoder;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#include "HybridBarcodeScannerFactory.hpp"
|
|
2
|
+
|
|
3
|
+
#include "HybridBarcodeScanner.hpp"
|
|
4
|
+
|
|
5
|
+
namespace margelo::nitro::camera::zxing {
|
|
6
|
+
|
|
7
|
+
std::shared_ptr<HybridBarcodeScannerSpec> HybridBarcodeScannerFactory::createBarcodeScanner(const BarcodeScannerOptions& options) {
|
|
8
|
+
return std::make_shared<HybridBarcodeScanner>(options.barcodeFormats);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "HybridZXingBarcodeScannerFactorySpec.hpp"
|
|
4
|
+
|
|
5
|
+
namespace margelo::nitro::camera::zxing {
|
|
6
|
+
|
|
7
|
+
class HybridBarcodeScannerFactory final : public HybridZXingBarcodeScannerFactorySpec {
|
|
8
|
+
public:
|
|
9
|
+
HybridBarcodeScannerFactory() : HybridObject(TAG) {}
|
|
10
|
+
|
|
11
|
+
std::shared_ptr<HybridBarcodeScannerSpec> createBarcodeScanner(const BarcodeScannerOptions& options) override;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "ImageDownscaler.hpp"
|
|
2
|
+
|
|
3
|
+
namespace margelo::nitro::camera::zxing {
|
|
4
|
+
|
|
5
|
+
std::vector<uint8_t> downscaleToLuminance(const ZXing::ImageView& image, int factor, ZXing::ImageView& outView) {
|
|
6
|
+
const int width = image.width() / factor;
|
|
7
|
+
const int height = image.height() / factor;
|
|
8
|
+
const int pixelStride = image.pixStride();
|
|
9
|
+
const int redIndex = ZXing::RedIndex(image.format());
|
|
10
|
+
const int greenIndex = ZXing::GreenIndex(image.format());
|
|
11
|
+
const int blueIndex = ZXing::BlueIndex(image.format());
|
|
12
|
+
const bool isLuminance = image.format() == ZXing::ImageFormat::Lum;
|
|
13
|
+
const unsigned samples = static_cast<unsigned>(factor) * static_cast<unsigned>(factor);
|
|
14
|
+
|
|
15
|
+
std::vector<uint8_t> pixels(static_cast<size_t>(width) * static_cast<size_t>(height));
|
|
16
|
+
for (int y = 0; y < height; y++) {
|
|
17
|
+
for (int x = 0; x < width; x++) {
|
|
18
|
+
unsigned sum = 0;
|
|
19
|
+
for (int blockY = 0; blockY < factor; blockY++) {
|
|
20
|
+
const uint8_t* row = image.data(x * factor, y * factor + blockY);
|
|
21
|
+
for (int blockX = 0; blockX < factor; blockX++) {
|
|
22
|
+
const uint8_t* pixel = row + blockX * pixelStride;
|
|
23
|
+
sum += isLuminance ? *pixel : ZXing::RGBToLum(pixel[redIndex], pixel[greenIndex], pixel[blueIndex]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const size_t index = static_cast<size_t>(y) * static_cast<size_t>(width) + static_cast<size_t>(x);
|
|
27
|
+
pixels[index] = static_cast<uint8_t>(sum / samples);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
outView = ZXing::ImageView(pixels.data(), width, height, ZXing::ImageFormat::Lum);
|
|
31
|
+
return pixels;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "ImageView.h"
|
|
4
|
+
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
namespace margelo::nitro::camera::zxing {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Box-averages `image` down by an integer `factor` into a compact luminance buffer,
|
|
12
|
+
* converting colour input to luminance in the same pass.
|
|
13
|
+
*
|
|
14
|
+
* Averaging (rather than dropping pixels) keeps barcode edges intact: plain subsampling
|
|
15
|
+
* aliases the fine bar/module pattern and can make a readable code undecodable.
|
|
16
|
+
*
|
|
17
|
+
* @returns the pixel data; `outView` is a view onto it and stays valid while it is alive.
|
|
18
|
+
*/
|
|
19
|
+
std::vector<uint8_t> downscaleToLuminance(const ZXing::ImageView& image, int factor, ZXing::ImageView& outView);
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#include "ZXingDecoder.hpp"
|
|
2
|
+
|
|
3
|
+
#include "BarcodeValueTypeClassifier.hpp"
|
|
4
|
+
#include "ImageDownscaler.hpp"
|
|
5
|
+
|
|
6
|
+
#include "Barcode.h"
|
|
7
|
+
#include "BarcodeFormat.h"
|
|
8
|
+
#include "ReadBarcode.h"
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
#include <stdexcept>
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::camera::zxing {
|
|
14
|
+
|
|
15
|
+
namespace {
|
|
16
|
+
|
|
17
|
+
/// How often the rotation-aware fallback runs while scanning live frames.
|
|
18
|
+
constexpr uint64_t kLiveRotationPeriod = 4;
|
|
19
|
+
|
|
20
|
+
ZXing::BarcodeFormat toZXingFormat(TargetBarcodeFormat format) {
|
|
21
|
+
switch (format) {
|
|
22
|
+
case TargetBarcodeFormat::CODE_128:
|
|
23
|
+
return ZXing::BarcodeFormat::Code128;
|
|
24
|
+
case TargetBarcodeFormat::CODE_39:
|
|
25
|
+
return ZXing::BarcodeFormat::Code39;
|
|
26
|
+
case TargetBarcodeFormat::CODE_93:
|
|
27
|
+
return ZXing::BarcodeFormat::Code93;
|
|
28
|
+
case TargetBarcodeFormat::CODABAR:
|
|
29
|
+
return ZXing::BarcodeFormat::Codabar;
|
|
30
|
+
case TargetBarcodeFormat::DATA_MATRIX:
|
|
31
|
+
return ZXing::BarcodeFormat::DataMatrix;
|
|
32
|
+
case TargetBarcodeFormat::EAN_13:
|
|
33
|
+
return ZXing::BarcodeFormat::EAN13;
|
|
34
|
+
case TargetBarcodeFormat::EAN_8:
|
|
35
|
+
return ZXing::BarcodeFormat::EAN8;
|
|
36
|
+
case TargetBarcodeFormat::ITF:
|
|
37
|
+
return ZXing::BarcodeFormat::ITF;
|
|
38
|
+
case TargetBarcodeFormat::QR_CODE:
|
|
39
|
+
return ZXing::BarcodeFormat::QRCode;
|
|
40
|
+
case TargetBarcodeFormat::UPC_A:
|
|
41
|
+
return ZXing::BarcodeFormat::UPCA;
|
|
42
|
+
case TargetBarcodeFormat::UPC_E:
|
|
43
|
+
return ZXing::BarcodeFormat::UPCE;
|
|
44
|
+
case TargetBarcodeFormat::PDF_417:
|
|
45
|
+
return ZXing::BarcodeFormat::PDF417;
|
|
46
|
+
case TargetBarcodeFormat::AZTEC:
|
|
47
|
+
return ZXing::BarcodeFormat::Aztec;
|
|
48
|
+
case TargetBarcodeFormat::ALL_FORMATS:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
throw std::invalid_argument("Unknown TargetBarcodeFormat: " + std::to_string(static_cast<int>(format)));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
constexpr std::array<TargetBarcodeFormat, 13> kAllFormats = {
|
|
55
|
+
TargetBarcodeFormat::CODE_128, TargetBarcodeFormat::CODE_39, TargetBarcodeFormat::CODE_93, TargetBarcodeFormat::CODABAR, TargetBarcodeFormat::DATA_MATRIX,
|
|
56
|
+
TargetBarcodeFormat::EAN_13, TargetBarcodeFormat::EAN_8, TargetBarcodeFormat::ITF, TargetBarcodeFormat::QR_CODE, TargetBarcodeFormat::UPC_A,
|
|
57
|
+
TargetBarcodeFormat::UPC_E, TargetBarcodeFormat::PDF_417, TargetBarcodeFormat::AZTEC,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
BarcodeFormat toNitroFormat(const ZXing::Barcode& barcode) {
|
|
61
|
+
switch (barcode.symbology()) {
|
|
62
|
+
case ZXing::BarcodeFormat::Code128:
|
|
63
|
+
return BarcodeFormat::CODE_128;
|
|
64
|
+
case ZXing::BarcodeFormat::Code39:
|
|
65
|
+
return BarcodeFormat::CODE_39;
|
|
66
|
+
case ZXing::BarcodeFormat::Code93:
|
|
67
|
+
return BarcodeFormat::CODE_93;
|
|
68
|
+
case ZXing::BarcodeFormat::Codabar:
|
|
69
|
+
return BarcodeFormat::CODABAR;
|
|
70
|
+
case ZXing::BarcodeFormat::DataMatrix:
|
|
71
|
+
return BarcodeFormat::DATA_MATRIX;
|
|
72
|
+
case ZXing::BarcodeFormat::ITF:
|
|
73
|
+
return BarcodeFormat::ITF;
|
|
74
|
+
case ZXing::BarcodeFormat::QRCode:
|
|
75
|
+
return BarcodeFormat::QR_CODE;
|
|
76
|
+
case ZXing::BarcodeFormat::PDF417:
|
|
77
|
+
return BarcodeFormat::PDF_417;
|
|
78
|
+
case ZXing::BarcodeFormat::Aztec:
|
|
79
|
+
return BarcodeFormat::AZTEC;
|
|
80
|
+
case ZXing::BarcodeFormat::EANUPC:
|
|
81
|
+
switch (barcode.format()) {
|
|
82
|
+
case ZXing::BarcodeFormat::EAN8:
|
|
83
|
+
return BarcodeFormat::EAN_8;
|
|
84
|
+
case ZXing::BarcodeFormat::UPCA:
|
|
85
|
+
return BarcodeFormat::UPC_A;
|
|
86
|
+
case ZXing::BarcodeFormat::UPCE:
|
|
87
|
+
return BarcodeFormat::UPC_E;
|
|
88
|
+
default:
|
|
89
|
+
return BarcodeFormat::EAN_13;
|
|
90
|
+
}
|
|
91
|
+
default:
|
|
92
|
+
return BarcodeFormat::UNKNOWN;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
ZXing::ReaderOptions makeOptions(const std::vector<ZXing::BarcodeFormat>& formats, bool tryHarder, bool tryRotate, bool tryDownscale) {
|
|
97
|
+
ZXing::BarcodeFormats barcodeFormats{std::vector<ZXing::BarcodeFormat>(formats)};
|
|
98
|
+
ZXing::ReaderOptions options;
|
|
99
|
+
options.setFormats(barcodeFormats);
|
|
100
|
+
options.setTryHarder(tryHarder);
|
|
101
|
+
options.setTryRotate(tryRotate);
|
|
102
|
+
options.setTryInvert(tryHarder);
|
|
103
|
+
options.setTryDownscale(tryDownscale);
|
|
104
|
+
return options;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
DecodedBarcode toDecodedBarcode(const ZXing::Barcode& barcode, int scale) {
|
|
108
|
+
DecodedBarcode decoded;
|
|
109
|
+
decoded.format = toNitroFormat(barcode);
|
|
110
|
+
decoded.rawValue = barcode.text(ZXing::TextMode::Plain);
|
|
111
|
+
decoded.displayValue = barcode.text(ZXing::TextMode::HRI);
|
|
112
|
+
decoded.rawBytes = barcode.bytes();
|
|
113
|
+
const ZXing::Position& position = barcode.position();
|
|
114
|
+
for (size_t i = 0; i < 4; i++) {
|
|
115
|
+
// Map back to the coordinate system of the image the caller passed in.
|
|
116
|
+
decoded.corners[i] = scale * position[i];
|
|
117
|
+
}
|
|
118
|
+
decoded.valueType = classifyValueType(decoded.rawValue, decoded.format, barcode.contentType());
|
|
119
|
+
return decoded;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
} // namespace
|
|
123
|
+
|
|
124
|
+
ZXingDecoder::ZXingDecoder(const std::vector<TargetBarcodeFormat>& formats, Mode mode) {
|
|
125
|
+
if (formats.empty()) {
|
|
126
|
+
throw std::invalid_argument("Target barcodeFormats cannot be empty!");
|
|
127
|
+
}
|
|
128
|
+
std::vector<ZXing::BarcodeFormat> zxingFormats;
|
|
129
|
+
for (TargetBarcodeFormat format : formats) {
|
|
130
|
+
if (format == TargetBarcodeFormat::ALL_FORMATS) {
|
|
131
|
+
for (TargetBarcodeFormat all : kAllFormats) {
|
|
132
|
+
zxingFormats.push_back(toZXingFormat(all));
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
zxingFormats.push_back(toZXingFormat(format));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (mode == Mode::Live) {
|
|
140
|
+
// Most frames either contain a readable code or none at all, so start with the cheapest
|
|
141
|
+
// scan and only pay for rotation handling when that finds nothing.
|
|
142
|
+
_attempts.push_back({makeOptions(zxingFormats, false, false, false), 0, 1});
|
|
143
|
+
// Rotation handling costs several times a plain scan, so look for rotated codes periodically
|
|
144
|
+
// instead of on every frame that finds nothing.
|
|
145
|
+
_attempts.push_back({makeOptions(zxingFormats, false, true, false), 0, kLiveRotationPeriod});
|
|
146
|
+
} else {
|
|
147
|
+
// A still is usually many megapixels: scan a reduced copy first, then the full image, and
|
|
148
|
+
// only then the expensive heuristics that help with blurred or inverted captures.
|
|
149
|
+
_attempts.push_back({makeOptions(zxingFormats, false, false, true), kStillWorkingEdge, 1});
|
|
150
|
+
_attempts.push_back({makeOptions(zxingFormats, false, true, true), 0, 1});
|
|
151
|
+
_attempts.push_back({makeOptions(zxingFormats, true, true, true), 0, 1});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
std::vector<DecodedBarcode> ZXingDecoder::decode(const ZXing::ImageView& image) const {
|
|
156
|
+
const uint64_t call = _calls->fetch_add(1, std::memory_order_relaxed);
|
|
157
|
+
for (const Attempt& attempt : _attempts) {
|
|
158
|
+
if (attempt.period > 1 && call % attempt.period != 0) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const int longestEdge = std::max(image.width(), image.height());
|
|
162
|
+
const int factor = attempt.maxEdge > 0 ? longestEdge / attempt.maxEdge : 1;
|
|
163
|
+
|
|
164
|
+
ZXing::Barcodes barcodes;
|
|
165
|
+
int scale = 1;
|
|
166
|
+
if (factor > 1) {
|
|
167
|
+
ZXing::ImageView scaled;
|
|
168
|
+
// Keep the pixels alive for as long as the view is read.
|
|
169
|
+
std::vector<uint8_t> pixels = downscaleToLuminance(image, factor, scaled);
|
|
170
|
+
barcodes = ZXing::ReadBarcodes(scaled, attempt.options);
|
|
171
|
+
scale = factor;
|
|
172
|
+
} else {
|
|
173
|
+
barcodes = ZXing::ReadBarcodes(image, attempt.options);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
std::vector<DecodedBarcode> decoded;
|
|
177
|
+
for (const ZXing::Barcode& barcode : barcodes) {
|
|
178
|
+
if (barcode.isValid()) {
|
|
179
|
+
decoded.push_back(toDecodedBarcode(barcode, scale));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (!decoded.empty()) {
|
|
183
|
+
return decoded;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
} // namespace margelo::nitro::camera::zxing
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "BarcodeFormat.hpp"
|
|
4
|
+
#include "BarcodeValueType.hpp"
|
|
5
|
+
#include "TargetBarcodeFormat.hpp"
|
|
6
|
+
|
|
7
|
+
#include "ImageView.h"
|
|
8
|
+
#include "Point.h"
|
|
9
|
+
#include "ReaderOptions.h"
|
|
10
|
+
|
|
11
|
+
#include <array>
|
|
12
|
+
#include <atomic>
|
|
13
|
+
#include <cstdint>
|
|
14
|
+
#include <memory>
|
|
15
|
+
#include <string>
|
|
16
|
+
#include <vector>
|
|
17
|
+
|
|
18
|
+
namespace margelo::nitro::camera::zxing {
|
|
19
|
+
|
|
20
|
+
struct DecodedBarcode {
|
|
21
|
+
BarcodeFormat format = BarcodeFormat::UNKNOWN;
|
|
22
|
+
BarcodeValueType valueType = BarcodeValueType::UNKNOWN;
|
|
23
|
+
std::string rawValue;
|
|
24
|
+
std::string displayValue;
|
|
25
|
+
std::vector<uint8_t> rawBytes;
|
|
26
|
+
std::array<ZXing::PointI, 4> corners{};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Decodes barcodes with zxing-cpp.
|
|
31
|
+
*
|
|
32
|
+
* Decoding cost grows with the number of pixels scanned and with how many heuristics are
|
|
33
|
+
* enabled, so the decoder runs an escalating ladder of attempts: the cheapest configuration
|
|
34
|
+
* first, and a more expensive one only if the previous attempt found nothing. A frame that
|
|
35
|
+
* contains a readable code therefore pays only for the cheap attempt.
|
|
36
|
+
*
|
|
37
|
+
* While scanning live, most frames contain no readable code at all, so the expensive fallbacks
|
|
38
|
+
* are spread across frames rather than run on every miss: a code they can find is still picked
|
|
39
|
+
* up within a few frames, but the per-frame cost stays close to the cheap attempt.
|
|
40
|
+
*/
|
|
41
|
+
class ZXingDecoder final {
|
|
42
|
+
public:
|
|
43
|
+
/**
|
|
44
|
+
* - Live: tuned for camera frames arriving continuously, where latency per frame matters.
|
|
45
|
+
* - Still: tuned for a single high-resolution capture, where a slower fallback is acceptable.
|
|
46
|
+
*/
|
|
47
|
+
enum class Mode { Live, Still };
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Longest edge a still image is scanned at. Larger captures are scaled down first: they cost
|
|
51
|
+
* proportionally more to scan while carrying more detail than a barcode needs.
|
|
52
|
+
*/
|
|
53
|
+
static constexpr int kStillWorkingEdge = 1280;
|
|
54
|
+
|
|
55
|
+
explicit ZXingDecoder(const std::vector<TargetBarcodeFormat>& formats, Mode mode = Mode::Live);
|
|
56
|
+
|
|
57
|
+
std::vector<DecodedBarcode> decode(const ZXing::ImageView& image) const;
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
struct Attempt {
|
|
61
|
+
ZXing::ReaderOptions options;
|
|
62
|
+
/// Longest edge to scan at, or 0 to scan the image at its native size.
|
|
63
|
+
int maxEdge;
|
|
64
|
+
/// Run this attempt on every Nth call. 1 runs it whenever the previous attempts found nothing.
|
|
65
|
+
uint64_t period;
|
|
66
|
+
};
|
|
67
|
+
std::vector<Attempt> _attempts;
|
|
68
|
+
/// Shared by copies of this decoder so one scanner keeps a single cadence.
|
|
69
|
+
std::shared_ptr<std::atomic<uint64_t>> _calls = std::make_shared<std::atomic<uint64_t>>(0);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
} // namespace margelo::nitro::camera::zxing
|