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,472 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Axel Waggershauser
|
|
3
|
+
*/
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "Range.h"
|
|
9
|
+
#include "ZXAlgorithms.h"
|
|
10
|
+
|
|
11
|
+
#include <algorithm>
|
|
12
|
+
#include <array>
|
|
13
|
+
#include <bit>
|
|
14
|
+
#include <cassert>
|
|
15
|
+
#include <cmath>
|
|
16
|
+
#include <climits>
|
|
17
|
+
#include <cstddef>
|
|
18
|
+
#include <cstdint>
|
|
19
|
+
#include <iterator>
|
|
20
|
+
#include <limits>
|
|
21
|
+
#include <type_traits>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
namespace ZXing {
|
|
25
|
+
|
|
26
|
+
using PatternType = uint16_t;
|
|
27
|
+
template<int N> using Pattern = std::array<PatternType, N>;
|
|
28
|
+
using PatternRow = std::vector<PatternType>;
|
|
29
|
+
|
|
30
|
+
class PatternView
|
|
31
|
+
{
|
|
32
|
+
using Iterator = PatternRow::const_pointer;
|
|
33
|
+
Iterator _data = nullptr;
|
|
34
|
+
int _size = 0;
|
|
35
|
+
Iterator _base = nullptr;
|
|
36
|
+
Iterator _end = nullptr;
|
|
37
|
+
|
|
38
|
+
public:
|
|
39
|
+
using value_type = PatternRow::value_type;
|
|
40
|
+
|
|
41
|
+
PatternView() = default;
|
|
42
|
+
|
|
43
|
+
// A PatternRow always starts with the width of whitespace in front of the first black bar.
|
|
44
|
+
// The first element of the PatternView is the first bar.
|
|
45
|
+
PatternView(const PatternRow& bars)
|
|
46
|
+
: _data(bars.data() + 1), _size(Size(bars) - 1), _base(bars.data()), _end(bars.data() + bars.size())
|
|
47
|
+
{}
|
|
48
|
+
|
|
49
|
+
PatternView(Iterator data, int size, Iterator base, Iterator end) : _data(data), _size(size), _base(base), _end(end) {}
|
|
50
|
+
|
|
51
|
+
template <size_t N>
|
|
52
|
+
constexpr PatternView(const Pattern<N>& row) : _data(row.data()), _size(N)
|
|
53
|
+
{}
|
|
54
|
+
|
|
55
|
+
Iterator data() const { return _data; }
|
|
56
|
+
Iterator begin() const { return _data; }
|
|
57
|
+
Iterator end() const { return _data + _size; }
|
|
58
|
+
|
|
59
|
+
constexpr value_type operator[](int i) const
|
|
60
|
+
{
|
|
61
|
+
// assert(i < _count);
|
|
62
|
+
return _data[i];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
constexpr int sum(int n = 0) const { return Reduce(_data, _data + (n == 0 ? _size : n)); }
|
|
66
|
+
constexpr int size() const { return _size; }
|
|
67
|
+
|
|
68
|
+
// index is the number of bars and spaces from the first bar to the current position
|
|
69
|
+
int index() const { return narrow_cast<int>(_data - _base) - 1; }
|
|
70
|
+
int pixelsInFront() const { return Reduce(_base, _data); }
|
|
71
|
+
int pixelsTillEnd() const { return Reduce(_base, _data + _size) - 1; }
|
|
72
|
+
bool isAtFirstBar() const { return _data == _base + 1; }
|
|
73
|
+
bool isAtLastBar() const { return _data + _size == _end - 1; }
|
|
74
|
+
bool isValid(int n) const { return _data && _data >= _base && _data + n <= _end; }
|
|
75
|
+
bool isValid() const { return isValid(size()); }
|
|
76
|
+
int spaceInFront() const { return isAtFirstBar() ? INT_MAX : _data[-1]; }
|
|
77
|
+
|
|
78
|
+
template<bool acceptIfAtFirstBar = false>
|
|
79
|
+
bool hasQuietZoneBefore(float scale) const
|
|
80
|
+
{
|
|
81
|
+
return (acceptIfAtFirstBar && isAtFirstBar()) || _data[-1] >= sum() * scale;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
template<bool acceptIfAtLastBar = true>
|
|
85
|
+
bool hasQuietZoneAfter(float scale) const
|
|
86
|
+
{
|
|
87
|
+
return (acceptIfAtLastBar && isAtLastBar()) || _data[_size] >= sum() * scale;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
PatternView subView(int offset, int size = 0) const
|
|
91
|
+
{
|
|
92
|
+
// if(std::abs(size) > count())
|
|
93
|
+
// printf("%d > %d\n", std::abs(size), _count);
|
|
94
|
+
// assert(std::abs(size) <= count());
|
|
95
|
+
if (size == 0)
|
|
96
|
+
size = _size - offset;
|
|
97
|
+
else if (size < 0)
|
|
98
|
+
size = _size - offset + size;
|
|
99
|
+
return {begin() + offset, std::max(size, 0), _base, _end};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
bool shift(int n)
|
|
103
|
+
{
|
|
104
|
+
return _data && ((_data += n) + _size <= _end);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
bool skipPair()
|
|
108
|
+
{
|
|
109
|
+
return shift(2);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
bool skipSymbol()
|
|
113
|
+
{
|
|
114
|
+
return shift(_size);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
bool skipSingle(int maxWidth)
|
|
118
|
+
{
|
|
119
|
+
return shift(1) && _data[-1] <= maxWidth;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void extend()
|
|
123
|
+
{
|
|
124
|
+
_size = std::max(0, narrow_cast<int>(_end - _data));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @brief The BarAndSpace struct is a simple 2 element data structure to hold information about bar(s) and space(s).
|
|
130
|
+
*
|
|
131
|
+
* The operator[](int) can be used in combination with a PatternView
|
|
132
|
+
*/
|
|
133
|
+
template <typename T>
|
|
134
|
+
struct BarAndSpace
|
|
135
|
+
{
|
|
136
|
+
using value_type = T;
|
|
137
|
+
T bar = {}, space = {};
|
|
138
|
+
// even index -> bar, odd index -> space
|
|
139
|
+
constexpr T& operator[](int i) noexcept { return reinterpret_cast<T*>(this)[i & 1]; }
|
|
140
|
+
constexpr T operator[](int i) const noexcept { return reinterpret_cast<const T*>(this)[i & 1]; }
|
|
141
|
+
bool isValid() const { return bar != T{} && space != T{}; }
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
using BarAndSpaceI = BarAndSpace<PatternType>;
|
|
145
|
+
|
|
146
|
+
template <int LEN, typename RT, typename T>
|
|
147
|
+
constexpr auto BarAndSpaceSum(const T* view) noexcept
|
|
148
|
+
{
|
|
149
|
+
BarAndSpace<RT> res;
|
|
150
|
+
for (int i = 0; i < LEN; ++i)
|
|
151
|
+
res[i] += view[i];
|
|
152
|
+
return res;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @brief FixedPattern describes a compile-time constant (start/stop) pattern.
|
|
157
|
+
*
|
|
158
|
+
* N = number of bars/spaces
|
|
159
|
+
* SUM = sum over all N elements (size of pattern in modules)
|
|
160
|
+
* IS_SPARSE = whether or not the pattern contains '0's denoting 'wide' bars/spaces
|
|
161
|
+
*/
|
|
162
|
+
template <int N, int SUM, bool IS_SPARSE = false>
|
|
163
|
+
struct FixedPattern : public Pattern<N>
|
|
164
|
+
{
|
|
165
|
+
static_assert(N > 0, "N must be > 0");
|
|
166
|
+
static_assert(SUM > 0, "SUM must be > 0");
|
|
167
|
+
static_assert(SUM >= N || IS_SPARSE, "SUM must be >= N");
|
|
168
|
+
|
|
169
|
+
using typename Pattern<N>::value_type;
|
|
170
|
+
using Pattern<N>::data;
|
|
171
|
+
|
|
172
|
+
constexpr int size() const noexcept { return N; }
|
|
173
|
+
constexpr int sum() const noexcept { return SUM; }
|
|
174
|
+
constexpr BarAndSpace<value_type> sums() const noexcept { return BarAndSpaceSum<N, value_type>(data()); }
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
template <int N, int SUM>
|
|
178
|
+
using FixedSparsePattern = FixedPattern<N, SUM, true>;
|
|
179
|
+
|
|
180
|
+
template <bool E2E = false, int LEN, int SUM>
|
|
181
|
+
double IsPattern(const PatternView& view, const FixedPattern<LEN, SUM, false>& pattern, int spaceInPixel = 0,
|
|
182
|
+
double minQuietZone = 0, double moduleSizeRef = 0)
|
|
183
|
+
{
|
|
184
|
+
if constexpr (E2E) {
|
|
185
|
+
auto widths = BarAndSpaceSum<LEN, double>(view.data());
|
|
186
|
+
auto sums = pattern.sums();
|
|
187
|
+
BarAndSpace<double> modSize = {widths[0] / sums[0], widths[1] / sums[1]};
|
|
188
|
+
|
|
189
|
+
auto [m, M] = std::minmax(modSize[0], modSize[1]);
|
|
190
|
+
if (M > 4 * m) // make sure module sizes of bars and spaces are not too far away from each other
|
|
191
|
+
return 0;
|
|
192
|
+
|
|
193
|
+
if (minQuietZone && spaceInPixel < minQuietZone * modSize.space)
|
|
194
|
+
return 0;
|
|
195
|
+
|
|
196
|
+
const BarAndSpace<double> thr = {modSize[0] * .75 + .5, modSize[1] * .6 + .5};
|
|
197
|
+
|
|
198
|
+
for (int x = 0; x < LEN; ++x)
|
|
199
|
+
if (std::abs(view[x] - pattern[x] * modSize[x]) > thr[x])
|
|
200
|
+
return 0;
|
|
201
|
+
|
|
202
|
+
return (modSize[0] + modSize[1]) / 2;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
double width = view.sum(LEN);
|
|
206
|
+
if (SUM > LEN && width < SUM)
|
|
207
|
+
return 0;
|
|
208
|
+
|
|
209
|
+
const auto moduleSize = width / SUM;
|
|
210
|
+
|
|
211
|
+
if (minQuietZone && spaceInPixel < minQuietZone * moduleSize - 1)
|
|
212
|
+
return 0;
|
|
213
|
+
|
|
214
|
+
if (!moduleSizeRef)
|
|
215
|
+
moduleSizeRef = moduleSize;
|
|
216
|
+
|
|
217
|
+
// the offset of 0.5 is to make the code less sensitive to quantization errors for small (near 1) module sizes.
|
|
218
|
+
// TODO: review once we have upsampling in the binarizer in place.
|
|
219
|
+
const auto threshold = moduleSizeRef * (0.5 + E2E * 0.25) + 0.5;
|
|
220
|
+
|
|
221
|
+
for (int x = 0; x < LEN; ++x)
|
|
222
|
+
if (std::abs(view[x] - pattern[x] * moduleSizeRef) > threshold)
|
|
223
|
+
return 0;
|
|
224
|
+
|
|
225
|
+
return moduleSize;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
template <bool RELAXED_THRESHOLD = false, int N, int SUM>
|
|
229
|
+
double IsPattern(const PatternView& view, const FixedPattern<N, SUM, true>& pattern, int spaceInPixel = 0,
|
|
230
|
+
double minQuietZone = 0, double moduleSizeRef = 0)
|
|
231
|
+
{
|
|
232
|
+
// pattern contains the indices with the bars/spaces that need to be equally wide
|
|
233
|
+
double width = 0;
|
|
234
|
+
for (int x = 0; x < SUM; ++x)
|
|
235
|
+
width += view[pattern[x]];
|
|
236
|
+
|
|
237
|
+
const auto moduleSize = width / SUM;
|
|
238
|
+
|
|
239
|
+
if (minQuietZone && spaceInPixel < minQuietZone * moduleSize - 1)
|
|
240
|
+
return 0;
|
|
241
|
+
|
|
242
|
+
if (!moduleSizeRef)
|
|
243
|
+
moduleSizeRef = moduleSize;
|
|
244
|
+
|
|
245
|
+
// the offset of 0.5 is to make the code less sensitive to quantization errors for small (near 1) module sizes.
|
|
246
|
+
// TODO: review once we have upsampling in the binarizer in place.
|
|
247
|
+
const auto threshold = moduleSizeRef * (0.5 + RELAXED_THRESHOLD * 0.25) + 0.5;
|
|
248
|
+
|
|
249
|
+
for (int x = 0; x < SUM; ++x)
|
|
250
|
+
if (std::abs(view[pattern[x]] - moduleSizeRef) > threshold)
|
|
251
|
+
return 0;
|
|
252
|
+
|
|
253
|
+
return moduleSize;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
template <bool E2E = false, int N, int SUM, bool IS_SPARSE>
|
|
257
|
+
bool IsRightGuard(const PatternView& view, const FixedPattern<N, SUM, IS_SPARSE>& pattern, double minQuietZone,
|
|
258
|
+
double moduleSizeRef = 0)
|
|
259
|
+
{
|
|
260
|
+
assert(view.size() == pattern.size());
|
|
261
|
+
if (!view.isValid())
|
|
262
|
+
return false;
|
|
263
|
+
int spaceInPixel = view.isAtLastBar() ? std::numeric_limits<int>::max() : *view.end();
|
|
264
|
+
return IsPattern<E2E>(view, pattern, spaceInPixel, minQuietZone, moduleSizeRef) != 0;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
template<int LEN, typename Pred>
|
|
268
|
+
PatternView FindLeftGuard(const PatternView& view, int minSize, Pred isGuard)
|
|
269
|
+
{
|
|
270
|
+
if (view.size() < minSize)
|
|
271
|
+
return {};
|
|
272
|
+
|
|
273
|
+
auto window = view.subView(0, LEN);
|
|
274
|
+
if (window.isAtFirstBar() && isGuard(window, std::numeric_limits<int>::max()))
|
|
275
|
+
return window;
|
|
276
|
+
for (auto end = view.end() - minSize; window.data() < end; window.skipPair())
|
|
277
|
+
if (isGuard(window, window[-1]))
|
|
278
|
+
return window;
|
|
279
|
+
|
|
280
|
+
return {};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
template <bool E2E = false, int LEN, int SUM, bool IS_SPARSE>
|
|
284
|
+
PatternView FindLeftGuard(const PatternView& view, int minSize, const FixedPattern<LEN, SUM, IS_SPARSE>& pattern,
|
|
285
|
+
double minQuietZone)
|
|
286
|
+
{
|
|
287
|
+
return FindLeftGuard<LEN>(view, std::max(minSize, LEN),
|
|
288
|
+
[&pattern, minQuietZone](const PatternView& window, int spaceInPixel) {
|
|
289
|
+
return IsPattern<E2E>(window, pattern, spaceInPixel, minQuietZone);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
template <typename ARRAY, typename = std::enable_if_t<std::is_integral_v<typename ARRAY::value_type>>>
|
|
294
|
+
constexpr int ToInt(const ARRAY& a)
|
|
295
|
+
{
|
|
296
|
+
assert(Reduce(a) <= 32);
|
|
297
|
+
|
|
298
|
+
int pattern = 0;
|
|
299
|
+
for (int i = 0; i < Size(a); i++) {
|
|
300
|
+
if (a[i] < 0) // negative shift is undefined behavior
|
|
301
|
+
return -1;
|
|
302
|
+
pattern = (pattern << a[i]) | ~(0xffffffff << a[i]) * (~i & 1);
|
|
303
|
+
}
|
|
304
|
+
return pattern;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
template <size_t BITS, typename T, size_t N, typename = std::enable_if_t<std::is_integral_v<T>>>
|
|
308
|
+
constexpr uint32_t PackedPattern(const std::array<T, N>& np, T min = 0)
|
|
309
|
+
{
|
|
310
|
+
static_assert(BITS * N <= 32, "PackedArray: BITS * N must be <= 32");
|
|
311
|
+
uint32_t res = 0;
|
|
312
|
+
for (size_t i = 0; i < N; ++i) {
|
|
313
|
+
if (np[i] < min || np[i] - min >= (1 << BITS))
|
|
314
|
+
return -1;
|
|
315
|
+
AppendBits(res, uint32_t(np[i] - min), BITS);
|
|
316
|
+
}
|
|
317
|
+
return res;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
template <int LEN, int RET_LEN>
|
|
321
|
+
constexpr std::array<int, RET_LEN> NormalizedE2EPattern(const PatternView& view, int mods, bool reverse = false)
|
|
322
|
+
{
|
|
323
|
+
double moduleSize = static_cast<double>(view.sum(LEN)) / mods;
|
|
324
|
+
std::array<int, RET_LEN> e2e;
|
|
325
|
+
|
|
326
|
+
for (int i = 0; i < RET_LEN; i++) {
|
|
327
|
+
int i_v = reverse ? LEN - 2 - i : i;
|
|
328
|
+
double v = (view[i_v] + view[i_v + 1]) / moduleSize;
|
|
329
|
+
e2e[i] = int(v + .5);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return e2e;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
template <int LEN, int SUM, int RET_LEN = LEN - 2>
|
|
336
|
+
constexpr std::array<int, RET_LEN> NormalizedE2EPattern(const PatternView& view)
|
|
337
|
+
{
|
|
338
|
+
return NormalizedE2EPattern<LEN, RET_LEN>(view, SUM);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
template <int LEN, int SUM, size_t N>
|
|
342
|
+
constexpr auto PatternsToE2EInts(const std::array<FixedPattern<LEN, SUM>, N>& in)
|
|
343
|
+
{
|
|
344
|
+
std::array<int, N> res{};
|
|
345
|
+
for (size_t i = 0; i < N; ++i)
|
|
346
|
+
res[i] = ToInt(NormalizedE2EPattern<LEN, SUM>(in[i]));
|
|
347
|
+
return res;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
template <int LEN, int SUM>
|
|
351
|
+
constexpr std::array<int, LEN> NormalizedPattern(const PatternView& view)
|
|
352
|
+
{
|
|
353
|
+
double moduleSize = static_cast<double>(view.sum(LEN)) / SUM;
|
|
354
|
+
#if 1
|
|
355
|
+
int err = SUM;
|
|
356
|
+
std::array<int, LEN> is;
|
|
357
|
+
std::array<double, LEN> rs;
|
|
358
|
+
for (int i = 0; i < LEN; i++) {
|
|
359
|
+
double v = view[i] / moduleSize;
|
|
360
|
+
is[i] = int(v + .5);
|
|
361
|
+
rs[i] = v - is[i];
|
|
362
|
+
err -= is[i];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (std::abs(err) > 1)
|
|
366
|
+
return {};
|
|
367
|
+
|
|
368
|
+
if (err) {
|
|
369
|
+
auto mi = err > 0 ? std::ranges::max_element(rs) - rs.begin()
|
|
370
|
+
: std::ranges::min_element(rs) - rs.begin();
|
|
371
|
+
is[mi] += err;
|
|
372
|
+
rs[mi] -= err;
|
|
373
|
+
}
|
|
374
|
+
#else
|
|
375
|
+
std::array<int, LEN> is, e2e;
|
|
376
|
+
int min_v = view[0], min_i = 0;
|
|
377
|
+
|
|
378
|
+
for (int i = 1; i < LEN; i++) {
|
|
379
|
+
double v = (view[i - 1] + view[i]) / moduleSize;
|
|
380
|
+
e2e[i] = int(v + .5);
|
|
381
|
+
if (view[i] < min_v) {
|
|
382
|
+
min_v = view[i];
|
|
383
|
+
min_i = i;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
is[min_i] = 1;
|
|
388
|
+
for (int i = min_i + 1; i < LEN; ++i)
|
|
389
|
+
is[i] = e2e[i] - is[i - 1];
|
|
390
|
+
for (int i = min_i - 1; i >= 0; --i)
|
|
391
|
+
is[i] = e2e[i + 1] - is[i + 1];
|
|
392
|
+
#endif
|
|
393
|
+
return is;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
template<typename I>
|
|
397
|
+
void GetPatternRow(Range<I> b_row, PatternRow& p_row)
|
|
398
|
+
{
|
|
399
|
+
// TODO: if reactivating the bit-packed array (!ZX_FAST_BIT_STORAGE) should be of interest then the following code could be
|
|
400
|
+
// considerably speed up by using a specialized variant along the lines of the old BitArray::getNextSetTo() function that
|
|
401
|
+
// was removed between 1.4 and 2.0.
|
|
402
|
+
|
|
403
|
+
#if 0
|
|
404
|
+
p_row.reserve(64);
|
|
405
|
+
p_row.clear();
|
|
406
|
+
|
|
407
|
+
auto lastPos = b_row.begin();
|
|
408
|
+
if (*lastPos)
|
|
409
|
+
p_row.push_back(0); // first value is number of white pixels, here 0
|
|
410
|
+
|
|
411
|
+
for (auto p = b_row.begin() + 1; p != b_row.end(); ++p)
|
|
412
|
+
if (bool(*p) != bool(*lastPos))
|
|
413
|
+
p_row.push_back(p - std::exchange(lastPos, p));
|
|
414
|
+
|
|
415
|
+
p_row.push_back(b_row.end() - lastPos);
|
|
416
|
+
|
|
417
|
+
if (*lastPos)
|
|
418
|
+
p_row.push_back(0); // last value is number of white pixels, here 0
|
|
419
|
+
#else
|
|
420
|
+
p_row.resize(b_row.size() + 2);
|
|
421
|
+
std::fill(p_row.begin(), p_row.end(), 0);
|
|
422
|
+
|
|
423
|
+
auto bitPos = b_row.begin();
|
|
424
|
+
const auto bitPosEnd = b_row.end();
|
|
425
|
+
auto intPos = p_row.data();
|
|
426
|
+
|
|
427
|
+
if (*bitPos)
|
|
428
|
+
intPos++; // first value is number of white pixels, here 0
|
|
429
|
+
|
|
430
|
+
// The following code has been observed to cause a speedup of up to 30% on large images on an AVX cpu
|
|
431
|
+
// and on an a Google Pixel 3 Android phone. Your mileage may vary.
|
|
432
|
+
if constexpr (std::contiguous_iterator<I> && sizeof(std::remove_cv_t<std::iter_value_t<I>>) == 1) {
|
|
433
|
+
using simd_t = uint64_t;
|
|
434
|
+
const auto* const bitPtrBegin = std::to_address(bitPos);
|
|
435
|
+
const auto* const bitPtrEnd = std::to_address(bitPosEnd);
|
|
436
|
+
auto* bitPtr = bitPtrBegin;
|
|
437
|
+
|
|
438
|
+
while (bitPtr < bitPtrEnd - sizeof(simd_t)) {
|
|
439
|
+
auto asSimd0 = LoadU<simd_t>(bitPtr);
|
|
440
|
+
auto asSimd1 = LoadU<simd_t>(bitPtr + 1);
|
|
441
|
+
auto z = asSimd0 ^ asSimd1;
|
|
442
|
+
if (z) {
|
|
443
|
+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
444
|
+
int step = std::countr_zero(z) / 8 + 1;
|
|
445
|
+
#else
|
|
446
|
+
int step = std::countl_zero(z) / 8 + 1;
|
|
447
|
+
#endif
|
|
448
|
+
(*intPos++) += step;
|
|
449
|
+
bitPtr += step;
|
|
450
|
+
} else {
|
|
451
|
+
(*intPos) += sizeof(simd_t);
|
|
452
|
+
bitPtr += sizeof(simd_t);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
bitPos += bitPtr - bitPtrBegin;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
while (++bitPos != bitPosEnd) {
|
|
460
|
+
++(*intPos);
|
|
461
|
+
intPos += bitPos[0] != bitPos[-1];
|
|
462
|
+
}
|
|
463
|
+
++(*intPos);
|
|
464
|
+
|
|
465
|
+
if (bitPos[-1])
|
|
466
|
+
intPos++;
|
|
467
|
+
|
|
468
|
+
p_row.resize(intPos - p_row.data() + 1);
|
|
469
|
+
#endif
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
} // ZXing
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
* Copyright 2020 Axel Waggershauser
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
|
|
8
|
+
#include "PerspectiveTransform.h"
|
|
9
|
+
|
|
10
|
+
#include <array>
|
|
11
|
+
|
|
12
|
+
namespace ZXing {
|
|
13
|
+
|
|
14
|
+
PerspectiveTransform PerspectiveTransform::inverse() const
|
|
15
|
+
{
|
|
16
|
+
// Here, the adjoint serves as the inverse:
|
|
17
|
+
// Adjoint is the transpose of the cofactor matrix:
|
|
18
|
+
return {
|
|
19
|
+
a22 * a33 - a23 * a32,
|
|
20
|
+
a23 * a31 - a21 * a33,
|
|
21
|
+
a21 * a32 - a22 * a31,
|
|
22
|
+
a13 * a32 - a12 * a33,
|
|
23
|
+
a11 * a33 - a13 * a31,
|
|
24
|
+
a12 * a31 - a11 * a32,
|
|
25
|
+
a12 * a23 - a13 * a22,
|
|
26
|
+
a13 * a21 - a11 * a23,
|
|
27
|
+
a11 * a22 - a12 * a21
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
PerspectiveTransform PerspectiveTransform::times(const PerspectiveTransform& other) const
|
|
32
|
+
{
|
|
33
|
+
return {
|
|
34
|
+
a11 * other.a11 + a21 * other.a12 + a31 * other.a13,
|
|
35
|
+
a11 * other.a21 + a21 * other.a22 + a31 * other.a23,
|
|
36
|
+
a11 * other.a31 + a21 * other.a32 + a31 * other.a33,
|
|
37
|
+
a12 * other.a11 + a22 * other.a12 + a32 * other.a13,
|
|
38
|
+
a12 * other.a21 + a22 * other.a22 + a32 * other.a23,
|
|
39
|
+
a12 * other.a31 + a22 * other.a32 + a32 * other.a33,
|
|
40
|
+
a13 * other.a11 + a23 * other.a12 + a33 * other.a13,
|
|
41
|
+
a13 * other.a21 + a23 * other.a22 + a33 * other.a23,
|
|
42
|
+
a13 * other.a31 + a23 * other.a32 + a33 * other.a33
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
PerspectiveTransform PerspectiveTransform::UnitSquareTo(const QuadrilateralF& q)
|
|
47
|
+
{
|
|
48
|
+
auto [x0, y0, x1, y1, x2, y2, x3, y3] = reinterpret_cast<const std::array<PointF::value_t, 8>&>(q);
|
|
49
|
+
|
|
50
|
+
auto d3 = q[0] - q[1] + q[2] - q[3];
|
|
51
|
+
if (d3 == PointF(0, 0)) {
|
|
52
|
+
// Affine
|
|
53
|
+
return {x1 - x0, x2 - x1, x0,
|
|
54
|
+
y1 - y0, y2 - y1, y0,
|
|
55
|
+
0.0f, 0.0f, 1.0f};
|
|
56
|
+
} else {
|
|
57
|
+
auto d1 = q[1] - q[2];
|
|
58
|
+
auto d2 = q[3] - q[2];
|
|
59
|
+
auto denominator = cross(d1, d2);
|
|
60
|
+
auto a13 = cross(d3, d2) / denominator;
|
|
61
|
+
auto a23 = cross(d1, d3) / denominator;
|
|
62
|
+
return {x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0,
|
|
63
|
+
y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0,
|
|
64
|
+
a13, a23, 1.0f};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
PerspectiveTransform::PerspectiveTransform(const QuadrilateralF& src, const QuadrilateralF& dst)
|
|
69
|
+
{
|
|
70
|
+
if (!IsConvex(src) || !IsConvex(dst))
|
|
71
|
+
return;
|
|
72
|
+
*this = UnitSquareTo(dst).times(UnitSquareTo(src).inverse());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
PointF PerspectiveTransform::operator()(PointF p) const
|
|
76
|
+
{
|
|
77
|
+
auto denominator = a13 * p.x + a23 * p.y + a33;
|
|
78
|
+
return {(a11 * p.x + a21 * p.y + a31) / denominator, (a12 * p.x + a22 * p.y + a32) / denominator};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
} // ZXing
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2016 Nu-book Inc.
|
|
3
|
+
* Copyright 2016 ZXing authors
|
|
4
|
+
* Copyright 2020 Axel Waggershauser
|
|
5
|
+
*/
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "Point.h"
|
|
11
|
+
#include "Quadrilateral.h"
|
|
12
|
+
|
|
13
|
+
namespace ZXing {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This class implements a perspective transform in two dimensions. Given four source and four
|
|
17
|
+
* destination points, it will compute the transformation implied between them. The code is based
|
|
18
|
+
* directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.
|
|
19
|
+
*
|
|
20
|
+
* See also e.g. https://math.stackexchange.com/a/339033
|
|
21
|
+
*/
|
|
22
|
+
class PerspectiveTransform
|
|
23
|
+
{
|
|
24
|
+
using value_t = PointF::value_t;
|
|
25
|
+
value_t a11, a12, a13, a21, a22, a23, a31, a32, a33 = NAN;
|
|
26
|
+
|
|
27
|
+
PerspectiveTransform(value_t a11, value_t a21, value_t a31, value_t a12, value_t a22, value_t a32, value_t a13,
|
|
28
|
+
value_t a23, value_t a33)
|
|
29
|
+
: a11(a11), a12(a12), a13(a13), a21(a21), a22(a22), a23(a23), a31(a31), a32(a32), a33(a33)
|
|
30
|
+
{}
|
|
31
|
+
|
|
32
|
+
PerspectiveTransform inverse() const;
|
|
33
|
+
PerspectiveTransform times(const PerspectiveTransform& other) const;
|
|
34
|
+
|
|
35
|
+
static PerspectiveTransform UnitSquareTo(const QuadrilateralF& q);
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
PerspectiveTransform() = default;
|
|
39
|
+
PerspectiveTransform(const QuadrilateralF& src, const QuadrilateralF& dst);
|
|
40
|
+
|
|
41
|
+
/// Project from the destination space (grid of modules) into the image space (bit matrix)
|
|
42
|
+
PointF operator()(PointF p) const;
|
|
43
|
+
|
|
44
|
+
bool isValid() const { return !std::isnan(a33); }
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // ZXing
|