zxing_cpp_no_cmake 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.gitmodules +0 -0
- data/CHANGELOG.rdoc +6 -0
- data/Gemfile +3 -0
- data/Manifest.txt +375 -0
- data/README.rdoc +141 -0
- data/Rakefile +28 -0
- data/bin/zxd +87 -0
- data/bin/zxe +53 -0
- data/ext/zxing/extconf.rb +20 -0
- data/ext/zxing/zxing-cpp/.gitignore +2 -0
- data/ext/zxing/zxing-cpp/AUTHORS +115 -0
- data/ext/zxing/zxing-cpp/CMakeLists.txt +89 -0
- data/ext/zxing/zxing-cpp/COPYING +201 -0
- data/ext/zxing/zxing-cpp/NOTICE +65 -0
- data/ext/zxing/zxing-cpp/README.md +45 -0
- data/ext/zxing/zxing-cpp/build/CMakeCache.txt +382 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CMakeCCompiler.cmake +76 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CMakeCXXCompiler.cmake +79 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CMakeSystem.cmake +15 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CompilerIdC/CMakeCCompilerId.c +665 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CompilerIdC/a.out +0 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CompilerIdCXX/CMakeCXXCompilerId.cpp +644 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/3.15.4/CompilerIdCXX/a.out +0 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/CMakeOutput.log +447 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/Makefile.cmake +125 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/Makefile2 +177 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/TargetDirectories.txt +9 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/cmake.check_cache +1 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/CXX.includecache +1892 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/DependInfo.cmake +120 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/build.make +1584 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/cmake_clean.cmake +109 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/cmake_clean_target.cmake +3 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/depend.internal +1465 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/depend.make +1465 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/flags.make +10 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/link.txt +2 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/libzxing.dir/progress.make +102 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/progress.marks +1 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/CXX.includecache +344 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/DependInfo.cmake +33 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/build.make +266 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/cmake_clean.cmake +21 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/depend.internal +103 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/depend.make +103 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/flags.make +10 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/link.txt +1 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/testrunner.dir/progress.make +14 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/CXX.includecache +378 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/DependInfo.cmake +25 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/build.make +145 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/cmake_clean.cmake +13 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/depend.internal +53 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/depend.make +53 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/flags.make +10 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/link.txt +1 -0
- data/ext/zxing/zxing-cpp/build/CMakeFiles/zxing.dir/progress.make +6 -0
- data/ext/zxing/zxing-cpp/build/Makefile +3706 -0
- data/ext/zxing/zxing-cpp/build/cmake_install.cmake +73 -0
- data/ext/zxing/zxing-cpp/build/libzxing.a +0 -0
- data/ext/zxing/zxing-cpp/build/testrunner +0 -0
- data/ext/zxing/zxing-cpp/build/zxing +0 -0
- data/ext/zxing/zxing-cpp/cli/src/ImageReaderSource.cpp +113 -0
- data/ext/zxing/zxing-cpp/cli/src/ImageReaderSource.h +40 -0
- data/ext/zxing/zxing-cpp/cli/src/jpgd.cpp +3174 -0
- data/ext/zxing/zxing-cpp/cli/src/jpgd.h +319 -0
- data/ext/zxing/zxing-cpp/cli/src/lodepng.cpp +6261 -0
- data/ext/zxing/zxing-cpp/cli/src/lodepng.h +1695 -0
- data/ext/zxing/zxing-cpp/cli/src/main.cpp +297 -0
- data/ext/zxing/zxing-cpp/cmake/FindCPPUNIT.cmake +54 -0
- data/ext/zxing/zxing-cpp/cmake/FindIconv.cmake +57 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/.gitignore +6 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigInteger.cc +405 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigInteger.hh +215 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerAlgorithms.cc +70 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerAlgorithms.hh +25 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerLibrary.hh +8 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerUtils.cc +50 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerUtils.hh +72 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsigned.cc +697 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsigned.hh +418 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsignedInABase.cc +125 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsignedInABase.hh +122 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/ChangeLog +146 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/Makefile +73 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/NumberlikeArray.hh +177 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/README +71 -0
- data/ext/zxing/zxing-cpp/core/src/win32/zxing/iconv.h +14 -0
- data/ext/zxing/zxing-cpp/core/src/win32/zxing/stdint.h +247 -0
- data/ext/zxing/zxing-cpp/core/src/win32/zxing/win_iconv.c +2035 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BarcodeFormat.cpp +40 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BarcodeFormat.h +60 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Binarizer.cpp +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Binarizer.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BinaryBitmap.cpp +70 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BinaryBitmap.h +56 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ChecksumException.cpp +28 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ChecksumException.h +34 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/DecodeHints.cpp +142 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/DecodeHints.h +85 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Exception.cpp +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Exception.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/FormatException.cpp +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/FormatException.h +37 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/IllegalStateException.h +35 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/InvertedLuminanceSource.cpp +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/InvertedLuminanceSource.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/LuminanceSource.cpp +86 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/LuminanceSource.h +59 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/MultiFormatReader.cpp +124 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/MultiFormatReader.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/NotFoundException.h +35 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Reader.cpp +31 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Reader.h +40 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ReaderException.h +37 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Result.cpp +61 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Result.h +55 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultIO.cpp +34 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPoint.cpp +108 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPoint.h +55 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPointCallback.cpp +26 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPointCallback.h +39 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ZXing.h +133 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecDetectorResult.cpp +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecDetectorResult.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecReader.cpp +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecReader.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/decoder/Decoder.cpp +489 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/decoder/Decoder.h +69 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/detector/Detector.cpp +548 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/detector/Detector.h +92 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Array.h +170 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitArray.cpp +155 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitArray.h +81 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitArrayIO.cpp +31 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitMatrix.cpp +143 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitMatrix.h +91 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitSource.cpp +76 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitSource.h +74 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/CharacterSetECI.cpp +105 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/CharacterSetECI.h +53 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Counted.h +140 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DecoderResult.cpp +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DecoderResult.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DetectorResult.cpp +39 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DetectorResult.h +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GlobalHistogramBinarizer.cpp +212 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GlobalHistogramBinarizer.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleLuminanceSource.cpp +80 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleLuminanceSource.h +53 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleRotatedLuminanceSource.cpp +81 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleRotatedLuminanceSource.h +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GridSampler.cpp +122 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GridSampler.h +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/HybridBinarizer.cpp +226 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/HybridBinarizer.h +67 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/IllegalArgumentException.cpp +27 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/IllegalArgumentException.h +36 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/PerspectiveTransform.cpp +107 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/PerspectiveTransform.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Point.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Str.cpp +61 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Str.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/StringUtils.cpp +198 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/StringUtils.h +52 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/JavaMath.h +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MathUtils.h +57 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MonochromeRectangleDetector.cpp +175 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MonochromeRectangleDetector.h +62 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp +330 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/WhiteRectangleDetector.h +59 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp +150 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGF.h +73 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp +218 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h +56 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp +174 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonException.cpp +30 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonException.h +33 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/DataMatrixReader.h +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/Version.cpp +199 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/Version.h +87 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.cpp +361 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.h +59 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DataBlock.cpp +113 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DataBlock.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DecodedBitStreamParser.cpp +415 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DecodedBitStreamParser.h +104 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/Decoder.cpp +93 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/Decoder.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/CornerPoint.cpp +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/CornerPoint.h +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/Detector.cpp +447 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/Detector.h +94 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/DetectorException.cpp +23 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/DetectorException.h +23 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/ByQuadrantReader.cpp +75 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/ByQuadrantReader.h +42 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp +137 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/GenericMultipleBarcodeReader.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/MultipleBarcodeReader.cpp +29 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/MultipleBarcodeReader.h +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp +58 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/QRCodeMultiReader.h +36 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiDetector.cpp +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiDetector.h +37 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +236 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/CodaBarReader.cpp +340 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/CodaBarReader.h +57 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code128Reader.cpp +497 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code128Reader.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code39Reader.cpp +329 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code39Reader.h +63 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code93Reader.cpp +303 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code93Reader.h +58 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN13Reader.cpp +85 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN13Reader.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN8Reader.cpp +65 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN8Reader.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/ITFReader.cpp +337 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/ITFReader.h +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp +96 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatOneDReader.h +38 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp +110 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatUPCEANReader.h +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDReader.cpp +228 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDReader.h +81 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDResultPoint.cpp +28 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDResultPoint.h +35 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCAReader.cpp +70 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCAReader.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEANReader.cpp +309 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEANReader.h +88 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEReader.cpp +146 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEReader.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/PDF417Reader.cpp +170 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/PDF417Reader.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/BitMatrixParser.cpp +997 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/BitMatrixParser.h +84 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/DecodedBitStreamParser.cpp +563 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/DecodedBitStreamParser.h +84 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/Decoder.cpp +118 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/Decoder.h +62 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ErrorCorrection.cpp +214 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ErrorCorrection.h +71 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusGF.cpp +120 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusGF.h +72 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusPoly.cpp +284 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusPoly.h +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/Detector.cpp +665 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/Detector.h +106 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/LinesSampler.cpp +715 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/LinesSampler.h +122 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.cpp +65 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.h +52 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/FormatInformation.cpp +117 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/FormatInformation.h +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/QRCodeReader.cpp +52 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/QRCodeReader.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/Version.cpp +560 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/Version.h +85 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp +183 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.h +56 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataBlock.cpp +118 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataBlock.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataMask.cpp +159 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataMask.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp +428 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.h +72 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Decoder.cpp +107 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Decoder.h +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Mode.cpp +90 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Mode.h +57 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPattern.cpp +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPattern.h +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.cpp +208 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/Detector.cpp +315 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/Detector.h +69 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPattern.cpp +69 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPattern.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp +559 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h +76 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternInfo.cpp +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternInfo.h +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/TestRunner.cpp +30 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitArrayTest.cpp +216 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitArrayTest.h +61 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitMatrixTest.cpp +106 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitMatrixTest.h +55 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitSourceTest.cpp +49 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitSourceTest.h +42 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/CountedTest.cpp +58 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/CountedTest.h +46 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/PerspectiveTransformTest.cpp +69 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/PerspectiveTransformTest.h +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.cpp +129 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.h +62 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/ErrorCorrectionLevelTest.cpp +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/ErrorCorrectionLevelTest.h +45 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/FormatInformationTest.cpp +88 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/FormatInformationTest.h +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/VersionTest.cpp +88 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/VersionTest.h +49 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/DataMaskTest.cpp +132 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/DataMaskTest.h +91 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/ModeTest.cpp +52 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/ModeTest.h +47 -0
- data/ext/zxing/zxing.cc +224 -0
- data/lib/zxing.rb +50 -0
- data/lib/zxing/.gitignore +2 -0
- data/lib/zxing/aztec.rb +5 -0
- data/lib/zxing/aztec/aztec_reader.rb +14 -0
- data/lib/zxing/bad_image_exception.rb +4 -0
- data/lib/zxing/binarizer.rb +8 -0
- data/lib/zxing/binary_bitmap.rb +15 -0
- data/lib/zxing/checksum_exception.rb +4 -0
- data/lib/zxing/common.rb +7 -0
- data/lib/zxing/common/bit_matrix.rb +9 -0
- data/lib/zxing/common/hybrid_binarizer.rb +17 -0
- data/lib/zxing/common/illegal_argument_exception.rb +4 -0
- data/lib/zxing/datamatrix.rb +5 -0
- data/lib/zxing/datamatrix/data_matrix_reader.rb +14 -0
- data/lib/zxing/decodable.rb +11 -0
- data/lib/zxing/exception.rb +4 -0
- data/lib/zxing/ffi.rb +20 -0
- data/lib/zxing/ffi/aztec.rb +6 -0
- data/lib/zxing/ffi/aztec/aztec_reader.rb +9 -0
- data/lib/zxing/ffi/binarizer.rb +25 -0
- data/lib/zxing/ffi/binary_bitmap.rb +15 -0
- data/lib/zxing/ffi/common.rb +8 -0
- data/lib/zxing/ffi/common/bit_matrix.rb +12 -0
- data/lib/zxing/ffi/common/greyscale_luminance_source.rb +30 -0
- data/lib/zxing/ffi/common/hybrid_binarizer.rb +10 -0
- data/lib/zxing/ffi/datamatrix.rb +6 -0
- data/lib/zxing/ffi/datamatrix/data_matrix_reader.rb +9 -0
- data/lib/zxing/ffi/library.rb +102 -0
- data/lib/zxing/ffi/luminance_source.rb +18 -0
- data/lib/zxing/ffi/multi_format_reader.rb +9 -0
- data/lib/zxing/ffi/oned.rb +6 -0
- data/lib/zxing/ffi/oned/code_39_reader.rb +10 -0
- data/lib/zxing/ffi/qrcode.rb +8 -0
- data/lib/zxing/ffi/qrcode/decoder.rb +10 -0
- data/lib/zxing/ffi/qrcode/detector.rb +10 -0
- data/lib/zxing/ffi/reader.rb +58 -0
- data/lib/zxing/ffi/result.rb +23 -0
- data/lib/zxing/format_exception.rb +4 -0
- data/lib/zxing/illegal_argument_exception.rb +4 -0
- data/lib/zxing/image.rb +15 -0
- data/lib/zxing/luminance_source.rb +18 -0
- data/lib/zxing/multi_format_reader.rb +11 -0
- data/lib/zxing/not_found_exception.rb +4 -0
- data/lib/zxing/oned.rb +5 -0
- data/lib/zxing/oned/code_39_reader.rb +15 -0
- data/lib/zxing/qrcode.rb +8 -0
- data/lib/zxing/qrcode/decoder.rb +14 -0
- data/lib/zxing/qrcode/detector.rb +14 -0
- data/lib/zxing/qrcode/encoder.rb +8 -0
- data/lib/zxing/qrcode/encoder/byte_matrix.rb +18 -0
- data/lib/zxing/qrcode/encoder/encoder.rb +9 -0
- data/lib/zxing/qrcode/encoder/qrcode.rb +18 -0
- data/lib/zxing/reader.rb +8 -0
- data/lib/zxing/reader_exception.rb +4 -0
- data/lib/zxing/reed_solomon_exception.rb +2 -0
- data/lib/zxing/result.rb +18 -0
- data/lib/zxing/rmagick.rb +5 -0
- data/lib/zxing/rmagick/image.rb +109 -0
- data/lib/zxing/version.rb +33 -0
- data/zxing_cpp.gemspec +36 -0
- metadata +515 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
#ifndef __DECODED_BIT_STREAM_PARSER_DM_H__
|
2
|
+
#define __DECODED_BIT_STREAM_PARSER_DM_H__
|
3
|
+
|
4
|
+
/*
|
5
|
+
* DecodedBitStreamParser.h
|
6
|
+
* zxing
|
7
|
+
*
|
8
|
+
* Created by Luiz Silva on 09/02/2010.
|
9
|
+
* Copyright 2010 ZXing authors All rights reserved.
|
10
|
+
*
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
+
* you may not use this file except in compliance with the License.
|
13
|
+
* You may obtain a copy of the License at
|
14
|
+
*
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
*
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
+
* See the License for the specific language governing permissions and
|
21
|
+
* limitations under the License.
|
22
|
+
*/
|
23
|
+
|
24
|
+
#include <string>
|
25
|
+
#include <sstream>
|
26
|
+
#include <zxing/common/Array.h>
|
27
|
+
#include <zxing/common/BitSource.h>
|
28
|
+
#include <zxing/common/Counted.h>
|
29
|
+
#include <zxing/common/DecoderResult.h>
|
30
|
+
|
31
|
+
|
32
|
+
namespace zxing {
|
33
|
+
namespace datamatrix {
|
34
|
+
|
35
|
+
class DecodedBitStreamParser {
|
36
|
+
private:
|
37
|
+
static const int PAD_ENCODE = 0; // Not really an encoding
|
38
|
+
static const int ASCII_ENCODE = 1;
|
39
|
+
static const int C40_ENCODE = 2;
|
40
|
+
static const int TEXT_ENCODE = 3;
|
41
|
+
static const int ANSIX12_ENCODE = 4;
|
42
|
+
static const int EDIFACT_ENCODE = 5;
|
43
|
+
static const int BASE256_ENCODE = 6;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* See ISO 16022:2006, Annex C Table C.1
|
47
|
+
* The C40 Basic Character Set (*'s used for placeholders for the shift values)
|
48
|
+
*/
|
49
|
+
static const char C40_BASIC_SET_CHARS[];
|
50
|
+
|
51
|
+
static const char C40_SHIFT2_SET_CHARS[];
|
52
|
+
/**
|
53
|
+
* See ISO 16022:2006, Annex C Table C.2
|
54
|
+
* The Text Basic Character Set (*'s used for placeholders for the shift values)
|
55
|
+
*/
|
56
|
+
static const char TEXT_BASIC_SET_CHARS[];
|
57
|
+
|
58
|
+
static const char TEXT_SHIFT3_SET_CHARS[];
|
59
|
+
/**
|
60
|
+
* See ISO 16022:2006, 5.2.3 and Annex C, Table C.2
|
61
|
+
*/
|
62
|
+
int decodeAsciiSegment(Ref<BitSource> bits, std::ostringstream &result, std::ostringstream &resultTrailer);
|
63
|
+
/**
|
64
|
+
* See ISO 16022:2006, 5.2.5 and Annex C, Table C.1
|
65
|
+
*/
|
66
|
+
void decodeC40Segment(Ref<BitSource> bits, std::ostringstream &result);
|
67
|
+
/**
|
68
|
+
* See ISO 16022:2006, 5.2.6 and Annex C, Table C.2
|
69
|
+
*/
|
70
|
+
void decodeTextSegment(Ref<BitSource> bits, std::ostringstream &result);
|
71
|
+
/**
|
72
|
+
* See ISO 16022:2006, 5.2.7
|
73
|
+
*/
|
74
|
+
void decodeAnsiX12Segment(Ref<BitSource> bits, std::ostringstream &result);
|
75
|
+
/**
|
76
|
+
* See ISO 16022:2006, 5.2.8 and Annex C Table C.3
|
77
|
+
*/
|
78
|
+
void decodeEdifactSegment(Ref<BitSource> bits, std::ostringstream &result);
|
79
|
+
/**
|
80
|
+
* See ISO 16022:2006, 5.2.9 and Annex B, B.2
|
81
|
+
*/
|
82
|
+
void decodeBase256Segment(Ref<BitSource> bits, std::ostringstream &result, std::vector<char> byteSegments);
|
83
|
+
|
84
|
+
void parseTwoBytes(int firstByte, int secondByte, int* result);
|
85
|
+
/**
|
86
|
+
* See ISO 16022:2006, Annex B, B.2
|
87
|
+
*/
|
88
|
+
char unrandomize255State(int randomizedBase256Codeword,
|
89
|
+
int base256CodewordPosition) {
|
90
|
+
int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1;
|
91
|
+
int tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
|
92
|
+
return (char) (tempVariable >= 0 ? tempVariable : (tempVariable + 256));
|
93
|
+
};
|
94
|
+
void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src);
|
95
|
+
|
96
|
+
public:
|
97
|
+
DecodedBitStreamParser() { };
|
98
|
+
Ref<DecoderResult> decode(ArrayRef<char> bytes);
|
99
|
+
};
|
100
|
+
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
#endif // __DECODED_BIT_STREAM_PARSER_DM_H__
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/*
|
2
|
+
* Decoder.cpp
|
3
|
+
* zxing
|
4
|
+
*
|
5
|
+
* Created by Luiz Silva on 09/02/2010.
|
6
|
+
* Copyright 2010 ZXing authors All rights reserved.
|
7
|
+
*
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
* you may not use this file except in compliance with the License.
|
10
|
+
* You may obtain a copy of the License at
|
11
|
+
*
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
*
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
* See the License for the specific language governing permissions and
|
18
|
+
* limitations under the License.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <zxing/datamatrix/decoder/Decoder.h>
|
22
|
+
#include <zxing/datamatrix/decoder/BitMatrixParser.h>
|
23
|
+
#include <zxing/datamatrix/decoder/DataBlock.h>
|
24
|
+
#include <zxing/datamatrix/decoder/DecodedBitStreamParser.h>
|
25
|
+
#include <zxing/datamatrix/Version.h>
|
26
|
+
#include <zxing/ReaderException.h>
|
27
|
+
#include <zxing/ChecksumException.h>
|
28
|
+
#include <zxing/common/reedsolomon/ReedSolomonException.h>
|
29
|
+
|
30
|
+
using zxing::Ref;
|
31
|
+
using zxing::DecoderResult;
|
32
|
+
using zxing::datamatrix::Decoder;
|
33
|
+
|
34
|
+
// VC++
|
35
|
+
using zxing::ArrayRef;
|
36
|
+
using zxing::BitMatrix;
|
37
|
+
|
38
|
+
Decoder::Decoder() : rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) {}
|
39
|
+
|
40
|
+
void Decoder::correctErrors(ArrayRef<char> codewordBytes, int numDataCodewords) {
|
41
|
+
int numCodewords = codewordBytes->size();
|
42
|
+
ArrayRef<int> codewordInts(numCodewords);
|
43
|
+
for (int i = 0; i < numCodewords; i++) {
|
44
|
+
codewordInts[i] = codewordBytes[i] & 0xff;
|
45
|
+
}
|
46
|
+
int numECCodewords = numCodewords - numDataCodewords;
|
47
|
+
try {
|
48
|
+
rsDecoder_.decode(codewordInts, numECCodewords);
|
49
|
+
} catch (ReedSolomonException const& ignored) {
|
50
|
+
(void)ignored;
|
51
|
+
throw ChecksumException();
|
52
|
+
}
|
53
|
+
// Copy back into array of bytes -- only need to worry about the bytes that were data
|
54
|
+
// We don't care about errors in the error-correction codewords
|
55
|
+
for (int i = 0; i < numDataCodewords; i++) {
|
56
|
+
codewordBytes[i] = (char)codewordInts[i];
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
|
61
|
+
// Construct a parser and read version, error-correction level
|
62
|
+
BitMatrixParser parser(bits);
|
63
|
+
Version *version = parser.readVersion(bits);
|
64
|
+
|
65
|
+
// Read codewords
|
66
|
+
ArrayRef<char> codewords(parser.readCodewords());
|
67
|
+
// Separate into data blocks
|
68
|
+
std::vector<Ref<DataBlock> > dataBlocks = DataBlock::getDataBlocks(codewords, version);
|
69
|
+
|
70
|
+
int dataBlocksCount = dataBlocks.size();
|
71
|
+
|
72
|
+
// Count total number of data bytes
|
73
|
+
int totalBytes = 0;
|
74
|
+
for (int i = 0; i < dataBlocksCount; i++) {
|
75
|
+
totalBytes += dataBlocks[i]->getNumDataCodewords();
|
76
|
+
}
|
77
|
+
ArrayRef<char> resultBytes(totalBytes);
|
78
|
+
|
79
|
+
// Error-correct and copy data blocks together into a stream of bytes
|
80
|
+
for (int j = 0; j < dataBlocksCount; j++) {
|
81
|
+
Ref<DataBlock> dataBlock(dataBlocks[j]);
|
82
|
+
ArrayRef<char> codewordBytes = dataBlock->getCodewords();
|
83
|
+
int numDataCodewords = dataBlock->getNumDataCodewords();
|
84
|
+
correctErrors(codewordBytes, numDataCodewords);
|
85
|
+
for (int i = 0; i < numDataCodewords; i++) {
|
86
|
+
// De-interlace data blocks.
|
87
|
+
resultBytes[i * dataBlocksCount + j] = codewordBytes[i];
|
88
|
+
}
|
89
|
+
}
|
90
|
+
// Decode the contents of that stream of bytes
|
91
|
+
DecodedBitStreamParser decodedBSParser;
|
92
|
+
return Ref<DecoderResult> (decodedBSParser.decode(resultBytes));
|
93
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#ifndef __DECODER_DM_H__
|
2
|
+
#define __DECODER_DM_H__
|
3
|
+
|
4
|
+
/*
|
5
|
+
* Decoder.h
|
6
|
+
* zxing
|
7
|
+
*
|
8
|
+
* Created by Luiz Silva on 09/02/2010.
|
9
|
+
* Copyright 2010 ZXing authors All rights reserved.
|
10
|
+
*
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
+
* you may not use this file except in compliance with the License.
|
13
|
+
* You may obtain a copy of the License at
|
14
|
+
*
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
*
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
+
* See the License for the specific language governing permissions and
|
21
|
+
* limitations under the License.
|
22
|
+
*/
|
23
|
+
|
24
|
+
#include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
|
25
|
+
#include <zxing/common/Counted.h>
|
26
|
+
#include <zxing/common/Array.h>
|
27
|
+
#include <zxing/common/DecoderResult.h>
|
28
|
+
#include <zxing/common/BitMatrix.h>
|
29
|
+
|
30
|
+
|
31
|
+
namespace zxing {
|
32
|
+
namespace datamatrix {
|
33
|
+
|
34
|
+
class Decoder {
|
35
|
+
private:
|
36
|
+
ReedSolomonDecoder rsDecoder_;
|
37
|
+
|
38
|
+
void correctErrors(ArrayRef<char> bytes, int numDataCodewords);
|
39
|
+
|
40
|
+
public:
|
41
|
+
Decoder();
|
42
|
+
|
43
|
+
Ref<DecoderResult> decode(Ref<BitMatrix> bits);
|
44
|
+
};
|
45
|
+
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
#endif // __DECODER_DM_H__
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
* CornerPoint.cpp
|
3
|
+
* zxing
|
4
|
+
*
|
5
|
+
* Created by Luiz Silva on 09/02/2010.
|
6
|
+
* Copyright 2010 ZXing authors All rights reserved.
|
7
|
+
*
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
* you may not use this file except in compliance with the License.
|
10
|
+
* You may obtain a copy of the License at
|
11
|
+
*
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
*
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
* See the License for the specific language governing permissions and
|
18
|
+
* limitations under the License.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <zxing/datamatrix/detector/CornerPoint.h>
|
22
|
+
|
23
|
+
|
24
|
+
namespace zxing {
|
25
|
+
namespace datamatrix {
|
26
|
+
|
27
|
+
using namespace std;
|
28
|
+
|
29
|
+
CornerPoint::CornerPoint(float posX, float posY) :
|
30
|
+
ResultPoint(posX,posY), counter_(0) {
|
31
|
+
}
|
32
|
+
|
33
|
+
int CornerPoint::getCount() const {
|
34
|
+
return counter_;
|
35
|
+
}
|
36
|
+
|
37
|
+
void CornerPoint::incrementCount() {
|
38
|
+
counter_++;
|
39
|
+
}
|
40
|
+
|
41
|
+
bool CornerPoint::equals(Ref<CornerPoint> other) const {
|
42
|
+
return posX_ == other->getX() && posY_ == other->getY();
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#ifndef __CORNER_FINDER_H__
|
2
|
+
#define __CORNER_FINDER_H__
|
3
|
+
|
4
|
+
/*
|
5
|
+
* CornerPoint.h
|
6
|
+
* zxing
|
7
|
+
*
|
8
|
+
* Created by Luiz Silva on 09/02/2010.
|
9
|
+
* Copyright 2010 ZXing authors All rights reserved.
|
10
|
+
*
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
+
* you may not use this file except in compliance with the License.
|
13
|
+
* You may obtain a copy of the License at
|
14
|
+
*
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
*
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
+
* See the License for the specific language governing permissions and
|
21
|
+
* limitations under the License.
|
22
|
+
*/
|
23
|
+
|
24
|
+
#include <zxing/ResultPoint.h>
|
25
|
+
#include <cmath>
|
26
|
+
|
27
|
+
namespace zxing {
|
28
|
+
namespace datamatrix {
|
29
|
+
|
30
|
+
class CornerPoint : public ResultPoint {
|
31
|
+
private:
|
32
|
+
int counter_;
|
33
|
+
|
34
|
+
public:
|
35
|
+
CornerPoint(float posX, float posY);
|
36
|
+
int getCount() const;
|
37
|
+
void incrementCount();
|
38
|
+
bool equals(Ref<CornerPoint> other) const;
|
39
|
+
};
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
#endif // __CORNER_FINDER_H__
|
@@ -0,0 +1,447 @@
|
|
1
|
+
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
2
|
+
/*
|
3
|
+
* Detector.cpp
|
4
|
+
* zxing
|
5
|
+
*
|
6
|
+
* Created by Luiz Silva on 09/02/2010.
|
7
|
+
* Copyright 2010 ZXing authors All rights reserved.
|
8
|
+
*
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
* you may not use this file except in compliance with the License.
|
11
|
+
* You may obtain a copy of the License at
|
12
|
+
*
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
*
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
* See the License for the specific language governing permissions and
|
19
|
+
* limitations under the License.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include <map>
|
23
|
+
#include <zxing/ResultPoint.h>
|
24
|
+
#include <zxing/common/GridSampler.h>
|
25
|
+
#include <zxing/datamatrix/detector/Detector.h>
|
26
|
+
#include <zxing/common/detector/MathUtils.h>
|
27
|
+
#include <zxing/NotFoundException.h>
|
28
|
+
#include <sstream>
|
29
|
+
#include <cstdlib>
|
30
|
+
#include <algorithm> // vs12, std::min und std:max
|
31
|
+
|
32
|
+
using std::abs;
|
33
|
+
using zxing::Ref;
|
34
|
+
using zxing::BitMatrix;
|
35
|
+
using zxing::ResultPoint;
|
36
|
+
using zxing::DetectorResult;
|
37
|
+
using zxing::PerspectiveTransform;
|
38
|
+
using zxing::NotFoundException;
|
39
|
+
using zxing::datamatrix::Detector;
|
40
|
+
using zxing::datamatrix::ResultPointsAndTransitions;
|
41
|
+
using zxing::common::detector::MathUtils;
|
42
|
+
|
43
|
+
namespace {
|
44
|
+
typedef std::map<Ref<ResultPoint>, int> PointMap;
|
45
|
+
void increment(PointMap& table, Ref<ResultPoint> const& key) {
|
46
|
+
int& value = table[key];
|
47
|
+
value += 1;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
ResultPointsAndTransitions::ResultPointsAndTransitions() {
|
52
|
+
Ref<ResultPoint> ref(new ResultPoint(0, 0));
|
53
|
+
from_ = ref;
|
54
|
+
to_ = ref;
|
55
|
+
transitions_ = 0;
|
56
|
+
}
|
57
|
+
|
58
|
+
ResultPointsAndTransitions::ResultPointsAndTransitions(Ref<ResultPoint> from, Ref<ResultPoint> to,
|
59
|
+
int transitions)
|
60
|
+
: to_(to), from_(from), transitions_(transitions) {
|
61
|
+
}
|
62
|
+
|
63
|
+
Ref<ResultPoint> ResultPointsAndTransitions::getFrom() {
|
64
|
+
return from_;
|
65
|
+
}
|
66
|
+
|
67
|
+
Ref<ResultPoint> ResultPointsAndTransitions::getTo() {
|
68
|
+
return to_;
|
69
|
+
}
|
70
|
+
|
71
|
+
int ResultPointsAndTransitions::getTransitions() {
|
72
|
+
return transitions_;
|
73
|
+
}
|
74
|
+
|
75
|
+
Detector::Detector(Ref<BitMatrix> image)
|
76
|
+
: image_(image) {
|
77
|
+
}
|
78
|
+
|
79
|
+
Ref<BitMatrix> Detector::getImage() {
|
80
|
+
return image_;
|
81
|
+
}
|
82
|
+
|
83
|
+
Ref<DetectorResult> Detector::detect() {
|
84
|
+
Ref<WhiteRectangleDetector> rectangleDetector_(new WhiteRectangleDetector(image_));
|
85
|
+
std::vector<Ref<ResultPoint> > ResultPoints = rectangleDetector_->detect();
|
86
|
+
Ref<ResultPoint> pointA = ResultPoints[0];
|
87
|
+
Ref<ResultPoint> pointB = ResultPoints[1];
|
88
|
+
Ref<ResultPoint> pointC = ResultPoints[2];
|
89
|
+
Ref<ResultPoint> pointD = ResultPoints[3];
|
90
|
+
|
91
|
+
// Point A and D are across the diagonal from one another,
|
92
|
+
// as are B and C. Figure out which are the solid black lines
|
93
|
+
// by counting transitions
|
94
|
+
std::vector<Ref<ResultPointsAndTransitions> > transitions(4);
|
95
|
+
transitions[0].reset(transitionsBetween(pointA, pointB));
|
96
|
+
transitions[1].reset(transitionsBetween(pointA, pointC));
|
97
|
+
transitions[2].reset(transitionsBetween(pointB, pointD));
|
98
|
+
transitions[3].reset(transitionsBetween(pointC, pointD));
|
99
|
+
insertionSort(transitions);
|
100
|
+
|
101
|
+
// Sort by number of transitions. First two will be the two solid sides; last two
|
102
|
+
// will be the two alternating black/white sides
|
103
|
+
Ref<ResultPointsAndTransitions> lSideOne(transitions[0]);
|
104
|
+
Ref<ResultPointsAndTransitions> lSideTwo(transitions[1]);
|
105
|
+
|
106
|
+
// Figure out which point is their intersection by tallying up the number of times we see the
|
107
|
+
// endpoints in the four endpoints. One will show up twice.
|
108
|
+
typedef std::map<Ref<ResultPoint>, int> PointMap;
|
109
|
+
PointMap pointCount;
|
110
|
+
increment(pointCount, lSideOne->getFrom());
|
111
|
+
increment(pointCount, lSideOne->getTo());
|
112
|
+
increment(pointCount, lSideTwo->getFrom());
|
113
|
+
increment(pointCount, lSideTwo->getTo());
|
114
|
+
|
115
|
+
// Figure out which point is their intersection by tallying up the number of times we see the
|
116
|
+
// endpoints in the four endpoints. One will show up twice.
|
117
|
+
Ref<ResultPoint> maybeTopLeft;
|
118
|
+
Ref<ResultPoint> bottomLeft;
|
119
|
+
Ref<ResultPoint> maybeBottomRight;
|
120
|
+
for (PointMap::const_iterator entry = pointCount.begin(), end = pointCount.end(); entry != end; ++entry) {
|
121
|
+
Ref<ResultPoint> const& point = entry->first;
|
122
|
+
int value = entry->second;
|
123
|
+
if (value == 2) {
|
124
|
+
bottomLeft = point; // this is definitely the bottom left, then -- end of two L sides
|
125
|
+
} else {
|
126
|
+
// Otherwise it's either top left or bottom right -- just assign the two arbitrarily now
|
127
|
+
if (maybeTopLeft == 0) {
|
128
|
+
maybeTopLeft = point;
|
129
|
+
} else {
|
130
|
+
maybeBottomRight = point;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
if (maybeTopLeft == 0 || bottomLeft == 0 || maybeBottomRight == 0) {
|
136
|
+
throw NotFoundException();
|
137
|
+
}
|
138
|
+
|
139
|
+
// Bottom left is correct but top left and bottom right might be switched
|
140
|
+
std::vector<Ref<ResultPoint> > corners(3);
|
141
|
+
corners[0].reset(maybeTopLeft);
|
142
|
+
corners[1].reset(bottomLeft);
|
143
|
+
corners[2].reset(maybeBottomRight);
|
144
|
+
|
145
|
+
// Use the dot product trick to sort them out
|
146
|
+
ResultPoint::orderBestPatterns(corners);
|
147
|
+
|
148
|
+
// Now we know which is which:
|
149
|
+
Ref<ResultPoint> bottomRight(corners[0]);
|
150
|
+
bottomLeft = corners[1];
|
151
|
+
Ref<ResultPoint> topLeft(corners[2]);
|
152
|
+
|
153
|
+
// Which point didn't we find in relation to the "L" sides? that's the top right corner
|
154
|
+
Ref<ResultPoint> topRight;
|
155
|
+
if (!(pointA->equals(bottomRight) || pointA->equals(bottomLeft) || pointA->equals(topLeft))) {
|
156
|
+
topRight = pointA;
|
157
|
+
} else if (!(pointB->equals(bottomRight) || pointB->equals(bottomLeft)
|
158
|
+
|| pointB->equals(topLeft))) {
|
159
|
+
topRight = pointB;
|
160
|
+
} else if (!(pointC->equals(bottomRight) || pointC->equals(bottomLeft)
|
161
|
+
|| pointC->equals(topLeft))) {
|
162
|
+
topRight = pointC;
|
163
|
+
} else {
|
164
|
+
topRight = pointD;
|
165
|
+
}
|
166
|
+
|
167
|
+
// Next determine the dimension by tracing along the top or right side and counting black/white
|
168
|
+
// transitions. Since we start inside a black module, we should see a number of transitions
|
169
|
+
// equal to 1 less than the code dimension. Well, actually 2 less, because we are going to
|
170
|
+
// end on a black module:
|
171
|
+
|
172
|
+
// The top right point is actually the corner of a module, which is one of the two black modules
|
173
|
+
// adjacent to the white module at the top right. Tracing to that corner from either the top left
|
174
|
+
// or bottom right should work here.
|
175
|
+
|
176
|
+
int dimensionTop = transitionsBetween(topLeft, topRight)->getTransitions();
|
177
|
+
int dimensionRight = transitionsBetween(bottomRight, topRight)->getTransitions();
|
178
|
+
|
179
|
+
//dimensionTop++;
|
180
|
+
if ((dimensionTop & 0x01) == 1) {
|
181
|
+
// it can't be odd, so, round... up?
|
182
|
+
dimensionTop++;
|
183
|
+
}
|
184
|
+
dimensionTop += 2;
|
185
|
+
|
186
|
+
//dimensionRight++;
|
187
|
+
if ((dimensionRight & 0x01) == 1) {
|
188
|
+
// it can't be odd, so, round... up?
|
189
|
+
dimensionRight++;
|
190
|
+
}
|
191
|
+
dimensionRight += 2;
|
192
|
+
|
193
|
+
Ref<BitMatrix> bits;
|
194
|
+
Ref<PerspectiveTransform> transform;
|
195
|
+
Ref<ResultPoint> correctedTopRight;
|
196
|
+
|
197
|
+
|
198
|
+
// Rectanguar symbols are 6x16, 6x28, 10x24, 10x32, 14x32, or 14x44. If one dimension is more
|
199
|
+
// than twice the other, it's certainly rectangular, but to cut a bit more slack we accept it as
|
200
|
+
// rectangular if the bigger side is at least 7/4 times the other:
|
201
|
+
if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) {
|
202
|
+
// The matrix is rectangular
|
203
|
+
correctedTopRight = correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight,
|
204
|
+
dimensionTop, dimensionRight);
|
205
|
+
if (correctedTopRight == NULL) {
|
206
|
+
correctedTopRight = topRight;
|
207
|
+
}
|
208
|
+
|
209
|
+
dimensionTop = transitionsBetween(topLeft, correctedTopRight)->getTransitions();
|
210
|
+
dimensionRight = transitionsBetween(bottomRight, correctedTopRight)->getTransitions();
|
211
|
+
|
212
|
+
if ((dimensionTop & 0x01) == 1) {
|
213
|
+
// it can't be odd, so, round... up?
|
214
|
+
dimensionTop++;
|
215
|
+
}
|
216
|
+
|
217
|
+
if ((dimensionRight & 0x01) == 1) {
|
218
|
+
// it can't be odd, so, round... up?
|
219
|
+
dimensionRight++;
|
220
|
+
}
|
221
|
+
|
222
|
+
transform = createTransform(topLeft, correctedTopRight, bottomLeft, bottomRight, dimensionTop,
|
223
|
+
dimensionRight);
|
224
|
+
bits = sampleGrid(image_, dimensionTop, dimensionRight, transform);
|
225
|
+
|
226
|
+
} else {
|
227
|
+
// The matrix is square
|
228
|
+
int dimension = min(dimensionRight, dimensionTop);
|
229
|
+
|
230
|
+
// correct top right point to match the white module
|
231
|
+
correctedTopRight = correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension);
|
232
|
+
if (correctedTopRight == NULL) {
|
233
|
+
correctedTopRight = topRight;
|
234
|
+
}
|
235
|
+
|
236
|
+
// Redetermine the dimension using the corrected top right point
|
237
|
+
int dimensionCorrected = std::max(transitionsBetween(topLeft, correctedTopRight)->getTransitions(),
|
238
|
+
transitionsBetween(bottomRight, correctedTopRight)->getTransitions());
|
239
|
+
dimensionCorrected++;
|
240
|
+
if ((dimensionCorrected & 0x01) == 1) {
|
241
|
+
dimensionCorrected++;
|
242
|
+
}
|
243
|
+
|
244
|
+
transform = createTransform(topLeft, correctedTopRight, bottomLeft, bottomRight,
|
245
|
+
dimensionCorrected, dimensionCorrected);
|
246
|
+
bits = sampleGrid(image_, dimensionCorrected, dimensionCorrected, transform);
|
247
|
+
}
|
248
|
+
|
249
|
+
ArrayRef< Ref<ResultPoint> > points (new Array< Ref<ResultPoint> >(4));
|
250
|
+
points[0].reset(topLeft);
|
251
|
+
points[1].reset(bottomLeft);
|
252
|
+
points[2].reset(correctedTopRight);
|
253
|
+
points[3].reset(bottomRight);
|
254
|
+
Ref<DetectorResult> detectorResult(new DetectorResult(bits, points));
|
255
|
+
return detectorResult;
|
256
|
+
}
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Calculates the position of the white top right module using the output of the rectangle detector
|
260
|
+
* for a rectangular matrix
|
261
|
+
*/
|
262
|
+
Ref<ResultPoint> Detector::correctTopRightRectangular(Ref<ResultPoint> bottomLeft,
|
263
|
+
Ref<ResultPoint> bottomRight, Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight,
|
264
|
+
int dimensionTop, int dimensionRight) {
|
265
|
+
|
266
|
+
float corr = distance(bottomLeft, bottomRight) / (float) dimensionTop;
|
267
|
+
int norm = distance(topLeft, topRight);
|
268
|
+
float cos = (topRight->getX() - topLeft->getX()) / norm;
|
269
|
+
float sin = (topRight->getY() - topLeft->getY()) / norm;
|
270
|
+
|
271
|
+
Ref<ResultPoint> c1(
|
272
|
+
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
|
273
|
+
|
274
|
+
corr = distance(bottomLeft, topLeft) / (float) dimensionRight;
|
275
|
+
norm = distance(bottomRight, topRight);
|
276
|
+
cos = (topRight->getX() - bottomRight->getX()) / norm;
|
277
|
+
sin = (topRight->getY() - bottomRight->getY()) / norm;
|
278
|
+
|
279
|
+
Ref<ResultPoint> c2(
|
280
|
+
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
|
281
|
+
|
282
|
+
if (!isValid(c1)) {
|
283
|
+
if (isValid(c2)) {
|
284
|
+
return c2;
|
285
|
+
}
|
286
|
+
return Ref<ResultPoint>(NULL);
|
287
|
+
}
|
288
|
+
if (!isValid(c2)) {
|
289
|
+
return c1;
|
290
|
+
}
|
291
|
+
|
292
|
+
int l1 = abs(dimensionTop - transitionsBetween(topLeft, c1)->getTransitions())
|
293
|
+
+ abs(dimensionRight - transitionsBetween(bottomRight, c1)->getTransitions());
|
294
|
+
int l2 = abs(dimensionTop - transitionsBetween(topLeft, c2)->getTransitions())
|
295
|
+
+ abs(dimensionRight - transitionsBetween(bottomRight, c2)->getTransitions());
|
296
|
+
|
297
|
+
return l1 <= l2 ? c1 : c2;
|
298
|
+
}
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Calculates the position of the white top right module using the output of the rectangle detector
|
302
|
+
* for a square matrix
|
303
|
+
*/
|
304
|
+
Ref<ResultPoint> Detector::correctTopRight(Ref<ResultPoint> bottomLeft,
|
305
|
+
Ref<ResultPoint> bottomRight, Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight,
|
306
|
+
int dimension) {
|
307
|
+
|
308
|
+
float corr = distance(bottomLeft, bottomRight) / (float) dimension;
|
309
|
+
int norm = distance(topLeft, topRight);
|
310
|
+
float cos = (topRight->getX() - topLeft->getX()) / norm;
|
311
|
+
float sin = (topRight->getY() - topLeft->getY()) / norm;
|
312
|
+
|
313
|
+
Ref<ResultPoint> c1(
|
314
|
+
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
|
315
|
+
|
316
|
+
corr = distance(bottomLeft, topLeft) / (float) dimension;
|
317
|
+
norm = distance(bottomRight, topRight);
|
318
|
+
cos = (topRight->getX() - bottomRight->getX()) / norm;
|
319
|
+
sin = (topRight->getY() - bottomRight->getY()) / norm;
|
320
|
+
|
321
|
+
Ref<ResultPoint> c2(
|
322
|
+
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
|
323
|
+
|
324
|
+
if (!isValid(c1)) {
|
325
|
+
if (isValid(c2)) {
|
326
|
+
return c2;
|
327
|
+
}
|
328
|
+
return Ref<ResultPoint>(NULL);
|
329
|
+
}
|
330
|
+
if (!isValid(c2)) {
|
331
|
+
return c1;
|
332
|
+
}
|
333
|
+
|
334
|
+
int l1 = abs(
|
335
|
+
transitionsBetween(topLeft, c1)->getTransitions()
|
336
|
+
- transitionsBetween(bottomRight, c1)->getTransitions());
|
337
|
+
int l2 = abs(
|
338
|
+
transitionsBetween(topLeft, c2)->getTransitions()
|
339
|
+
- transitionsBetween(bottomRight, c2)->getTransitions());
|
340
|
+
|
341
|
+
return l1 <= l2 ? c1 : c2;
|
342
|
+
}
|
343
|
+
|
344
|
+
bool Detector::isValid(Ref<ResultPoint> p) {
|
345
|
+
return p->getX() >= 0 && p->getX() < image_->getWidth() && p->getY() > 0
|
346
|
+
&& p->getY() < image_->getHeight();
|
347
|
+
}
|
348
|
+
|
349
|
+
int Detector::distance(Ref<ResultPoint> a, Ref<ResultPoint> b) {
|
350
|
+
return MathUtils::round(ResultPoint::distance(a, b));
|
351
|
+
}
|
352
|
+
|
353
|
+
Ref<ResultPointsAndTransitions> Detector::transitionsBetween(Ref<ResultPoint> from,
|
354
|
+
Ref<ResultPoint> to) {
|
355
|
+
// See QR Code Detector, sizeOfBlackWhiteBlackRun()
|
356
|
+
int fromX = (int) from->getX();
|
357
|
+
int fromY = (int) from->getY();
|
358
|
+
int toX = (int) to->getX();
|
359
|
+
int toY = (int) to->getY();
|
360
|
+
bool steep = abs(toY - fromY) > abs(toX - fromX);
|
361
|
+
if (steep) {
|
362
|
+
int temp = fromX;
|
363
|
+
fromX = fromY;
|
364
|
+
fromY = temp;
|
365
|
+
temp = toX;
|
366
|
+
toX = toY;
|
367
|
+
toY = temp;
|
368
|
+
}
|
369
|
+
|
370
|
+
int dx = abs(toX - fromX);
|
371
|
+
int dy = abs(toY - fromY);
|
372
|
+
int error = -dx >> 1;
|
373
|
+
int ystep = fromY < toY ? 1 : -1;
|
374
|
+
int xstep = fromX < toX ? 1 : -1;
|
375
|
+
int transitions = 0;
|
376
|
+
bool inBlack = image_->get(steep ? fromY : fromX, steep ? fromX : fromY);
|
377
|
+
for (int x = fromX, y = fromY; x != toX; x += xstep) {
|
378
|
+
bool isBlack = image_->get(steep ? y : x, steep ? x : y);
|
379
|
+
if (isBlack != inBlack) {
|
380
|
+
transitions++;
|
381
|
+
inBlack = isBlack;
|
382
|
+
}
|
383
|
+
error += dy;
|
384
|
+
if (error > 0) {
|
385
|
+
if (y == toY) {
|
386
|
+
break;
|
387
|
+
}
|
388
|
+
y += ystep;
|
389
|
+
error -= dx;
|
390
|
+
}
|
391
|
+
}
|
392
|
+
Ref<ResultPointsAndTransitions> result(new ResultPointsAndTransitions(from, to, transitions));
|
393
|
+
return result;
|
394
|
+
}
|
395
|
+
|
396
|
+
Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft,
|
397
|
+
Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft, Ref<ResultPoint> bottomRight,
|
398
|
+
int dimensionX, int dimensionY) {
|
399
|
+
|
400
|
+
Ref<PerspectiveTransform> transform(
|
401
|
+
PerspectiveTransform::quadrilateralToQuadrilateral(
|
402
|
+
0.5f,
|
403
|
+
0.5f,
|
404
|
+
dimensionX - 0.5f,
|
405
|
+
0.5f,
|
406
|
+
dimensionX - 0.5f,
|
407
|
+
dimensionY - 0.5f,
|
408
|
+
0.5f,
|
409
|
+
dimensionY - 0.5f,
|
410
|
+
topLeft->getX(),
|
411
|
+
topLeft->getY(),
|
412
|
+
topRight->getX(),
|
413
|
+
topRight->getY(),
|
414
|
+
bottomRight->getX(),
|
415
|
+
bottomRight->getY(),
|
416
|
+
bottomLeft->getX(),
|
417
|
+
bottomLeft->getY()));
|
418
|
+
return transform;
|
419
|
+
}
|
420
|
+
|
421
|
+
Ref<BitMatrix> Detector::sampleGrid(Ref<BitMatrix> image, int dimensionX, int dimensionY,
|
422
|
+
Ref<PerspectiveTransform> transform) {
|
423
|
+
GridSampler &sampler = GridSampler::getInstance();
|
424
|
+
return sampler.sampleGrid(image, dimensionX, dimensionY, transform);
|
425
|
+
}
|
426
|
+
|
427
|
+
void Detector::insertionSort(std::vector<Ref<ResultPointsAndTransitions> > &vector) {
|
428
|
+
int max = vector.size();
|
429
|
+
bool swapped = true;
|
430
|
+
Ref<ResultPointsAndTransitions> value;
|
431
|
+
Ref<ResultPointsAndTransitions> valueB;
|
432
|
+
do {
|
433
|
+
swapped = false;
|
434
|
+
for (int i = 1; i < max; i++) {
|
435
|
+
value = vector[i - 1];
|
436
|
+
if (compare(value, (valueB = vector[i])) > 0){
|
437
|
+
swapped = true;
|
438
|
+
vector[i - 1].reset(valueB);
|
439
|
+
vector[i].reset(value);
|
440
|
+
}
|
441
|
+
}
|
442
|
+
} while (swapped);
|
443
|
+
}
|
444
|
+
|
445
|
+
int Detector::compare(Ref<ResultPointsAndTransitions> a, Ref<ResultPointsAndTransitions> b) {
|
446
|
+
return a->getTransitions() - b->getTransitions();
|
447
|
+
}
|