From 2b01d912d3fde8cca2d13e8a60598c57e3cb9a35 Mon Sep 17 00:00:00 2001 From: "smparkes@smparkes.net" Date: Sat, 18 Feb 2012 02:14:45 +0000 Subject: [PATCH] ahti333's port of aztec and gfpoly + some fixes + Xcode tweaks for recent ECI updates git-svn-id: https://zxing.googlecode.com/svn/trunk@2204 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- cpp/blackboxtest.results | 75 +++ cpp/blackboxtest.sh | 2 +- cpp/core/src/zxing/BarcodeFormat.cpp | 3 +- cpp/core/src/zxing/BarcodeFormat.h | 30 +- cpp/core/src/zxing/DecodeHints.cpp | 3 + cpp/core/src/zxing/DecodeHints.h | 1 + cpp/core/src/zxing/MultiFormatReader.cpp | 4 + .../src/zxing/aztec/AztecDetectorResult.cpp | 45 ++ .../src/zxing/aztec/AztecDetectorResult.h | 42 ++ cpp/core/src/zxing/aztec/AztecReader.cpp | 64 ++ cpp/core/src/zxing/aztec/AztecReader.h | 49 ++ cpp/core/src/zxing/aztec/decoder/Decoder.cpp | 482 +++++++++++++++ cpp/core/src/zxing/aztec/decoder/Decoder.h | 63 ++ .../src/zxing/aztec/detector/Detector.cpp | 554 ++++++++++++++++++ cpp/core/src/zxing/aztec/detector/Detector.h | 87 +++ cpp/core/src/zxing/common/DetectorResult.cpp | 8 +- cpp/core/src/zxing/common/DetectorResult.h | 5 +- .../detector/WhiteRectangleDetector.cpp | 35 +- .../common/detector/WhiteRectangleDetector.h | 5 + .../src/zxing/common/reedsolomon/GF256.cpp | 136 ----- cpp/core/src/zxing/common/reedsolomon/GF256.h | 68 --- .../zxing/common/reedsolomon/GF256Poly.cpp | 198 ------- .../src/zxing/common/reedsolomon/GF256Poly.h | 53 -- .../zxing/common/reedsolomon/GenericGF.cpp | 153 +++++ .../src/zxing/common/reedsolomon/GenericGF.h | 78 +++ .../common/reedsolomon/GenericGFPoly.cpp | 215 +++++++ .../zxing/common/reedsolomon/GenericGFPoly.h | 54 ++ .../common/reedsolomon/ReedSolomonDecoder.cpp | 83 +-- .../common/reedsolomon/ReedSolomonDecoder.h | 16 +- .../src/zxing/datamatrix/decoder/Decoder.cpp | 2 +- .../src/zxing/datamatrix/decoder/Decoder.h | 1 - .../zxing/datamatrix/detector/Detector.cpp | 2 +- cpp/core/src/zxing/qrcode/decoder/Decoder.cpp | 2 +- cpp/core/src/zxing/qrcode/decoder/Decoder.h | 1 - .../src/zxing/qrcode/detector/Detector.cpp | 2 +- .../common/reedsolomon/ReedSolomonTest.cpp | 4 +- cpp/ios.xcodeproj/project.pbxproj | 80 ++- cpp/osx.xcodeproj/project.pbxproj | 256 +++----- iphone/ScanTest/Classes/RootViewController.mm | 55 +- iphone/ZXingWidget/Classes/AztecReader.h | 15 + iphone/ZXingWidget/Classes/AztecReader.mm | 25 + iphone/ZXingWidget/Classes/CBarcodeFormat.h | 23 +- iphone/ZXingWidget/Classes/CBarcodeFormat.mm | 47 +- iphone/ZXingWidget/Classes/Decoder.mm | 51 +- .../ZXingWidget.xcodeproj/project.pbxproj | 116 +++- 45 files changed, 2441 insertions(+), 852 deletions(-) create mode 100644 cpp/core/src/zxing/aztec/AztecDetectorResult.cpp create mode 100644 cpp/core/src/zxing/aztec/AztecDetectorResult.h create mode 100644 cpp/core/src/zxing/aztec/AztecReader.cpp create mode 100644 cpp/core/src/zxing/aztec/AztecReader.h create mode 100644 cpp/core/src/zxing/aztec/decoder/Decoder.cpp create mode 100644 cpp/core/src/zxing/aztec/decoder/Decoder.h create mode 100644 cpp/core/src/zxing/aztec/detector/Detector.cpp create mode 100644 cpp/core/src/zxing/aztec/detector/Detector.h delete mode 100644 cpp/core/src/zxing/common/reedsolomon/GF256.cpp delete mode 100644 cpp/core/src/zxing/common/reedsolomon/GF256.h delete mode 100644 cpp/core/src/zxing/common/reedsolomon/GF256Poly.cpp delete mode 100644 cpp/core/src/zxing/common/reedsolomon/GF256Poly.h create mode 100644 cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp create mode 100644 cpp/core/src/zxing/common/reedsolomon/GenericGF.h create mode 100644 cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp create mode 100644 cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h create mode 100644 iphone/ZXingWidget/Classes/AztecReader.h create mode 100644 iphone/ZXingWidget/Classes/AztecReader.mm diff --git a/cpp/blackboxtest.results b/cpp/blackboxtest.results index d0268b88e..967c5c0d2 100644 --- a/cpp/blackboxtest.results +++ b/cpp/blackboxtest.results @@ -1003,3 +1003,78 @@ Processing: ../core/test/data/blackbox/qrcode-6/7.png ... passed. Processing: ../core/test/data/blackbox/qrcode-6/8.png ... passed. Processing: ../core/test/data/blackbox/qrcode-6/9.png ... passed. ***** qrcode-6 finished - 15 of 15 passed **** ***** ******* ***** ********************* +Processing: ../core/test/data/blackbox/aztec-1/7.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/Historico.gif ... passed. +Processing: ../core/test/data/blackbox/aztec-1/HistoricoLong.gif ... passed. +Processing: ../core/test/data/blackbox/aztec-1/abc-19x19C.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/abc-37x37.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/lorem-075x075.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/lorem-105x105.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/lorem-151x151.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/tableShifts.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/tag.png ... passed. +Processing: ../core/test/data/blackbox/aztec-1/texte.png ... passed. +***** aztec-1 finished - 11 of 11 passed **** ***** ******* ***** ********************* +Processing: ../core/test/data/blackbox/aztec-2/01.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/02.png ... passed. +Processing: ../core/test/data/blackbox/aztec-2/03.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/04.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/05.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/06.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/07.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/08.png ... FAILED + Expected: This is a real world Aztec barcode test. + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/09.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::IllegalArgumentException: Invalid position (ReedSolomonDecoder) +Processing: ../core/test/data/blackbox/aztec-2/10.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/11.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::IllegalArgumentException: Invalid position (ReedSolomonDecoder) +Processing: ../core/test/data/blackbox/aztec-2/12.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/13.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/14.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/15.png ... FAILED + Expected: mailto:zxing@googlegroups.com + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/16.png ... FAILED + Expected: http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/17.png ... FAILED + Expected: http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/18.png ... passed. +Processing: ../core/test/data/blackbox/aztec-2/19.png ... FAILED + Expected: http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/20.png ... FAILED + Expected: http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/21.png ... FAILED + Expected: http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java + Detected: zxing::ReaderException: No code detected +Processing: ../core/test/data/blackbox/aztec-2/22.png ... FAILED + Expected: http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java + Detected: zxing::ReaderException: No code detected +***** aztec-2 finished - 2 of 22 passed **** ***** ******* ***** ********************* diff --git a/cpp/blackboxtest.sh b/cpp/blackboxtest.sh index f329d19f1..7341087ee 100755 --- a/cpp/blackboxtest.sh +++ b/cpp/blackboxtest.sh @@ -5,7 +5,7 @@ blackboxpath="../core/test/data/blackbox" if [ "$*" != "" ]; then formats="$*" else - formats="ean13 ean8 upce upca qrcode" + formats="ean13 ean8 upce upca qrcode aztec" fi passed=0; diff --git a/cpp/core/src/zxing/BarcodeFormat.cpp b/cpp/core/src/zxing/BarcodeFormat.cpp index c0623f379..5dae4a106 100755 --- a/cpp/core/src/zxing/BarcodeFormat.cpp +++ b/cpp/core/src/zxing/BarcodeFormat.cpp @@ -30,7 +30,8 @@ const char *barcodeFormatNames[] = { "EAN_13", "CODE_128", "CODE_39", - "ITF" + "ITF", + "AZTEC" }; } diff --git a/cpp/core/src/zxing/BarcodeFormat.h b/cpp/core/src/zxing/BarcodeFormat.h index 78e6f8c8e..4dc9f6f8b 100644 --- a/cpp/core/src/zxing/BarcodeFormat.h +++ b/cpp/core/src/zxing/BarcodeFormat.h @@ -1,3 +1,4 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __BARCODE_FORMAT_H__ #define __BARCODE_FORMAT_H__ @@ -22,21 +23,22 @@ namespace zxing { - typedef enum BarcodeFormat { - BarcodeFormat_None = 0, - BarcodeFormat_QR_CODE, - BarcodeFormat_DATA_MATRIX, - BarcodeFormat_UPC_E, - BarcodeFormat_UPC_A, - BarcodeFormat_EAN_8, - BarcodeFormat_EAN_13, - BarcodeFormat_CODE_128, - BarcodeFormat_CODE_39, - BarcodeFormat_ITF - } BarcodeFormat; + typedef enum BarcodeFormat { + BarcodeFormat_None = 0, + BarcodeFormat_QR_CODE, + BarcodeFormat_DATA_MATRIX, + BarcodeFormat_UPC_E, + BarcodeFormat_UPC_A, + BarcodeFormat_EAN_8, + BarcodeFormat_EAN_13, + BarcodeFormat_CODE_128, + BarcodeFormat_CODE_39, + BarcodeFormat_ITF, + BarcodeFormat_AZTEC + } BarcodeFormat; - /* if you update the enum, please update the name in BarcodeFormat.cpp */ - extern const char *barcodeFormatNames[]; + /* if you update the enum, please update the name in BarcodeFormat.cpp */ + extern const char *barcodeFormatNames[]; } #endif // __BARCODE_FORMAT_H__ diff --git a/cpp/core/src/zxing/DecodeHints.cpp b/cpp/core/src/zxing/DecodeHints.cpp index 578cdc5bb..6bbac0f1c 100644 --- a/cpp/core/src/zxing/DecodeHints.cpp +++ b/cpp/core/src/zxing/DecodeHints.cpp @@ -47,6 +47,7 @@ const DecodeHints DecodeHints::DEFAULT_HINT( BARCODEFORMAT_CODE_39_HINT | BARCODEFORMAT_ITF_HINT | BARCODEFORMAT_DATA_MATRIX_HINT | + BARCODEFORMAT_AZTEC_HINT | BARCODEFORMAT_QR_CODE_HINT); DecodeHints::DecodeHints() { @@ -59,6 +60,7 @@ DecodeHints::DecodeHints(DecodeHintType init) { void DecodeHints::addFormat(BarcodeFormat toadd) { switch (toadd) { + case BarcodeFormat_AZTEC: hints |= BARCODEFORMAT_AZTEC_HINT; break; case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break; case BarcodeFormat_DATA_MATRIX: hints |= BARCODEFORMAT_DATA_MATRIX_HINT; break; case BarcodeFormat_UPC_E: hints |= BARCODEFORMAT_UPC_E_HINT; break; @@ -75,6 +77,7 @@ void DecodeHints::addFormat(BarcodeFormat toadd) { bool DecodeHints::containsFormat(BarcodeFormat tocheck) const { DecodeHintType checkAgainst; switch (tocheck) { + case BarcodeFormat_AZTEC: checkAgainst = BARCODEFORMAT_AZTEC_HINT; break; case BarcodeFormat_QR_CODE: checkAgainst = BARCODEFORMAT_QR_CODE_HINT; break; case BarcodeFormat_DATA_MATRIX: checkAgainst = BARCODEFORMAT_DATA_MATRIX_HINT; break; case BarcodeFormat_UPC_E: checkAgainst = BARCODEFORMAT_UPC_E_HINT; break; diff --git a/cpp/core/src/zxing/DecodeHints.h b/cpp/core/src/zxing/DecodeHints.h index 7eb120194..16486665c 100644 --- a/cpp/core/src/zxing/DecodeHints.h +++ b/cpp/core/src/zxing/DecodeHints.h @@ -45,6 +45,7 @@ class DecodeHints { static const DecodeHintType BARCODEFORMAT_CODE_128_HINT = 1 << BarcodeFormat_CODE_128; static const DecodeHintType BARCODEFORMAT_CODE_39_HINT = 1 << BarcodeFormat_CODE_39; static const DecodeHintType BARCODEFORMAT_ITF_HINT = 1 << BarcodeFormat_ITF; + static const DecodeHintType BARCODEFORMAT_AZTEC_HINT = 1 << BarcodeFormat_AZTEC; static const DecodeHintType CHARACTER_SET = 1 << 30; static const DecodeHintType TRYHARDER_HINT = 1 << 31; diff --git a/cpp/core/src/zxing/MultiFormatReader.cpp b/cpp/core/src/zxing/MultiFormatReader.cpp index 6b423e8e1..82067df0b 100644 --- a/cpp/core/src/zxing/MultiFormatReader.cpp +++ b/cpp/core/src/zxing/MultiFormatReader.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,9 @@ namespace zxing { if (hints.containsFormat(BarcodeFormat_DATA_MATRIX)) { readers_.push_back(Ref(new zxing::datamatrix::DataMatrixReader())); } + if (hints.containsFormat(BarcodeFormat_AZTEC)) { + readers_.push_back(Ref(new zxing::aztec::AztecReader())); + } //TODO: add PDF417 here once PDF417 reader is implemented if (addOneDReader && tryHarder) { readers_.push_back(Ref(new zxing::oned::MultiFormatOneDReader(hints))); diff --git a/cpp/core/src/zxing/aztec/AztecDetectorResult.cpp b/cpp/core/src/zxing/aztec/AztecDetectorResult.cpp new file mode 100644 index 000000000..72fae6931 --- /dev/null +++ b/cpp/core/src/zxing/aztec/AztecDetectorResult.cpp @@ -0,0 +1,45 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * AtztecDetecorResult.cpp + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace zxing { + namespace aztec { + AztecDetectorResult::AztecDetectorResult(Ref bits, std::vector > points, bool compact, int nbDatablocks, int nbLayers) + : DetectorResult(bits, points), + compact_(compact), + nbDatablocks_(nbDatablocks), + nbLayers_(nbLayers) { + }; + + bool AztecDetectorResult::isCompact() { + return compact_; + } + + int AztecDetectorResult::getNBDatablocks() { + return nbDatablocks_; + } + + int AztecDetectorResult::getNBLayers() { + return nbLayers_; + } + } +} \ No newline at end of file diff --git a/cpp/core/src/zxing/aztec/AztecDetectorResult.h b/cpp/core/src/zxing/aztec/AztecDetectorResult.h new file mode 100644 index 000000000..dc2cc4e3d --- /dev/null +++ b/cpp/core/src/zxing/aztec/AztecDetectorResult.h @@ -0,0 +1,42 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * AtztecDetecorResult.h + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef ZXingWidget_AtztecDetecorResult_h +#define ZXingWidget_AtztecDetecorResult_h + +namespace zxing { + namespace aztec { + class AztecDetectorResult : public DetectorResult { + private: + bool compact_; + int nbDatablocks_, nbLayers_; + public: + AztecDetectorResult(Ref bits, std::vector > points, bool compact, int nbDatablocks, int nbLayers); + bool isCompact(); + int getNBDatablocks(); + int getNBLayers(); + }; + } +} + +#endif diff --git a/cpp/core/src/zxing/aztec/AztecReader.cpp b/cpp/core/src/zxing/aztec/AztecReader.cpp new file mode 100644 index 000000000..05fd79c57 --- /dev/null +++ b/cpp/core/src/zxing/aztec/AztecReader.cpp @@ -0,0 +1,64 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * AztecReader.cpp + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +namespace zxing { + namespace aztec { + + AztecReader::AztecReader() : decoder_() { + // nothing + }; + + Ref AztecReader::decode(Ref image) { + Detector detector(image->getBlackMatrix()); + + Ref detectorResult(detector.detect()); + + std::vector > points(detectorResult->getPoints()); + + Ref decoderResult(decoder_.decode(detectorResult)); + + Ref result(new Result(decoderResult->getText(), + decoderResult->getRawBytes(), + points, + BarcodeFormat_AZTEC)); + + return result; + } + + Ref AztecReader::decode(Ref image, DecodeHints) { + //cout << "decoding with hints not supported for aztec" << "\n" << flush; + return this->decode(image); + } + + AztecReader::~AztecReader() { + // nothing + } + + Decoder& AztecReader::getDecoder() { + return decoder_; + } + + } +} diff --git a/cpp/core/src/zxing/aztec/AztecReader.h b/cpp/core/src/zxing/aztec/AztecReader.h new file mode 100644 index 000000000..0ab0ce030 --- /dev/null +++ b/cpp/core/src/zxing/aztec/AztecReader.h @@ -0,0 +1,49 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * AztecReader.h + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#ifndef ZXingWidget_AztecReader_h +#define ZXingWidget_AztecReader_h + +namespace zxing { + namespace aztec { + + class AztecReader : public Reader { + private: + Decoder decoder_; + + protected: + Decoder &getDecoder(); + + public: + AztecReader(); + virtual Ref decode(Ref image); + virtual Ref decode(Ref image, DecodeHints hints); + virtual ~AztecReader(); + }; + + } +} + +#endif diff --git a/cpp/core/src/zxing/aztec/decoder/Decoder.cpp b/cpp/core/src/zxing/aztec/decoder/Decoder.cpp new file mode 100644 index 000000000..09b2fe9bd --- /dev/null +++ b/cpp/core/src/zxing/aztec/decoder/Decoder.cpp @@ -0,0 +1,482 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * Decoder.cpp + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +using zxing::aztec::Decoder; +using zxing::DecoderResult; +using zxing::String; +using zxing::BitArray; +using zxing::BitMatrix; +using zxing::Ref; + +using std::string; + +namespace { + void add(string& result, uint8_t character) { + char s[] = { character & 0xff }; + char* ss = s; + size_t sl = sizeof(s); + char d[4]; + char* ds = d; + size_t dl = sizeof(d); + iconv_t ic = iconv_open("UTF-8", "ISO-8859-1"); + iconv(ic, &ss, &sl, &ds, &dl); + iconv_close(ic); + d[sizeof(d)-dl] = 0; + result.append(d); + } + + const int NB_BITS_COMPACT[] = { + 0, 104, 240, 408, 608 + }; + + const int NB_BITS[] = { + 0, 128, 288, 480, 704, 960, 1248, 1568, 1920, 2304, 2720, 3168, 3648, 4160, 4704, 5280, 5888, 6528, + 7200, 7904, 8640, 9408, 10208, 11040, 11904, 12800, 13728, 14688, 15680, 16704, 17760, 18848, 19968 + }; + + const int NB_DATABLOCK_COMPACT[] = { + 0, 17, 40, 51, 76 + }; + + const int NB_DATABLOCK[] = { + 0, 21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790, 864, + 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664 + }; + + const char* UPPER_TABLE[] = { + "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", + "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS" + }; + + const char* LOWER_TABLE[] = { + "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", + "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS" + }; + + const char* MIXED_TABLE[] = { + "CTRL_PS", " ", "\1", "\2", "\3", "\4", "\5", "\6", "\7", "\b", "\t", "\n", + "\13", "\f", "\r", "\33", "\34", "\35", "\36", "\37", "@", "\\", "^", "_", + "`", "|", "~", "\177", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS" + }; + + const char* PUNCT_TABLE[] = { + "", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", + "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL" + }; + + const char* DIGIT_TABLE[] = { + "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US" + }; +} + +Decoder::Table Decoder::getTable(char t) { + switch (t) { + case 'L': + return LOWER; + case 'P': + return PUNCT; + case 'M': + return MIXED; + case 'D': + return DIGIT; + case 'B': + return BINARY; + case 'U': + default: + return UPPER; + } +} + +const char* Decoder::getCharacter(zxing::aztec::Decoder::Table table, int code) { + switch (table) { + case UPPER: + return UPPER_TABLE[code]; + case LOWER: + return LOWER_TABLE[code]; + case MIXED: + return MIXED_TABLE[code]; + case PUNCT: + return PUNCT_TABLE[code]; + case DIGIT: + return DIGIT_TABLE[code]; + default: + return ""; + } +} + +Decoder::Decoder() { + // nothing +} + +Ref Decoder::decode(Ref detectorResult) { + ddata_ = detectorResult; + + // std::printf("getting bits\n"); + + Ref matrix = detectorResult->getBits(); + + if (!ddata_->isCompact()) { + // std::printf("removing lines\n"); + matrix = removeDashedLines(ddata_->getBits()); + } + + // std::printf("extracting bits\n"); + Ref rawbits = extractBits(matrix); + + // std::printf("correcting bits\n"); + Ref aCorrectedBits = correctBits(rawbits); + + // std::printf("decoding bits\n"); + Ref result = getEncodedData(aCorrectedBits); + + // std::printf("constructing array\n"); + ArrayRef arrayOut(aCorrectedBits->getSize()); + for (int i = 0; i < aCorrectedBits->count(); i++) { + arrayOut[i] = (unsigned char)aCorrectedBits->get(i); + } + + // std::printf("returning\n"); + + return Ref(new DecoderResult(arrayOut, result)); +} + +Ref Decoder::getEncodedData(Ref correctedBits) { + int endIndex = codewordSize_ * ddata_->getNBDatablocks() - invertedBitCount_; + if (endIndex > (int)correctedBits->getSize()) { + // std::printf("invalid input\n"); + throw FormatException("invalid input data"); + } + + Table lastTable = UPPER; + Table table = UPPER; + int startIndex = 0; + std::string result; + bool end = false; + bool shift = false; + bool switchShift = false; + bool binaryShift = false; + + while (!end) { + // std::printf("decoooooding\n"); + + if (shift) { + switchShift = true; + } else { + lastTable = table; + } + + int code; + if (binaryShift) { + if (endIndex - startIndex < 5) { + break; + } + + int length = readCode(correctedBits, startIndex, 5); + startIndex += 5; + if (length == 0) { + if (endIndex - startIndex < 11) { + break; + } + + length = readCode(correctedBits, startIndex, 11) + 31; + startIndex += 11; + } + for (int charCount = 0; charCount < length; charCount++) { + if (endIndex - startIndex < 8) { + end = true; + break; + } + + code = readCode(correctedBits, startIndex, 8); + add(result, code); + startIndex += 8; + } + binaryShift = false; + } else { + if (table == BINARY) { + if (endIndex - startIndex < 8) { + end = true; + break; + } + code = readCode(correctedBits, startIndex, 8); + startIndex += 8; + + add(result, code); + } else { + int size = 5; + + if (table == DIGIT) { + size = 4; + } + + if (endIndex - startIndex < size) { + end = true; + break; + } + + code = readCode(correctedBits, startIndex, size); + startIndex += size; + + const char *str = getCharacter(table, code); + std::string string(str); + if ((int)string.find("CTRL_") != -1) { + table = getTable(str[5]); + + if (str[6] == 'S') { + shift = true; + if (str[5] == 'B') { + binaryShift = true; + } + } + } else { + result.append(string); + } + + } + } + + if (switchShift) { + table = lastTable; + shift = false; + switchShift = false; + } + + + } + + return Ref(new String(result)); + +} + +Ref Decoder::correctBits(Ref rawbits) { + //return rawbits; + // std::printf("decoding stuff:%d datablocks in %d layers\n", ddata_->getNBDatablocks(), ddata_->getNBLayers()); + + Ref gf = GenericGF::AZTEC_DATA_6; + + if (ddata_->getNBLayers() <= 2) { + codewordSize_ = 6; + gf = GenericGF::AZTEC_DATA_6; + } else if (ddata_->getNBLayers() <= 8) { + codewordSize_ = 8; + gf = GenericGF::AZTEC_DATA_8; + } else if (ddata_->getNBLayers() <= 22) { + codewordSize_ = 10; + gf = GenericGF::AZTEC_DATA_10; + } else { + codewordSize_ = 12; + gf = GenericGF::AZTEC_DATA_12; + } + + int numDataCodewords = ddata_->getNBDatablocks(); + int numECCodewords; + int offset; + + if (ddata_->isCompact()) { + offset = NB_BITS_COMPACT[ddata_->getNBLayers()] - numCodewords_ * codewordSize_; + numECCodewords = NB_DATABLOCK_COMPACT[ddata_->getNBLayers()] - numDataCodewords; + } else { + offset = NB_BITS[ddata_->getNBLayers()] - numCodewords_ * codewordSize_; + numECCodewords = NB_DATABLOCK[ddata_->getNBLayers()] - numDataCodewords; + } + + ArrayRef dataWords(numCodewords_); + + for (int i = 0; i < numCodewords_; i++) { + int flag = 1; + for (int j = 1; j <= codewordSize_; j++) { + if (rawbits->get(codewordSize_ * i + codewordSize_ - j + offset)) { + dataWords[i] += flag; + } + flag <<= 1; + } + + // + // + // + } + + try { + // std::printf("trying reed solomon, numECCodewords:%d\n", numECCodewords); + ReedSolomonDecoder rsDecoder(gf); + rsDecoder.decode(dataWords, numECCodewords); + } catch (ReedSolomonException rse) { + // std::printf("got reed solomon exception:%s, throwing formatexception\n", rse.what()); + throw FormatException("rs decoding failed"); + } catch (IllegalArgumentException iae) { + // std::printf("illegal argument exception: %s", iae.what()); + } + + offset = 0; + invertedBitCount_ = 0; + + Ref correctedBits(new BitArray(numDataCodewords * codewordSize_)); + for (int i = 0; i < numDataCodewords; i++) { + + bool seriesColor = false; + int seriesCount = 0; + int flag = 1 << (codewordSize_ - 1); + + for (int j = 0; j < codewordSize_; j++) { + + bool color = (dataWords[i] & flag) == flag; + + if (seriesCount == codewordSize_ - 1) { + + if (color == seriesColor) { + throw FormatException("bit was not inverted"); + } + + seriesColor = false; + seriesCount = 0; + offset++; + invertedBitCount_++; + + } else { + + if (seriesColor == color) { + seriesCount++; + } else { + seriesCount = 1; + seriesColor = color; + } + + if (color) correctedBits->set(i * codewordSize_ + j - offset); + + } + + flag = (unsigned int)flag >> 1; + + } + } + + return correctedBits; +} + +Ref Decoder::extractBits(Ref matrix) { + std::vector rawbits; + + if (ddata_->isCompact()) { + if (ddata_->getNBLayers() > 5) { //NB_BITS_COMPACT length + throw FormatException("data is too long"); + } + rawbits = std::vector(NB_BITS_COMPACT[ddata_->getNBLayers()]); + numCodewords_ = NB_DATABLOCK_COMPACT[ddata_->getNBLayers()]; + } else { + if (ddata_->getNBLayers() > 33) { //NB_BITS length + throw FormatException("data is too long"); + } + rawbits = std::vector(NB_BITS[ddata_->getNBLayers()]); + numCodewords_ = NB_DATABLOCK[ddata_->getNBLayers()]; + } + + int layer = ddata_->getNBLayers(); + int size = matrix->getHeight(); + int rawbitsOffset = 0; + int matrixOffset = 0; + + + while (layer != 0) { + + int flip = 0; + for (int i = 0; i < 2 * size - 4; i++) { + rawbits[rawbitsOffset + i] = matrix->get(matrixOffset + flip, matrixOffset + i / 2); + rawbits[rawbitsOffset + 2 * size - 4 + i] = matrix->get(matrixOffset + i / 2, matrixOffset + size - 1 - flip); + flip = (flip + 1) % 2; + } + + flip = 0; + for (int i = 2 * size + 1; i > 5; i--) { + rawbits[rawbitsOffset + 4 * size - 8 + (2 * size - i) + 1] = + matrix->get(matrixOffset + size - 1 - flip, matrixOffset + i / 2 - 1); + rawbits[rawbitsOffset + 6 * size - 12 + (2 * size - i) + 1] = + matrix->get(matrixOffset + i / 2 - 1, matrixOffset + flip); + flip = (flip + 1) % 2; + } + + matrixOffset += 2; + rawbitsOffset += 8 * size - 16; + layer--; + size -= 4; + + } + + Ref returnValue(new BitArray(rawbits.size())); + for (int i = 0; i < (int)rawbits.size(); i++) { + if (rawbits[i]) returnValue->set(i); + } + + return returnValue; + +} + +Ref Decoder::removeDashedLines(Ref matrix) { + int nbDashed = 1 + 2 * ((matrix->getWidth() - 1) / 2 / 16); + Ref newMatrix(new BitMatrix(matrix->getWidth() - nbDashed, matrix->getHeight() - nbDashed)); + + int nx = 0; + + for (int x = 0; x < (int)matrix->getWidth(); x++) { + + if ((matrix->getWidth() / 2 - x) % 16 == 0) { + continue; + } + + int ny = 0; + for (int y = 0; y < (int)matrix->getHeight(); y++) { + + if ((matrix->getWidth() / 2 - y) % 16 == 0) { + continue; + } + + if (matrix->get(x, y)) { + newMatrix->set(nx, ny); + } + ny++; + + } + nx++; + + } + return newMatrix; +} + +int Decoder::readCode(Ref rawbits, int startIndex, int length) { + int res = 0; + + for (int i = startIndex; i < startIndex + length; i++) { + res <<= 1; + if (rawbits->get(i)) { + res ++; + } + } + + return res; +} diff --git a/cpp/core/src/zxing/aztec/decoder/Decoder.h b/cpp/core/src/zxing/aztec/decoder/Decoder.h new file mode 100644 index 000000000..a6f8d936c --- /dev/null +++ b/cpp/core/src/zxing/aztec/decoder/Decoder.h @@ -0,0 +1,63 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * Decoder.h + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +namespace zxing { + namespace aztec { + + class Decoder : public Counted { + private: + enum Table { + UPPER, + LOWER, + MIXED, + DIGIT, + PUNCT, + BINARY + }; + + static Table getTable(char t); + static const char* getCharacter(Table table, int code); + + int numCodewords_; + int codewordSize_; + Ref ddata_; + int invertedBitCount_; + + Ref getEncodedData(Ref correctedBits); + Ref correctBits(Ref rawbits); + Ref extractBits(Ref matrix); + static Ref removeDashedLines(Ref matrix); + static int readCode(Ref rawbits, int startIndex, int length); + + + public: + Decoder(); + Ref decode(Ref detectorResult); + }; + + } +} + diff --git a/cpp/core/src/zxing/aztec/detector/Detector.cpp b/cpp/core/src/zxing/aztec/detector/Detector.cpp new file mode 100644 index 000000000..92bb55f5d --- /dev/null +++ b/cpp/core/src/zxing/aztec/detector/Detector.cpp @@ -0,0 +1,554 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * Detector.cpp + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using zxing::aztec::Detector; +using zxing::aztec::Point; +using zxing::aztec::AztecDetectorResult; +using zxing::Ref; +using zxing::ResultPoint; +using zxing::BitArray; +using zxing::BitMatrix; + +Detector::Detector(Ref image): + image_(image), + nbLayers_(0), + nbDataBlocks_(0), + nbCenterLayers_(0) { + +} + +// using namespace std; + +Ref Detector::detect() { + Ref pCenter = getMatrixCenter(); + + std::vector > bullEyeCornerPoints = getBullEyeCornerPoints(pCenter); + + extractParameters(bullEyeCornerPoints); + + std::vector > corners = getMatrixCornerPoints(bullEyeCornerPoints); + + Ref bits = sampleGrid(image_, corners[shift_%4], corners[(shift_+3)%4], corners[(shift_+2)%4], corners[(shift_+1)%4]); + + // std::printf("------------\ndetected: compact:%s, nbDataBlocks:%d, nbLayers:%d\n------------\n",compact_?"YES":"NO", nbDataBlocks_, nbLayers_); + + return Ref(new AztecDetectorResult(bits, corners, compact_, nbDataBlocks_, nbLayers_)); +} + +void Detector::extractParameters(std::vector > bullEyeCornerPoints) { + // get the bits around the bull's eye + Ref resab = sampleLine(bullEyeCornerPoints[0], bullEyeCornerPoints[1], 2*nbCenterLayers_+1); + Ref resbc = sampleLine(bullEyeCornerPoints[1], bullEyeCornerPoints[2], 2*nbCenterLayers_+1); + Ref rescd = sampleLine(bullEyeCornerPoints[2], bullEyeCornerPoints[3], 2*nbCenterLayers_+1); + Ref resda = sampleLine(bullEyeCornerPoints[3], bullEyeCornerPoints[0], 2*nbCenterLayers_+1); + + // determin the orientation of the matrix + if (resab->get(0) && resab->get(2 * nbCenterLayers_)) { + shift_ = 0; + } else if (resbc->get(0) && resbc->get(2 * nbCenterLayers_)) { + shift_ = 1; + } else if (rescd->get(0) && rescd->get(2 * nbCenterLayers_)) { + shift_ = 2; + } else if (resda->get(0) && resda->get(2 * nbCenterLayers_)) { + shift_ = 3; + } else { + // std::printf("could not detemine orientation\n"); + throw ReaderException("could not determine orientation"); + } + + //d a + // + //c b + + //flatten the bits in a single array + Ref parameterData(new BitArray(compact_?28:40)); + Ref shiftedParameterData(new BitArray(compact_?28:40)); + + if (compact_) { + for (int i = 0; i < 7; i++) { + if (resab->get(2+i)) shiftedParameterData->set(i); + if (resbc->get(2+i)) shiftedParameterData->set(i+7); + if (rescd->get(2+i)) shiftedParameterData->set(i+14); + if (resda->get(2+i)) shiftedParameterData->set(i+21); + } + for (int i = 0; i < 28; i++) { + if (shiftedParameterData->get((i+shift_*7)%28)) parameterData->set(i); + } + + } else { + for (int i = 0; i < 11; i++) { + if (i < 5) { + if (resab->get(2+i)) shiftedParameterData->set(i); + if (resbc->get(2+i)) shiftedParameterData->set(i+10); + if (rescd->get(2+i)) shiftedParameterData->set(i+20); + if (resda->get(2+i)) shiftedParameterData->set(i+30); + } + if (i > 5) { + if (resab->get(2+i)) shiftedParameterData->set(i-1); + if (resbc->get(2+i)) shiftedParameterData->set(i+10-1); + if (rescd->get(2+i)) shiftedParameterData->set(i+20-1); + if (resda->get(2+i)) shiftedParameterData->set(i+30-1); + } + } + for (int i = 0; i < 40; i++) { + if (shiftedParameterData->get((i+shift_*10)%40)) parameterData->set(i); + } + } + + correctParameterData(parameterData, compact_); + + getParameters(parameterData); +} + +std::vector > Detector::getMatrixCornerPoints(std::vector > bullEyeCornerPoints) { + float ratio = (2 * nbLayers_ + (nbLayers_ > 4 ? 1 : 0) + (nbLayers_ - 4) / 8) / (2.0f * nbCenterLayers_); + + int dx = bullEyeCornerPoints[0]->x - bullEyeCornerPoints[2]->x; + dx += dx > 0 ? 1 : -1; + int dy = bullEyeCornerPoints[0]->y - bullEyeCornerPoints[2]->y; + dy += dy > 0 ? 1 : -1; + + int targetcx = ROUND(bullEyeCornerPoints[2]->x - ratio * dx); + int targetcy = ROUND(bullEyeCornerPoints[2]->y - ratio * dy); + + int targetax = ROUND(bullEyeCornerPoints[0]->x + ratio * dx); + int targetay = ROUND(bullEyeCornerPoints[0]->y + ratio * dy); + + dx = bullEyeCornerPoints[1]->x - bullEyeCornerPoints[3]->x; + dx += dx > 0 ? 1 : -1; + dy = bullEyeCornerPoints[1]->y - bullEyeCornerPoints[3]->y; + dy += dy > 0 ? 1 : -1; + + int targetdx = ROUND(bullEyeCornerPoints[3]->x - ratio * dx); + int targetdy = ROUND(bullEyeCornerPoints[3]->y - ratio * dy); + int targetbx = ROUND(bullEyeCornerPoints[1]->x + ratio * dx); + int targetby = ROUND(bullEyeCornerPoints[1]->y + ratio * dy); + + if (!isValid(targetax, targetay) || + !isValid(targetbx, targetby) || + !isValid(targetcx, targetcy) || + !isValid(targetdx, targetdy)) { + throw ReaderException("matrix extends over image bounds"); + } + std::vector > returnValue; + returnValue.push_back(Ref(new ResultPoint(targetax, targetay))); + returnValue.push_back(Ref(new ResultPoint(targetbx, targetby))); + returnValue.push_back(Ref(new ResultPoint(targetcx, targetcy))); + returnValue.push_back(Ref(new ResultPoint(targetdx, targetdy))); + + return returnValue; + +} + +void Detector::correctParameterData(Ref parameterData, bool compact) { + int numCodewords; + int numDataCodewords; + + if (compact) { + numCodewords = 7; + numDataCodewords = 2; + } else { + numCodewords = 10; + numDataCodewords = 4; + } + + int numECCodewords = numCodewords - numDataCodewords; + + ArrayRef parameterWords(new Array(numCodewords)); + + int codewordSize = 4; + for (int i = 0; i < numCodewords; i++) { + int flag = 1; + for (int j = 1; j <= codewordSize; j++) { + if (parameterData->get(codewordSize*i + codewordSize - j)) { + parameterWords[i] += flag; + } + flag <<= 1; + } + } + + try { + // std::printf("parameter data reed solomon\n"); + ReedSolomonDecoder rsDecoder(GenericGF::AZTEC_PARAM); + rsDecoder.decode(parameterWords, numECCodewords); + } catch (ReedSolomonException e) { + // std::printf("reed solomon decoding failed\n"); + throw ReaderException("failed to decode parameter data"); + } + + parameterData->clear(); + for (int i = 0; i < numDataCodewords; i++) { + int flag = 1; + for (int j = 1; j <= codewordSize; j++) { + if ((parameterWords[i] & flag) == flag) { + parameterData->set(i*codewordSize+codewordSize-j); + } + flag <<= 1; + } + } +} + +std::vector > Detector::getBullEyeCornerPoints(Ref pCenter) { + Ref pina = pCenter; + Ref pinb = pCenter; + Ref pinc = pCenter; + Ref pind = pCenter; + + bool color = true; + + for (nbCenterLayers_ = 1; nbCenterLayers_ < 9; nbCenterLayers_++) { + Ref pouta = getFirstDifferent(pina, color, 1, -1); + Ref poutb = getFirstDifferent(pinb, color, 1, 1); + Ref poutc = getFirstDifferent(pinc, color, -1, 1); + Ref poutd = getFirstDifferent(pind, color, -1, -1); + + //d a + // + //c b + + if (nbCenterLayers_ > 2) { + float q = distance(poutd, pouta) * nbCenterLayers_ / (distance(pind, pina) * (nbCenterLayers_ + 2)); + if (q < 0.75 || q > 1.25 || !isWhiteOrBlackRectangle(pouta, poutb, poutc, poutd)) { + break; + } + } + + pina = pouta; + pinb = poutb; + pinc = poutc; + pind = poutd; + + color = !color; + } + + if (nbCenterLayers_ != 5 && nbCenterLayers_ != 7) { + throw ReaderException("encountered wrong bullseye ring count"); + } + + compact_ = nbCenterLayers_ == 5; + + + + float ratio = 0.75f*2 / (2*nbCenterLayers_-3); + + int dx = pina->x - pind->x; + int dy = pina->y - pinc->y; + + int targetcx = ROUND(pinc->x - ratio * dx); + int targetcy = ROUND(pinc->y - ratio * dy); + int targetax = ROUND(pina->x + ratio * dx); + int targetay = ROUND(pina->y + ratio * dy); + + dx = pinb->x - pind->x; + dy = pinb->y - pind->y; + + int targetdx = ROUND(pind->x - ratio * dx); + int targetdy = ROUND(pind->y - ratio * dy); + int targetbx = ROUND(pinb->x + ratio * dx); + int targetby = ROUND(pinb->y + ratio * dy); + + if (!isValid(targetax, targetay) || + !isValid(targetbx, targetby) || + !isValid(targetcx, targetcy) || + !isValid(targetdx, targetdy)) { + throw ReaderException("bullseye extends over image bounds"); + } + + std::vector > returnValue; + returnValue.push_back(Ref(new Point(targetax, targetay))); + returnValue.push_back(Ref(new Point(targetbx, targetby))); + returnValue.push_back(Ref(new Point(targetcx, targetcy))); + returnValue.push_back(Ref(new Point(targetdx, targetdy))); + + return returnValue; + +} + +Ref Detector::getMatrixCenter() { + Ref pointA, pointB, pointC, pointD; + try { + + std::vector > cornerPoints = WhiteRectangleDetector(image_).detect(); + pointA = cornerPoints[0]; + pointB = cornerPoints[1]; + pointC = cornerPoints[2]; + pointD = cornerPoints[3]; + + } catch (NotFoundException e) { + + int cx = image_->getWidth() / 2; + int cy = image_->getHeight() / 2; + + pointA = getFirstDifferent(Ref(new Point(cx+15/2, cy-15/2)), false, 1, -1)->toResultPoint(); + pointB = getFirstDifferent(Ref(new Point(cx+15/2, cy+15/2)), false, 1, 1)->toResultPoint(); + pointC = getFirstDifferent(Ref(new Point(cx-15/2, cy+15/2)), false, -1, -1)->toResultPoint(); + pointD = getFirstDifferent(Ref(new Point(cx-15/2, cy-15/2)), false, -1, -1)->toResultPoint(); + + } + + int cx = ROUND((pointA->getX() + pointD->getX() + pointB->getX() + pointC->getX()) / 4); + int cy = ROUND((pointA->getY() + pointD->getY() + pointB->getY() + pointC->getY()) / 4); + + try { + + std::vector > cornerPoints = WhiteRectangleDetector(image_, 15, cx, cy).detect(); + pointA = cornerPoints[0]; + pointB = cornerPoints[1]; + pointC = cornerPoints[2]; + pointD = cornerPoints[3]; + + } catch (NotFoundException e) { + + pointA = getFirstDifferent(Ref(new Point(cx+15/2, cy-15/2)), false, 1, -1)->toResultPoint(); + pointB = getFirstDifferent(Ref(new Point(cx+15/2, cy+15/2)), false, 1, 1)->toResultPoint(); + pointC = getFirstDifferent(Ref(new Point(cx-15/2, cy+15/2)), false, -1, -1)->toResultPoint(); + pointD = getFirstDifferent(Ref(new Point(cx-15/2, cy-15/2)), false, -1, -1)->toResultPoint(); + + } + + cx = ROUND((pointA->getX() + pointD->getX() + pointB->getX() + pointC->getX()) / 4); + cy = ROUND((pointA->getY() + pointD->getY() + pointB->getY() + pointC->getY()) / 4); + + return Ref(new Point(cx, cy)); + +} + +Ref Detector::sampleGrid(Ref image, + Ref topLeft, + Ref bottomLeft, + Ref bottomRight, + Ref topRight) { + int dimension; + if (compact_) { + dimension = 4 * nbLayers_+11; + } else { + if (nbLayers_ <= 4) { + dimension = 4 * nbLayers_ + 15; + } else { + dimension = 4 * nbLayers_ + 2 * ((nbLayers_-4)/8 + 1) + 15; + } + } + + GridSampler sampler = GridSampler::getInstance(); + + return sampler.sampleGrid(image, + dimension, + 0.5f, + 0.5f, + dimension - 0.5f, + 0.5f, + dimension - 0.5f, + dimension - 0.5f, + 0.5f, + dimension - 0.5f, + topLeft->getX(), + topLeft->getY(), + topRight->getX(), + topRight->getY(), + bottomRight->getX(), + bottomRight->getY(), + bottomLeft->getX(), + bottomLeft->getY()); +} + +void Detector::getParameters(Ref parameterData) { + + if (false) { + printf("getting parameters from: "); + for (int i = 0; i < (int)parameterData->getSize(); i++) { + if (parameterData->get(i)) { + printf("1"); + } else { + printf("0"); + } + } + printf("\n"); + } + + nbLayers_ = 0; + nbDataBlocks_ = 0; + + int nbBitsForNbLayers; + int nbBitsForNbDatablocks; + + if (compact_) { + nbBitsForNbLayers = 2; + nbBitsForNbDatablocks = 6; + } else { + nbBitsForNbLayers = 5; + nbBitsForNbDatablocks = 11; + } + + for (int i = 0; i < nbBitsForNbLayers; i++) { + nbLayers_ <<= 1; + if (parameterData->get(i)) { + nbLayers_ += 1; + } + } + + for (int i = nbBitsForNbLayers; i < nbBitsForNbLayers + nbBitsForNbDatablocks; i++) { + nbDataBlocks_ <<= 1; + if (parameterData->get(i)) { + nbDataBlocks_ += 1; + } + } + + nbLayers_ ++; + nbDataBlocks_ ++; +} + +Ref Detector::sampleLine(Ref p1, Ref p2, int size) { + Ref res(new BitArray(size)); + + float d = distance(p1, p2); + float moduleSize = d / (size-1); + float dx = moduleSize * (p2->x - p1->x)/d; + float dy = moduleSize * (p2->y - p1->y)/d; + + float px = p1->x; + float py = p1->y; + + for (int i = 0; i < size; i++) { + if (image_->get(ROUND(px), ROUND(py))) res->set(i); + px += dx; + py += dy; + } + + return res; +} + +bool Detector::isWhiteOrBlackRectangle(Ref p1, + Ref p2, + Ref p3, + Ref p4) { + int corr = 3; + + p1 = new Point(p1->x - corr, p1->y + corr); + p2 = new Point(p2->x - corr, p2->y - corr); + p3 = new Point(p3->x + corr, p3->y - corr); + p4 = new Point(p4->x + corr, p4->y + corr); + + int cInit = getColor(p4, p1); + + if (cInit == 0) { + return false; + } + + int c = getColor(p1, p2); + + if (c != cInit) { + return false; + } + + c = getColor(p2, p3); + + if (c != cInit) { + return false; + } + + c = getColor(p3, p4); + + if (c != cInit) { + return false; + } + + return true; +} + +int Detector::getColor(Ref p1, Ref p2) { + float d = distance(p1, p2); + + float dx = (p2->x - p1->x) / d; + float dy = (p2->y - p1->y) / d; + + int error = 0; + + float px = p1->x; + float py = p1->y; + + bool colorModel = image_->get(p1->x, p1->y); + + for (int i = 0; i < d; i++) { + px += dx; + py += dy; + if (image_->get(ROUND(px), ROUND(py)) != colorModel) { + error ++; + } + } + + float errRatio = (float)error/d; + + + if (errRatio > 0.1 && errRatio < 0.9) { + return 0; + } + + if (errRatio <= 0.1) { + return colorModel?1:-1; + } else { + return colorModel?-1:1; + } +} + +Ref Detector::getFirstDifferent(Ref init, bool color, int dx, int dy) { + int x = init->x + dx; + int y = init->y + dy; + + while (isValid(x, y) && image_->get(x, y) == color) { + x += dx; + y += dy; + } + + x -= dx; + y -= dy; + + while (isValid(x, y) && image_->get(x, y) == color) { + x += dx; + } + + x -= dx; + + while (isValid(x, y) && image_->get(x, y) == color) { + y += dy; + } + + y -= dy; + + return Ref(new Point(x, y)); +} + +bool Detector::isValid(int x, int y) { + return x >= 0 && x < (int)image_->getWidth() && y > 0 && y < (int)image_->getHeight(); +} + +float Detector::distance(Ref a, Ref b) { + return sqrtf((float)((a->x - b->x) * (a->x - b->x) + (a->y - b->y) * (a->y - b->y))); +} diff --git a/cpp/core/src/zxing/aztec/detector/Detector.h b/cpp/core/src/zxing/aztec/detector/Detector.h new file mode 100644 index 000000000..8b10853a1 --- /dev/null +++ b/cpp/core/src/zxing/aztec/detector/Detector.h @@ -0,0 +1,87 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * Detector.h + * zxing + * + * Created by Lukas Stabe on 08/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include + +#include +#include +#include +#include +#include + +#define ROUND(a) ((int)(a + 0.5f)) + +namespace zxing { + namespace aztec { + + class Point : public Counted { + public: + int x; + int y; + + Ref toResultPoint() { + return Ref(new ResultPoint(x, y)); + } + + Point(int ax, int ay):x(ax),y(ay) {}; + + }; + + class Detector : public Counted { + + private: + Ref image_; + + bool compact_; + int nbLayers_; + int nbDataBlocks_; + int nbCenterLayers_; + int shift_; + + void extractParameters(std::vector > bullEyeCornerPoints); + std::vector > getMatrixCornerPoints(std::vector > bullEyeCornerPoints); + static void correctParameterData(Ref parameterData, bool compact); + std::vector > getBullEyeCornerPoints(Ref pCenter); + Ref getMatrixCenter(); + Ref sampleGrid(Ref image, + Ref topLeft, + Ref bottomLeft, + Ref bottomRight, + Ref topRight); + void getParameters(Ref parameterData); + Ref sampleLine(Ref p1, Ref p2, int size); + bool isWhiteOrBlackRectangle(Ref p1, + Ref p2, + Ref p3, + Ref p4); + int getColor(Ref p1, Ref p2); + Ref getFirstDifferent(Ref init, bool color, int dx, int dy); + bool isValid(int x, int y); + static float distance(Ref a, Ref b); + + public: + Detector(Ref image); + Ref detect(); + }; + + } +} diff --git a/cpp/core/src/zxing/common/DetectorResult.cpp b/cpp/core/src/zxing/common/DetectorResult.cpp index 0769137de..c13898346 100644 --- a/cpp/core/src/zxing/common/DetectorResult.cpp +++ b/cpp/core/src/zxing/common/DetectorResult.cpp @@ -23,8 +23,8 @@ namespace zxing { -DetectorResult::DetectorResult(Ref bits, std::vector > points, Ref transform) : - bits_(bits), points_(points), transform_(transform) { +DetectorResult::DetectorResult(Ref bits, std::vector > points) : + bits_(bits), points_(points) { } Ref DetectorResult::getBits() { @@ -35,8 +35,4 @@ std::vector > DetectorResult::getPoints() { return points_; } -Ref DetectorResult::getTransform() { - return transform_; -} - } diff --git a/cpp/core/src/zxing/common/DetectorResult.h b/cpp/core/src/zxing/common/DetectorResult.h index 945848e0e..ebf5910cc 100644 --- a/cpp/core/src/zxing/common/DetectorResult.h +++ b/cpp/core/src/zxing/common/DetectorResult.h @@ -25,7 +25,6 @@ #include #include #include -#include namespace zxing { @@ -33,13 +32,11 @@ class DetectorResult : public Counted { private: Ref bits_; std::vector > points_; - Ref transform_; public: - DetectorResult(Ref bits, std::vector > points, Ref transform); + DetectorResult(Ref bits, std::vector > points); Ref getBits(); std::vector > getPoints(); - Ref getTransform(); }; } diff --git a/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp b/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp index 87b409957..4decd31ab 100644 --- a/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp +++ b/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp @@ -33,6 +33,30 @@ int WhiteRectangleDetector::CORR = 1; WhiteRectangleDetector::WhiteRectangleDetector(Ref image) : image_(image) { width_ = image->getWidth(); height_ = image->getHeight(); + + leftInit_ = (width_ - INIT_SIZE) >> 1; + rightInit_ = (width_ + INIT_SIZE) >> 1; + upInit_ = (height_ - INIT_SIZE) >> 1; + downInit_ = (height_ + INIT_SIZE) >> 1; + + if (upInit_ < 0 || leftInit_ < 0 || downInit_ >= height_ || rightInit_ >= width_) { + throw NotFoundException("Invalid dimensions WhiteRectangleDetector"); +} +} + +WhiteRectangleDetector::WhiteRectangleDetector(Ref image, int initSize, int x, int y) : image_(image) { + width_ = image->getWidth(); + height_ = image->getHeight(); + + int halfsize = initSize >> 1; + leftInit_ = x - halfsize; + rightInit_ = x + halfsize; + upInit_ = y - halfsize; + downInit_ = y + halfsize; + + if (upInit_ < 0 || leftInit_ < 0 || downInit_ >= height_ || rightInit_ >= width_) { + throw NotFoundException("Invalid dimensions WhiteRectangleDetector"); + } } /** @@ -50,13 +74,10 @@ WhiteRectangleDetector::WhiteRectangleDetector(Ref image) : image_(im * @throws NotFoundException if no Data Matrix Code can be found */ std::vector > WhiteRectangleDetector::detect() { - int left = (width_ - INIT_SIZE) >> 1; - int right = (width_ + INIT_SIZE) >> 1; - int up = (height_ - INIT_SIZE) >> 1; - int down = (height_ + INIT_SIZE) >> 1; - if (up < 0 || left < 0 || down >= height_ || right >= width_) { - throw NotFoundException("Invalid dimensions WhiteRectangleDetector"); - } + int left = leftInit_; + int right = rightInit_; + int up = upInit_; + int down = downInit_; bool sizeExceeded = false; bool aBlackPointFoundOnBorder = true; diff --git a/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.h b/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.h index 87de26a6b..2a8b8a4ff 100644 --- a/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.h +++ b/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.h @@ -38,9 +38,14 @@ class WhiteRectangleDetector : public Counted { Ref image_; int width_; int height_; + int leftInit_; + int rightInit_; + int downInit_; + int upInit_; public: WhiteRectangleDetector(Ref image); + WhiteRectangleDetector(Ref image, int initSize, int x, int y); std::vector > detect(); private: diff --git a/cpp/core/src/zxing/common/reedsolomon/GF256.cpp b/cpp/core/src/zxing/common/reedsolomon/GF256.cpp deleted file mode 100644 index 51b621e8e..000000000 --- a/cpp/core/src/zxing/common/reedsolomon/GF256.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * GF256.cpp - * zxing - * - * Created by Christian Brunschen on 05/05/2008. - * Copyright 2008 Google UK. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -namespace zxing { -using namespace std; - -static inline ArrayRef makeArray(int value) { - ArrayRef valuesRef(new Array (value, 1)); - return valuesRef; -} - -static inline Ref refPoly(GF256 &field, int value) { - ArrayRef values(makeArray(value)); - Ref result(new GF256Poly(field, values)); - return result; -} - -GF256::GF256(int primitive) : - exp_(256, (const int)0), log_(256, (const int)0), zero_(refPoly(*this, 0)), one_(refPoly(*this, 1)) { - int x = 1; - for (int i = 0; i < 256; i++) { - exp_[i] = x; - x <<= 1; - if (x >= 0x100) { - x ^= primitive; - } - } - - // log(0) == 0, but should never be used - log_[0] = 0; - for (int i = 0; i < 255; i++) { - log_[exp_[i]] = i; - } -} - -Ref GF256::getZero() { - return zero_; -} - -Ref GF256::getOne() { - return one_; -} - -Ref GF256::buildMonomial(int degree, int coefficient) { -#ifdef DEBUG - cout << __FUNCTION__ << "\n"; -#endif - if (degree < 0) { - throw IllegalArgumentException("Degree must be non-negative"); - } - if (coefficient == 0) { - return zero_; - } - int nCoefficients = degree + 1; - ArrayRef coefficients(new Array (nCoefficients)); - coefficients[0] = coefficient; - Ref result(new GF256Poly(*this, coefficients)); - return result; -} - -int GF256::addOrSubtract(int a, int b) { - return a ^ b; -} - -int GF256::exp(int a) { - return exp_[a]; -} - -int GF256::log(int a) { - if (a == 0) { - throw IllegalArgumentException("Cannot take the logarithm of 0"); - } - return log_[a]; -} - -int GF256::inverse(int a) { - if (a == 0) { - throw IllegalArgumentException("Cannot calculate the inverse of 0"); - } - return exp_[255 - log_[a]]; -} - -int GF256::multiply(int a, int b) { - if (a == 0 || b == 0) { - return 0; - } - int logSum = log_[a] + log_[b]; - // index is a sped-up alternative to logSum % 255 since sum - // is in [0,510]. Thanks to jmsachs for the idea - return exp_[(logSum & 0xFF) + (logSum >> 8)]; -} - -GF256 GF256::QR_CODE_FIELD(0x011D); // x^8 + x^4 + x^3 + x^2 + 1 -GF256 GF256::DATA_MATRIX_FIELD(0x012D); // x^8 + x^5 + x^3 + x^2 + 1 - -ostream& operator<<(ostream& out, const GF256& field) { - out << "Field[\nexp=("; - out << field.exp_[0]; - for (int i = 1; i < 256; i++) { - out << "," << field.exp_[i]; - } - out << "),\nlog=("; - out << field.log_[0]; - for (int i = 1; i < 256; i++) { - out << "," << field.log_[i]; - } - out << ")\n]"; - return out; -} - -} diff --git a/cpp/core/src/zxing/common/reedsolomon/GF256.h b/cpp/core/src/zxing/common/reedsolomon/GF256.h deleted file mode 100644 index 821fba505..000000000 --- a/cpp/core/src/zxing/common/reedsolomon/GF256.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __GF256_H__ -#define __GF256_H__ - -/* - * GF256.h - * zxing - * - * Copyright 2010 ZXing authors All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -namespace zxing { -class GF256Poly; - -class GF256 { - /** - *

This class contains utility methods for performing mathematical - * operations over the Galois Field GF(256). Operations use a given - * primitive polynomial in calculations.

- * - *

Throughout this package, elements of GF(256) are represented as an - * int for convenience and speed (but at the cost of memory). - * Only the bottom 8 bits are really used.

- * - * @author srowen@google.com (Sean Owen) - * @author christian.brunschen@gmail.com (Christian Brunschen) - */ -private: - std::vector exp_; - std::vector log_; - Ref zero_; - Ref one_; - - GF256(int primitive); - -public: - Ref getZero(); - Ref getOne(); - Ref buildMonomial(int degree, int coefficient); - static int addOrSubtract(int a, int b); - int exp(int a); - int log(int a); - int inverse(int a); - int multiply(int a, int b); - - static GF256 QR_CODE_FIELD; - static GF256 DATA_MATRIX_FIELD; - - friend std::ostream& operator<<(std::ostream& out, const GF256& field); -}; -} - -#endif // __GF256_H__ diff --git a/cpp/core/src/zxing/common/reedsolomon/GF256Poly.cpp b/cpp/core/src/zxing/common/reedsolomon/GF256Poly.cpp deleted file mode 100644 index 2c7f4812e..000000000 --- a/cpp/core/src/zxing/common/reedsolomon/GF256Poly.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - * GF256Poly.cpp - * zxing - * - * Created by Christian Brunschen on 05/05/2008. - * Copyright 2008 Google UK. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -namespace zxing { -using namespace std; - -void GF256Poly::fixCoefficients() { - int coefficientsLength = coefficients.size(); - if (coefficientsLength > 1 && coefficients[0] == 0) { - // Leading term must be non-zero for anything except - // the constant polynomial "0" - int firstNonZero = 1; - while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - coefficientsLength = field.getZero()->coefficients.size(); - coefficients.reset(new Array (coefficientsLength)); - *coefficients = *(field.getZero()->coefficients); - } else { - ArrayRef c(coefficients); - coefficientsLength -= firstNonZero; - coefficients.reset(new Array (coefficientsLength)); - for (int i = 0; i < coefficientsLength; i++) { - coefficients[i] = c[i + firstNonZero]; - } - } - } -} - -GF256Poly::GF256Poly(GF256 &f, ArrayRef c) : - Counted(), field(f), coefficients(c) { - fixCoefficients(); -} - -GF256Poly::~GF256Poly() { - -} - -int GF256Poly::getDegree() { - return coefficients.size() - 1; -} - -bool GF256Poly::isZero() { - return coefficients[0] == 0; -} - -int GF256Poly::getCoefficient(int degree) { - return coefficients[coefficients.size() - 1 - degree]; -} - -int GF256Poly::evaluateAt(int a) { - if (a == 0) { - return getCoefficient(0); - } - int size = coefficients.size(); - if (a == 1) { - // Just the sum of the coefficients - int result = 0; - for (int i = 0; i < size; i++) { - result = GF256::addOrSubtract(result, coefficients[i]); - } - return result; - } - int result = coefficients[0]; - for (int i = 1; i < size; i++) { - result = GF256::addOrSubtract(field.multiply(a, result), coefficients[i]); - } - return result; -} - -Ref GF256Poly::addOrSubtract(Ref b) { - if (&field != &b->field) { - throw IllegalArgumentException("Fields must be the same"); - } - if (isZero()) { - return b; - } - if (b->isZero()) { - return Ref(this); - } - - ArrayRef largerCoefficients = coefficients; - ArrayRef smallerCoefficients = b->coefficients; - if (smallerCoefficients.size() > largerCoefficients.size()) { - ArrayRef tmp(smallerCoefficients); - smallerCoefficients = largerCoefficients; - largerCoefficients = tmp; - } - - ArrayRef sumDiff(new Array (largerCoefficients.size())); - - unsigned lengthDiff = largerCoefficients.size() - smallerCoefficients.size(); - for (unsigned i = 0; i < lengthDiff; i++) { - sumDiff[i] = largerCoefficients[i]; - } - for (unsigned i = lengthDiff; i < largerCoefficients.size(); i++) { - sumDiff[i] = GF256::addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); - } - return Ref(new GF256Poly(field, sumDiff)); -} - -Ref GF256Poly::multiply(Ref b) { - if (&field != &b->field) { - throw IllegalArgumentException("Fields must be the same"); - } - if (isZero() || b->isZero()) { - return field.getZero(); - } - ArrayRef aCoefficients = coefficients; - int aLength = aCoefficients.size(); - ArrayRef bCoefficients = b->coefficients; - int bLength = bCoefficients.size(); - int productLength = aLength + bLength - 1; - ArrayRef product(new Array (productLength)); - for (int i = 0; i < aLength; i++) { - int aCoeff = aCoefficients[i]; - for (int j = 0; j < bLength; j++) { - product[i + j] = GF256::addOrSubtract(product[i + j], field.multiply(aCoeff, bCoefficients[j])); - } - } - - return Ref(new GF256Poly(field, product)); -} - -Ref GF256Poly::multiply(int scalar) { - if (scalar == 0) { - return field.getZero(); - } - if (scalar == 1) { - return Ref(this); - } - int size = coefficients.size(); - ArrayRef product(new Array (size)); - for (int i = 0; i < size; i++) { - product[i] = field.multiply(coefficients[i], scalar); - } - return Ref(new GF256Poly(field, product)); -} - -Ref GF256Poly::multiplyByMonomial(int degree, int coefficient) { - if (degree < 0) { - throw IllegalArgumentException("Degree must be non-negative"); - } - if (coefficient == 0) { - return field.getZero(); - } - int size = coefficients.size(); - ArrayRef product(new Array (size + degree)); - for (int i = 0; i < size; i++) { - product[i] = field.multiply(coefficients[i], coefficient); - } - return Ref(new GF256Poly(field, product)); -} - -const char *GF256Poly::description() const { - ostringstream result; - result << *this; - return result.str().c_str(); -} - -ostream& operator<<(ostream& out, const GF256Poly& p) { - GF256Poly &poly = const_cast(p); - out << "Poly[" << poly.coefficients.size() << "]"; - if (poly.coefficients.size() > 0) { - out << "(" << poly.coefficients[0]; - for (unsigned i = 1; i < poly.coefficients.size(); i++) { - out << "," << poly.coefficients[i]; - } - out << ")"; - } - return out; -} - -} diff --git a/cpp/core/src/zxing/common/reedsolomon/GF256Poly.h b/cpp/core/src/zxing/common/reedsolomon/GF256Poly.h deleted file mode 100644 index 0397be60b..000000000 --- a/cpp/core/src/zxing/common/reedsolomon/GF256Poly.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __GF256_POLY_H__ -#define __GF256_POLY_H__ - -/* - * GF256Poly.h - * zxing - * - * Copyright 2010 ZXing authors All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -namespace zxing { -class GF256; - -class GF256Poly : public Counted { -private: - GF256 &field; - ArrayRef coefficients; - void fixCoefficients(); -public: - GF256Poly(GF256 &field, ArrayRef c); - ~GF256Poly(); - - int getDegree(); - bool isZero(); - int getCoefficient(int degree); - int evaluateAt(int a); - Ref addOrSubtract(Ref other); - Ref multiply(Ref other); - Ref multiply(int scalar); - Ref multiplyByMonomial(int degree, int coefficient); - const char *description() const; - friend std::ostream& operator<<(std::ostream& out, const GF256Poly& poly); - -}; -} - -#endif // __GF256_POLY_H__ diff --git a/cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp b/cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp new file mode 100644 index 000000000..1485f3bf3 --- /dev/null +++ b/cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp @@ -0,0 +1,153 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * GenericGF.cpp + * zxing + * + * Created by Lukas Stabe on 13/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +using zxing::GenericGF; +using zxing::GenericGFPoly; +using zxing::Ref; + +Ref GenericGF::QR_CODE_FIELD_256(new GenericGF(0x011D, 256)); +Ref GenericGF::DATA_MATRIX_FIELD_256(new GenericGF(0x012D, 256)); +Ref GenericGF::AZTEC_PARAM(new GenericGF(0x13, 16)); +Ref GenericGF::AZTEC_DATA_6(new GenericGF(0x43, 64)); +Ref GenericGF::AZTEC_DATA_8(GenericGF::DATA_MATRIX_FIELD_256); +Ref GenericGF::AZTEC_DATA_10(new GenericGF(0x409, 1024)); +Ref GenericGF::AZTEC_DATA_12(new GenericGF(0x1069, 4096)); + + +static int INITIALIZATION_THRESHOLD = 0; + +GenericGF::GenericGF(int primitive, int size) + : size_(size), primitive_(primitive), initialized_(false) { + if (size <= INITIALIZATION_THRESHOLD) { + initialize(); + } +} + +void GenericGF::initialize() { + //expTable_ = std::vector(size_, (const int) 0); + //logTable_ = std::vector(size_, (const int) 0); + expTable_.resize(size_); + logTable_.resize(size_); + + int x = 1; + + for (int i = 0; i < size_; i++) { + expTable_[i] = x; + x <<= 1; // x = x * 2; we're assuming the generator alpha is 2 + if (x >= size_) { + x ^= primitive_; + x &= size_-1; + } + } + for (int i = 0; i < size_-1; i++) { + logTable_[expTable_[i]] = i; + } + //logTable_[0] == 0 but this should never be used + + zero_ = Ref(new GenericGFPoly(Ref(this), ArrayRef(new Array(1)))); + zero_->getCoefficients()[0] = 0; + one_ = Ref(new GenericGFPoly(Ref(this), ArrayRef(new Array(1)))); + one_->getCoefficients()[0] = 1; + + initialized_ = true; +} + +void GenericGF::checkInit() { + if (!initialized_) { + initialize(); + } +} + +Ref GenericGF::getZero() { + checkInit(); + return zero_; +} + +Ref GenericGF::getOne() { + checkInit(); + return one_; +} + +Ref GenericGF::buildMonomial(int degree, int coefficient) { + checkInit(); + + if (degree < 0) { + throw IllegalArgumentException("Degree must be non-negative"); + } + if (coefficient == 0) { + return zero_; + } + ArrayRef coefficients(new Array(degree + 1)); + coefficients[0] = coefficient; + + //return new GenericGFPoly(this, coefficients); + return Ref(new GenericGFPoly(Ref(this), coefficients)); +} + +int GenericGF::addOrSubtract(int a, int b) { + return a ^ b; +} + +int GenericGF::exp(int a) { + checkInit(); + return expTable_[a]; +} + +int GenericGF::log(int a) { + checkInit(); + if (a == 0) { + throw IllegalArgumentException("cannot give log(0)"); + } + return logTable_[a]; +} + +int GenericGF::inverse(int a) { + checkInit(); + if (a == 0) { + throw IllegalArgumentException("Cannot calculate the inverse of 0"); + } + return expTable_[size_ - logTable_[a] - 1]; +} + +int GenericGF::multiply(int a, int b) { + checkInit(); + + if (a == 0 || b == 0) { + return 0; + } + + if (a < 0 || b < 0 || a >= size_ || b >= size_) { + a++; + } + + int logSum = logTable_[a] + logTable_[b]; + + return expTable_[(logSum % size_) + logSum / size_]; +} + +int GenericGF::getSize() { + return size_; +} diff --git a/cpp/core/src/zxing/common/reedsolomon/GenericGF.h b/cpp/core/src/zxing/common/reedsolomon/GenericGF.h new file mode 100644 index 000000000..6f76a5865 --- /dev/null +++ b/cpp/core/src/zxing/common/reedsolomon/GenericGF.h @@ -0,0 +1,78 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * GenericGF.h + * zxing + * + * Created by Lukas Stabe on 13/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GENERICGF_H +#define GENERICGF_H + +#include +#include + +namespace zxing { + class GenericGFPoly; + + class GenericGF : public Counted { + + private: + std::vector expTable_; + std::vector logTable_; + Ref zero_; + Ref one_; + int size_; + int primitive_; + bool initialized_; + + void initialize(); + void checkInit(); + + public: + static Ref AZTEC_DATA_12; + static Ref AZTEC_DATA_10; + static Ref AZTEC_DATA_8; + static Ref AZTEC_DATA_6; + static Ref AZTEC_PARAM; + static Ref QR_CODE_FIELD_256; + static Ref DATA_MATRIX_FIELD_256; + + GenericGF(int primitive, int size); + + Ref getZero(); + Ref getOne(); + int getSize(); + Ref buildMonomial(int degree, int coefficient); + + static int addOrSubtract(int a, int b); + int exp(int a); + int log(int a); + int inverse(int a); + int multiply(int a, int b); + + bool operator==(GenericGF other) { + return (other.getSize() == this->size_ && + other.primitive_ == this->primitive_); + } + + //#warning todo: add print method + + }; +} + +#endif //GENERICGF_H + diff --git a/cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp b/cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp new file mode 100644 index 000000000..06cbad6fc --- /dev/null +++ b/cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp @@ -0,0 +1,215 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * GenericGFPoly.cpp + * zxing + * + * Created by Lukas Stabe on 13/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +using zxing::GenericGFPoly; +using zxing::ArrayRef; +using zxing::Ref; + +GenericGFPoly::GenericGFPoly(Ref field, + ArrayRef coefficients) + : field_(field) { + if (coefficients.size() == 0) { + throw IllegalArgumentException("need coefficients"); + } + int coefficientsLength = coefficients.size(); + if (coefficientsLength > 1 && coefficients[0] == 0) { + // Leading term must be non-zero for anything except the constant polynomial "0" + int firstNonZero = 1; + while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) { + firstNonZero++; + } + if (firstNonZero == coefficientsLength) { + coefficients_ = field->getZero()->getCoefficients(); + } else { + coefficients_ = ArrayRef(new Array(coefficientsLength-firstNonZero)); + for (int i = 0; i < (int)coefficients_.size(); i++) { + coefficients_[i] = coefficients[i + firstNonZero]; + } + } + } else { + coefficients_ = coefficients; + } +} + +ArrayRef GenericGFPoly::getCoefficients() { + return coefficients_; +} + +int GenericGFPoly::getDegree() { + return coefficients_.size() - 1; +} + +bool GenericGFPoly::isZero() { + return coefficients_[0] == 0; +} + +int GenericGFPoly::getCoefficient(int degree) { + return coefficients_[coefficients_.size() - 1 - degree]; +} + +int GenericGFPoly::evaluateAt(int a) { + if (a == 0) { + // Just return the x^0 coefficient + return getCoefficient(0); + } + + int size = coefficients_.size(); + if (a == 1) { + // Just the sum of the coefficients + int result = 0; + for (int i = 0; i < size; i++) { + result = GenericGF::addOrSubtract(result, coefficients_[i]); + } + return result; + } + int result = coefficients_[0]; + for (int i = 1; i < size; i++) { + result = GenericGF::addOrSubtract(field_->multiply(a, result), coefficients_[i]); + } + return result; +} + +Ref GenericGFPoly::addOrSubtract(Ref other) { + if (!(field_.object_ == other->field_.object_)) { + throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); + } + if (isZero()) { + return other; + } + if (other->isZero()) { + return Ref(this); + } + + ArrayRef smallerCoefficients = coefficients_; + ArrayRef largerCoefficients = other->getCoefficients(); + if (smallerCoefficients.size() > largerCoefficients.size()) { + ArrayRef temp = smallerCoefficients; + smallerCoefficients = largerCoefficients; + largerCoefficients = temp; + } + + ArrayRef sumDiff(new Array(largerCoefficients.size())); + int lengthDiff = largerCoefficients.size() - smallerCoefficients.size(); + // Copy high-order terms only found in higher-degree polynomial's coefficients + for (int i = 0; i < lengthDiff; i++) { + sumDiff[i] = largerCoefficients[i]; + } + + for (int i = lengthDiff; i < (int)largerCoefficients.size(); i++) { + sumDiff[i] = GenericGF::addOrSubtract(smallerCoefficients[i-lengthDiff], + largerCoefficients[i]); + } + + return Ref(new GenericGFPoly(field_, sumDiff)); +} + +Ref GenericGFPoly::multiply(Ref other) { + if (!(field_.object_ == other->field_.object_)) { + throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); + } + + if (isZero() || other->isZero()) { + return field_->getZero(); + } + + ArrayRef aCoefficients = coefficients_; + int aLength = aCoefficients.size(); + + ArrayRef bCoefficients = other->getCoefficients(); + int bLength = bCoefficients.size(); + + ArrayRef product(new Array(aLength + bLength - 1)); + for (int i = 0; i < aLength; i++) { + int aCoeff = aCoefficients[i]; + for (int j = 0; j < bLength; j++) { + product[i+j] = GenericGF::addOrSubtract(product[i+j], + field_->multiply(aCoeff, bCoefficients[j])); + } + } + + return Ref(new GenericGFPoly(field_, product)); +} + +Ref GenericGFPoly::multiply(int scalar) { + if (scalar == 0) { + return field_->getZero(); + } + if (scalar == 1) { + return Ref(this); + } + int size = coefficients_.size(); + ArrayRef product(new Array(size)); + for (int i = 0; i < size; i++) { + product[i] = field_->multiply(coefficients_[i], scalar); + } + return Ref(new GenericGFPoly(field_, product)); +} + +Ref GenericGFPoly::multiplyByMonomial(int degree, int coefficient) { + if (degree < 0) { + throw IllegalArgumentException("degree must not be less then 0"); + } + if (coefficient == 0) { + return field_->getZero(); + } + int size = coefficients_.size(); + ArrayRef product(new Array(size+degree)); + for (int i = 0; i < size; i++) { + product[i] = field_->multiply(coefficients_[i], coefficient); + } + return Ref(new GenericGFPoly(field_, product)); +} + +std::vector > GenericGFPoly::divide(Ref other) { + if (!(field_.object_ == other->field_.object_)) { + throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); + } + if (other->isZero()) { + throw IllegalArgumentException("divide by 0"); + } + + Ref quotient = field_->getZero(); + Ref remainder = Ref(this); + + int denominatorLeadingTerm = other->getCoefficient(other->getDegree()); + int inverseDenominatorLeadingTerm = field_->inverse(denominatorLeadingTerm); + + while (remainder->getDegree() >= other->getDegree() && !remainder->isZero()) { + int degreeDifference = remainder->getDegree() - other->getDegree(); + int scale = field_->multiply(remainder->getCoefficient(remainder->getDegree()), + inverseDenominatorLeadingTerm); + Ref term = other->multiplyByMonomial(degreeDifference, scale); + Ref iterationQuotiont = field_->buildMonomial(degreeDifference, + scale); + quotient = quotient->addOrSubtract(iterationQuotiont); + remainder = remainder->addOrSubtract(term); + } + + std::vector > returnValue; + returnValue[0] = quotient; + returnValue[1] = remainder; + return returnValue; +} diff --git a/cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h b/cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h new file mode 100644 index 000000000..feabc0aae --- /dev/null +++ b/cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h @@ -0,0 +1,54 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- +/* + * GenericGFPoly.h + * zxing + * + * Created by Lukas Stabe on 13/02/2012. + * Copyright 2012 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GENERICGFPOLY_H +#define GENERICGFPOLY_H + +#include +#include +#include + +namespace zxing { + class GenericGF; + + class GenericGFPoly : public Counted { + private: + Ref field_; + ArrayRef coefficients_; + + public: + GenericGFPoly(Ref field, ArrayRef coefficients); + ArrayRef getCoefficients(); + int getDegree(); + bool isZero(); + int getCoefficient(int degree); + int evaluateAt(int a); + Ref addOrSubtract(Ref other); + Ref multiply(Ref other); + Ref multiply(int scalar); + Ref multiplyByMonomial(int degree, int coefficient); + std::vector > divide(Ref other); + + //#warning todo: add print method + }; +} + +#endif //GENERICGFPOLY_H \ No newline at end of file diff --git a/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp b/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp index 0a2974814..ea81f5fb2 100644 --- a/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp +++ b/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp @@ -22,8 +22,6 @@ #include #include -#include -#include #include #include @@ -31,7 +29,7 @@ using namespace std; namespace zxing { -ReedSolomonDecoder::ReedSolomonDecoder(GF256 &fld) : +ReedSolomonDecoder::ReedSolomonDecoder(Ref fld) : field(fld) { } @@ -40,7 +38,7 @@ ReedSolomonDecoder::~ReedSolomonDecoder() { void ReedSolomonDecoder::decode(ArrayRef received, int twoS) { - Ref poly(new GF256Poly(field, received)); + Ref poly(new GenericGFPoly(field, received)); #ifdef DEBUG @@ -55,10 +53,10 @@ void ReedSolomonDecoder::decode(ArrayRef received, int twoS) { syndromeCoefficients.array_ << "\n"; #endif - bool dataMatrix = (&field == &GF256::DATA_MATRIX_FIELD); + bool dataMatrix = (field.object_ == GenericGF::DATA_MATRIX_FIELD_256.object_); bool noError = true; for (int i = 0; i < twoS; i++) { - int eval = poly->evaluateAt(field.exp(dataMatrix ? i + 1 : i)); + int eval = poly->evaluateAt(field->exp(dataMatrix ? i + 1 : i)); syndromeCoefficients[syndromeCoefficients->size() - 1 - i] = eval; if (eval != 0) { noError = false; @@ -68,41 +66,43 @@ void ReedSolomonDecoder::decode(ArrayRef received, int twoS) { return; } - Ref syndrome(new GF256Poly(field, syndromeCoefficients)); - Ref monomial(field.buildMonomial(twoS, 1)); - vector > sigmaOmega(runEuclideanAlgorithm(monomial, syndrome, twoS)); + Ref syndrome(new GenericGFPoly(field, syndromeCoefficients)); + Ref monomial = field->buildMonomial(twoS, 1); + vector > sigmaOmega = runEuclideanAlgorithm(monomial, syndrome, twoS); ArrayRef errorLocations = findErrorLocations(sigmaOmega[0]); ArrayRef errorMagitudes = findErrorMagnitudes(sigmaOmega[1], errorLocations, dataMatrix); for (unsigned i = 0; i < errorLocations->size(); i++) { - int position = received->size() - 1 - field.log(errorLocations[i]); + int position = received->size() - 1 - field->log(errorLocations[i]); //TODO: check why the position would be invalid if (position < 0 || (size_t)position >= received.size()) throw IllegalArgumentException("Invalid position (ReedSolomonDecoder)"); - received[position] = GF256::addOrSubtract(received[position], errorMagitudes[i]); + received[position] = GenericGF::addOrSubtract(received[position], errorMagitudes[i]); } } -vector > ReedSolomonDecoder::runEuclideanAlgorithm(Ref a, Ref b, int R) { +vector > ReedSolomonDecoder::runEuclideanAlgorithm(Ref a, + Ref b, + int R) { // Assume a's degree is >= b's if (a->getDegree() < b->getDegree()) { - Ref tmp = a; + Ref tmp = a; a = b; b = tmp; } - Ref rLast(a); - Ref r(b); - Ref sLast(field.getOne()); - Ref s(field.getZero()); - Ref tLast(field.getZero()); - Ref t(field.getOne()); + Ref rLast(a); + Ref r(b); + Ref sLast(field->getOne()); + Ref s(field->getZero()); + Ref tLast(field->getZero()); + Ref t(field->getOne()); // Run Euclidean algorithm until r's degree is less than R/2 while (r->getDegree() >= R / 2) { - Ref rLastLast(rLast); - Ref sLastLast(sLast); - Ref tLastLast(tLast); + Ref rLastLast(rLast); + Ref sLastLast(sLast); + Ref tLastLast(tLast); rLast = r; sLast = s; tLast = t; @@ -114,18 +114,19 @@ vector > ReedSolomonDecoder::runEuclideanAlgorithm(Ref throw ReedSolomonException("r_{i-1} was zero"); } r = rLastLast; - Ref q(field.getZero()); + Ref q(field->getZero()); int denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree()); - int dltInverse = field.inverse(denominatorLeadingTerm); + int dltInverse = field->inverse(denominatorLeadingTerm); while (r->getDegree() >= rLast->getDegree() && !r->isZero()) { int degreeDiff = r->getDegree() - rLast->getDegree(); - int scale = field.multiply(r->getCoefficient(r->getDegree()), dltInverse); - q = q->addOrSubtract(field.buildMonomial(degreeDiff, scale)); + int scale = field->multiply(r->getCoefficient(r->getDegree()), dltInverse); + q = q->addOrSubtract(field->buildMonomial(degreeDiff, scale)); r = r->addOrSubtract(rLast->multiplyByMonomial(degreeDiff, scale)); } s = q->multiply(sLast)->addOrSubtract(sLastLast); t = q->multiply(tLast)->addOrSubtract(tLastLast); + } int sigmaTildeAtZero = t->getCoefficient(0); @@ -133,9 +134,9 @@ vector > ReedSolomonDecoder::runEuclideanAlgorithm(Ref throw ReedSolomonException("sigmaTilde(0) was zero"); } - int inverse = field.inverse(sigmaTildeAtZero); - Ref sigma(t->multiply(inverse)); - Ref omega(r->multiply(inverse)); + int inverse = field->inverse(sigmaTildeAtZero); + Ref sigma(t->multiply(inverse)); + Ref omega(r->multiply(inverse)); #ifdef DEBUG @@ -145,26 +146,26 @@ vector > ReedSolomonDecoder::runEuclideanAlgorithm(Ref cout << "omega = " << *omega << "\n"; #endif - vector > result(2); + vector > result(2); result[0] = sigma; result[1] = omega; return result; } -ArrayRef ReedSolomonDecoder::findErrorLocations(Ref errorLocator) { +ArrayRef ReedSolomonDecoder::findErrorLocations(Ref errorLocator) { // This is a direct application of Chien's search int numErrors = errorLocator->getDegree(); if (numErrors == 1) { // shortcut - ArrayRef result(1); + ArrayRef result(new Array(1)); result[0] = errorLocator->getCoefficient(1); return result; } - ArrayRef result(numErrors); + ArrayRef result(new Array(numErrors)); int e = 0; - for (int i = 1; i < 256 && e < numErrors; i++) { + for (int i = 1; i < field->getSize() && e < numErrors; i++) { // cout << "errorLocator(" << i << ") == " << errorLocator->evaluateAt(i) << "\n"; if (errorLocator->evaluateAt(i) == 0) { - result[e] = field.inverse(i); + result[e] = field->inverse(i); e++; } } @@ -174,23 +175,23 @@ ArrayRef ReedSolomonDecoder::findErrorLocations(Ref errorLocator return result; } -ArrayRef ReedSolomonDecoder::findErrorMagnitudes(Ref errorEvaluator, ArrayRef errorLocations, bool dataMatrix) { +ArrayRef ReedSolomonDecoder::findErrorMagnitudes(Ref errorEvaluator, ArrayRef errorLocations, bool dataMatrix) { // This is directly applying Forney's Formula int s = errorLocations.size(); - ArrayRef result(s); + ArrayRef result(new Array(s)); for (int i = 0; i < s; i++) { - int xiInverse = field.inverse(errorLocations[i]); + int xiInverse = field->inverse(errorLocations[i]); int denominator = 1; for (int j = 0; j < s; j++) { if (i != j) { - denominator = field.multiply(denominator, GF256::addOrSubtract(1, field.multiply(errorLocations[j], + denominator = field->multiply(denominator, GenericGF::addOrSubtract(1, field->multiply(errorLocations[j], xiInverse))); } } - result[i] = field.multiply(errorEvaluator->evaluateAt(xiInverse), field.inverse(denominator)); + result[i] = field->multiply(errorEvaluator->evaluateAt(xiInverse), field->inverse(denominator)); if (dataMatrix) { - result[i] = field.multiply(result[i], xiInverse); + result[i] = field->multiply(result[i], xiInverse); } } return result; diff --git a/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.h b/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.h index f6c7681f8..20a417ea3 100644 --- a/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.h +++ b/cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.h @@ -24,22 +24,24 @@ #include #include #include +#include +#include namespace zxing { -class GF256; -class GF256Poly; +class GenericGFPoly; +class GenericGF; class ReedSolomonDecoder { private: - GF256 &field; + Ref field; public: - ReedSolomonDecoder(GF256 &fld); + ReedSolomonDecoder(Ref fld); ~ReedSolomonDecoder(); void decode(ArrayRef received, int twoS); private: - std::vector > runEuclideanAlgorithm(Ref a, Ref b, int R); - ArrayRef findErrorLocations(Ref errorLocator); - ArrayRef findErrorMagnitudes(Ref errorEvaluator, ArrayRef errorLocations, bool dataMatrix); + std::vector > runEuclideanAlgorithm(Ref a, Ref b, int R); + ArrayRef findErrorLocations(Ref errorLocator); + ArrayRef findErrorMagnitudes(Ref errorEvaluator, ArrayRef errorLocations, bool dataMatrix); }; } diff --git a/cpp/core/src/zxing/datamatrix/decoder/Decoder.cpp b/cpp/core/src/zxing/datamatrix/decoder/Decoder.cpp index 6fc042156..eff4e36be 100644 --- a/cpp/core/src/zxing/datamatrix/decoder/Decoder.cpp +++ b/cpp/core/src/zxing/datamatrix/decoder/Decoder.cpp @@ -32,7 +32,7 @@ namespace datamatrix { using namespace std; Decoder::Decoder() : - rsDecoder_(GF256::DATA_MATRIX_FIELD) { + rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) { } diff --git a/cpp/core/src/zxing/datamatrix/decoder/Decoder.h b/cpp/core/src/zxing/datamatrix/decoder/Decoder.h index 65fdf740c..cc5652d88 100644 --- a/cpp/core/src/zxing/datamatrix/decoder/Decoder.h +++ b/cpp/core/src/zxing/datamatrix/decoder/Decoder.h @@ -22,7 +22,6 @@ */ #include -#include #include #include #include diff --git a/cpp/core/src/zxing/datamatrix/detector/Detector.cpp b/cpp/core/src/zxing/datamatrix/detector/Detector.cpp index 72d9ebf9a..4e5c4343f 100644 --- a/cpp/core/src/zxing/datamatrix/detector/Detector.cpp +++ b/cpp/core/src/zxing/datamatrix/detector/Detector.cpp @@ -232,7 +232,7 @@ Ref Detector::detect() { points[1].reset(bottomLeft); points[2].reset(correctedTopRight); points[3].reset(bottomRight); - Ref detectorResult(new DetectorResult(bits, points, transform)); + Ref detectorResult(new DetectorResult(bits, points)); return detectorResult; } diff --git a/cpp/core/src/zxing/qrcode/decoder/Decoder.cpp b/cpp/core/src/zxing/qrcode/decoder/Decoder.cpp index 7b86e652d..5834df805 100644 --- a/cpp/core/src/zxing/qrcode/decoder/Decoder.cpp +++ b/cpp/core/src/zxing/qrcode/decoder/Decoder.cpp @@ -33,7 +33,7 @@ namespace qrcode { using namespace std; Decoder::Decoder() : - rsDecoder_(GF256::QR_CODE_FIELD) { + rsDecoder_(GenericGF::QR_CODE_FIELD_256) { } void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { diff --git a/cpp/core/src/zxing/qrcode/decoder/Decoder.h b/cpp/core/src/zxing/qrcode/decoder/Decoder.h index 3b63c98b9..bbfd9b72d 100644 --- a/cpp/core/src/zxing/qrcode/decoder/Decoder.h +++ b/cpp/core/src/zxing/qrcode/decoder/Decoder.h @@ -21,7 +21,6 @@ */ #include -#include #include #include #include diff --git a/cpp/core/src/zxing/qrcode/detector/Detector.cpp b/cpp/core/src/zxing/qrcode/detector/Detector.cpp index 952010a28..4a30fce81 100644 --- a/cpp/core/src/zxing/qrcode/detector/Detector.cpp +++ b/cpp/core/src/zxing/qrcode/detector/Detector.cpp @@ -106,7 +106,7 @@ Ref Detector::processFinderPatternInfo(Ref in points[3].reset(alignmentPattern); } - Ref result(new DetectorResult(bits, points, transform)); + Ref result(new DetectorResult(bits, points)); return result; } diff --git a/cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.cpp b/cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.cpp index db6b1e5cb..f2cdb9ff2 100644 --- a/cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.cpp +++ b/cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.cpp @@ -19,8 +19,6 @@ */ #include "ReedSolomonTest.h" -#include -#include #include #include #include @@ -56,7 +54,7 @@ void ReedSolomonTest::setUp() { qrCodeCorrectable_ = (qrCodeTestWithEc_->size() - qrCodeTest_->size()) / 2; - qrRSDecoder_ = new ReedSolomonDecoder(GF256::QR_CODE_FIELD); + qrRSDecoder_ = new ReedSolomonDecoder(GenericGF::QR_CODE_FIELD_256); } void ReedSolomonTest::tearDown() { diff --git a/cpp/ios.xcodeproj/project.pbxproj b/cpp/ios.xcodeproj/project.pbxproj index 12760a0ed..9f8687b32 100644 --- a/cpp/ios.xcodeproj/project.pbxproj +++ b/cpp/ios.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 3B15E78612CE9BF900DC7062 /* Exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B15E78512CE9BF900DC7062 /* Exception.cpp */; }; 3B1EEEC7144F1F5F0051C6A5 /* FormatException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B1EEEC6144F1F5F0051C6A5 /* FormatException.cpp */; }; 3B1EEECF144F1FBE0051C6A5 /* CharacterSetECI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B1EEECC144F1FBE0051C6A5 /* CharacterSetECI.cpp */; }; - 3B1EEED0144F1FBE0051C6A5 /* ECI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B1EEECD144F1FBE0051C6A5 /* ECI.cpp */; }; 3B1EEED1144F1FBE0051C6A5 /* StringUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B1EEECE144F1FBE0051C6A5 /* StringUtils.cpp */; }; 3B2A325212CE9D31001D9945 /* IllegalArgumentException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A325112CE9D31001D9945 /* IllegalArgumentException.cpp */; }; 3B2A32B012CEA202001D9945 /* HybridBinarizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A32AF12CEA202001D9945 /* HybridBinarizer.cpp */; }; @@ -42,8 +41,6 @@ 3B2A336E12CEA9B0001D9945 /* DecodedBitStreamParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A336D12CEA9B0001D9945 /* DecodedBitStreamParser.cpp */; }; 3B2A337212CEA9E2001D9945 /* Mode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A337112CEA9E2001D9945 /* Mode.cpp */; }; 3B2A337612CEAA06001D9945 /* ReedSolomonDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A337512CEAA06001D9945 /* ReedSolomonDecoder.cpp */; }; - 3B2A337A12CEAA20001D9945 /* GF256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A337912CEAA20001D9945 /* GF256.cpp */; }; - 3B2A337E12CEAA37001D9945 /* GF256Poly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A337D12CEAA37001D9945 /* GF256Poly.cpp */; }; 3B2A338212CEAA4B001D9945 /* ReedSolomonException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A338112CEAA4B001D9945 /* ReedSolomonException.cpp */; }; 3B2A338612CEAA63001D9945 /* BitSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A338512CEAA63001D9945 /* BitSource.cpp */; }; 3B2A338E12CEAA95001D9945 /* DecoderResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B2A338D12CEAA95001D9945 /* DecoderResult.cpp */; }; @@ -53,6 +50,12 @@ 3BBF0AEE12CBCAFC0061650E /* AlignmentPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BBF0AED12CBCAFC0061650E /* AlignmentPattern.cpp */; }; AA747D9F0F9514B9006C5449 /* ios_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* ios_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; + E105A8FE14EC34270011473C /* GenericGF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A8FC14EC34270011473C /* GenericGF.cpp */; }; + E105A8FF14EC34270011473C /* GenericGFPoly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A8FD14EC34270011473C /* GenericGFPoly.cpp */; }; + E105A90414EC35070011473C /* AztecDetectorResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A90214EC35070011473C /* AztecDetectorResult.cpp */; }; + E105A90514EC35070011473C /* AztecReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A90314EC35070011473C /* AztecReader.cpp */; }; + E105A90714EC35110011473C /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A90614EC35110011473C /* Decoder.cpp */; }; + E105A90914EC35190011473C /* Detector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A90814EC35190011473C /* Detector.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -60,7 +63,6 @@ 3B15E78512CE9BF900DC7062 /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Exception.cpp; path = core/src/zxing/Exception.cpp; sourceTree = ""; }; 3B1EEEC6144F1F5F0051C6A5 /* FormatException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatException.cpp; path = core/src/zxing/FormatException.cpp; sourceTree = ""; }; 3B1EEECC144F1FBE0051C6A5 /* CharacterSetECI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CharacterSetECI.cpp; path = core/src/zxing/common/CharacterSetECI.cpp; sourceTree = ""; }; - 3B1EEECD144F1FBE0051C6A5 /* ECI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ECI.cpp; path = core/src/zxing/common/ECI.cpp; sourceTree = ""; }; 3B1EEECE144F1FBE0051C6A5 /* StringUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringUtils.cpp; path = core/src/zxing/common/StringUtils.cpp; sourceTree = ""; }; 3B2A325112CE9D31001D9945 /* IllegalArgumentException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IllegalArgumentException.cpp; path = core/src/zxing/common/IllegalArgumentException.cpp; sourceTree = ""; }; 3B2A32AF12CEA202001D9945 /* HybridBinarizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HybridBinarizer.cpp; path = core/src/zxing/common/HybridBinarizer.cpp; sourceTree = ""; }; @@ -91,8 +93,6 @@ 3B2A336D12CEA9B0001D9945 /* DecodedBitStreamParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DecodedBitStreamParser.cpp; path = core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp; sourceTree = ""; }; 3B2A337112CEA9E2001D9945 /* Mode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mode.cpp; path = core/src/zxing/qrcode/decoder/Mode.cpp; sourceTree = ""; }; 3B2A337512CEAA06001D9945 /* ReedSolomonDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ReedSolomonDecoder.cpp; path = core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp; sourceTree = ""; }; - 3B2A337912CEAA20001D9945 /* GF256.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GF256.cpp; path = core/src/zxing/common/reedsolomon/GF256.cpp; sourceTree = ""; }; - 3B2A337D12CEAA37001D9945 /* GF256Poly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GF256Poly.cpp; path = core/src/zxing/common/reedsolomon/GF256Poly.cpp; sourceTree = ""; }; 3B2A338112CEAA4B001D9945 /* ReedSolomonException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ReedSolomonException.cpp; path = core/src/zxing/common/reedsolomon/ReedSolomonException.cpp; sourceTree = ""; }; 3B2A338512CEAA63001D9945 /* BitSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BitSource.cpp; path = core/src/zxing/common/BitSource.cpp; sourceTree = ""; }; 3B2A338D12CEAA95001D9945 /* DecoderResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DecoderResult.cpp; path = core/src/zxing/common/DecoderResult.cpp; sourceTree = ""; }; @@ -103,6 +103,12 @@ AA747D9E0F9514B9006C5449 /* ios_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_Prefix.pch; sourceTree = SOURCE_ROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D2AAC07E0554694100DB518D /* libzxing.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libzxing.a; sourceTree = BUILT_PRODUCTS_DIR; }; + E105A8FC14EC34270011473C /* GenericGF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GenericGF.cpp; path = core/src/zxing/common/reedsolomon/GenericGF.cpp; sourceTree = ""; }; + E105A8FD14EC34270011473C /* GenericGFPoly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GenericGFPoly.cpp; path = core/src/zxing/common/reedsolomon/GenericGFPoly.cpp; sourceTree = ""; }; + E105A90214EC35070011473C /* AztecDetectorResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AztecDetectorResult.cpp; path = core/src/zxing/aztec/AztecDetectorResult.cpp; sourceTree = ""; }; + E105A90314EC35070011473C /* AztecReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AztecReader.cpp; path = core/src/zxing/aztec/AztecReader.cpp; sourceTree = ""; }; + E105A90614EC35110011473C /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Decoder.cpp; path = core/src/zxing/aztec/decoder/Decoder.cpp; sourceTree = ""; }; + E105A90814EC35190011473C /* Detector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Detector.cpp; path = core/src/zxing/aztec/detector/Detector.cpp; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -147,40 +153,28 @@ 08FB77AEFE84172EC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + E105A90114EC34E20011473C /* aztec */, + E105A90014EC34580011473C /* qrcode */, 3B1EEECC144F1FBE0051C6A5 /* CharacterSetECI.cpp */, - 3B1EEECD144F1FBE0051C6A5 /* ECI.cpp */, 3B1EEECE144F1FBE0051C6A5 /* StringUtils.cpp */, 3B1EEEC6144F1F5F0051C6A5 /* FormatException.cpp */, 3BBCB72312DD10DC00B5936D /* Reader.cpp */, - 3BBCB71F12DD10BC00B5936D /* QRCodeReader.cpp */, 3BBCB71D12DD108300B5936D /* Result.cpp */, 3B2A338D12CEAA95001D9945 /* DecoderResult.cpp */, 3B2A338512CEAA63001D9945 /* BitSource.cpp */, 3B2A338112CEAA4B001D9945 /* ReedSolomonException.cpp */, - 3B2A337D12CEAA37001D9945 /* GF256Poly.cpp */, - 3B2A337912CEAA20001D9945 /* GF256.cpp */, 3B2A337512CEAA06001D9945 /* ReedSolomonDecoder.cpp */, + E105A8FC14EC34270011473C /* GenericGF.cpp */, + E105A8FD14EC34270011473C /* GenericGFPoly.cpp */, 3B2A337112CEA9E2001D9945 /* Mode.cpp */, 3B2A336D12CEA9B0001D9945 /* DecodedBitStreamParser.cpp */, - 3B2A336912CEA997001D9945 /* DataMask.cpp */, 3B2A336512CEA976001D9945 /* Str.cpp */, - 3B2A336112CEA95C001D9945 /* DataBlock.cpp */, - 3B2A335D12CEA93D001D9945 /* BitMatrixParser.cpp */, - 3B2A335912CEA925001D9945 /* Decoder.cpp */, 3B2A333212CEA6C2001D9945 /* DetectorResult.cpp */, - 3B2A332E12CEA696001D9945 /* ErrorCorrectionLevel.cpp */, - 3B2A332A12CEA67F001D9945 /* FormatInformation.cpp */, - 3B2A332612CEA664001D9945 /* FinderPattern.cpp */, 3B2A332212CEA64F001D9945 /* PerspectiveTransform.cpp */, 3B2A331E12CEA638001D9945 /* GridSampler.cpp */, - 3B2A331A12CEA624001D9945 /* FinderPatternInfo.cpp */, 3B2A331612CEA60A001D9945 /* DecodeHints.cpp */, - 3B2A331212CEA5F3001D9945 /* FinderPatternFinder.cpp */, - 3B2A330E12CEA5D2001D9945 /* Version.cpp */, 3B2A330A12CEA5BF001D9945 /* ReaderException.cpp */, 3B2A330612CEA59E001D9945 /* ResultPoint.cpp */, - 3B2A330212CEA55B001D9945 /* AlignmentPatternFinder.cpp */, - 3B2A32FE12CEA53A001D9945 /* Detector.cpp */, 3B2A32E712CEA43A001D9945 /* BinaryBitmap.cpp */, 3B2A32CB12CEA380001D9945 /* BitMatrix.cpp */, 3B2A32C512CEA2F9001D9945 /* BitArray.cpp */, @@ -190,7 +184,6 @@ 3B2A325112CE9D31001D9945 /* IllegalArgumentException.cpp */, 3B15E78512CE9BF900DC7062 /* Exception.cpp */, 3B15E73912CE996800DC7062 /* LuminanceSource.cpp */, - 3BBF0AED12CBCAFC0061650E /* AlignmentPattern.cpp */, ); name = Classes; sourceTree = ""; @@ -203,6 +196,38 @@ name = "Other Sources"; sourceTree = ""; }; + E105A90014EC34580011473C /* qrcode */ = { + isa = PBXGroup; + children = ( + 3BBCB71F12DD10BC00B5936D /* QRCodeReader.cpp */, + 3B2A336912CEA997001D9945 /* DataMask.cpp */, + 3B2A336112CEA95C001D9945 /* DataBlock.cpp */, + 3B2A335D12CEA93D001D9945 /* BitMatrixParser.cpp */, + 3B2A335912CEA925001D9945 /* Decoder.cpp */, + 3B2A332E12CEA696001D9945 /* ErrorCorrectionLevel.cpp */, + 3B2A332A12CEA67F001D9945 /* FormatInformation.cpp */, + 3B2A332612CEA664001D9945 /* FinderPattern.cpp */, + 3B2A331A12CEA624001D9945 /* FinderPatternInfo.cpp */, + 3B2A331212CEA5F3001D9945 /* FinderPatternFinder.cpp */, + 3B2A330E12CEA5D2001D9945 /* Version.cpp */, + 3B2A330212CEA55B001D9945 /* AlignmentPatternFinder.cpp */, + 3B2A32FE12CEA53A001D9945 /* Detector.cpp */, + 3BBF0AED12CBCAFC0061650E /* AlignmentPattern.cpp */, + ); + name = qrcode; + sourceTree = ""; + }; + E105A90114EC34E20011473C /* aztec */ = { + isa = PBXGroup; + children = ( + E105A90814EC35190011473C /* Detector.cpp */, + E105A90614EC35110011473C /* Decoder.cpp */, + E105A90214EC35070011473C /* AztecDetectorResult.cpp */, + E105A90314EC35070011473C /* AztecReader.cpp */, + ); + name = aztec; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -299,8 +324,6 @@ 3B2A336E12CEA9B0001D9945 /* DecodedBitStreamParser.cpp in Sources */, 3B2A337212CEA9E2001D9945 /* Mode.cpp in Sources */, 3B2A337612CEAA06001D9945 /* ReedSolomonDecoder.cpp in Sources */, - 3B2A337A12CEAA20001D9945 /* GF256.cpp in Sources */, - 3B2A337E12CEAA37001D9945 /* GF256Poly.cpp in Sources */, 3B2A338212CEAA4B001D9945 /* ReedSolomonException.cpp in Sources */, 3B2A338612CEAA63001D9945 /* BitSource.cpp in Sources */, 3B2A338E12CEAA95001D9945 /* DecoderResult.cpp in Sources */, @@ -309,8 +332,13 @@ 3BBCB72412DD10DC00B5936D /* Reader.cpp in Sources */, 3B1EEEC7144F1F5F0051C6A5 /* FormatException.cpp in Sources */, 3B1EEECF144F1FBE0051C6A5 /* CharacterSetECI.cpp in Sources */, - 3B1EEED0144F1FBE0051C6A5 /* ECI.cpp in Sources */, 3B1EEED1144F1FBE0051C6A5 /* StringUtils.cpp in Sources */, + E105A8FE14EC34270011473C /* GenericGF.cpp in Sources */, + E105A8FF14EC34270011473C /* GenericGFPoly.cpp in Sources */, + E105A90414EC35070011473C /* AztecDetectorResult.cpp in Sources */, + E105A90514EC35070011473C /* AztecReader.cpp in Sources */, + E105A90714EC35110011473C /* Decoder.cpp in Sources */, + E105A90914EC35190011473C /* Detector.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/cpp/osx.xcodeproj/project.pbxproj b/cpp/osx.xcodeproj/project.pbxproj index 8ab4c4a9c..4d9b90288 100644 --- a/cpp/osx.xcodeproj/project.pbxproj +++ b/cpp/osx.xcodeproj/project.pbxproj @@ -44,10 +44,6 @@ 3B5B0EC8121C52ED005698F8 /* PerspectiveTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5B0E33121C52ED005698F8 /* PerspectiveTransform.cpp */; }; 3B5B0EC9121C52ED005698F8 /* PerspectiveTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5B0E34121C52ED005698F8 /* PerspectiveTransform.h */; }; 3B5B0ECA121C52ED005698F8 /* Point.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5B0E35121C52ED005698F8 /* Point.h */; }; - 3B5B0ECB121C52ED005698F8 /* GF256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5B0E37121C52ED005698F8 /* GF256.cpp */; }; - 3B5B0ECC121C52ED005698F8 /* GF256.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5B0E38121C52ED005698F8 /* GF256.h */; }; - 3B5B0ECD121C52ED005698F8 /* GF256Poly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5B0E39121C52ED005698F8 /* GF256Poly.cpp */; }; - 3B5B0ECE121C52ED005698F8 /* GF256Poly.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5B0E3A121C52ED005698F8 /* GF256Poly.h */; }; 3B5B0ECF121C52ED005698F8 /* ReedSolomonDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5B0E3B121C52ED005698F8 /* ReedSolomonDecoder.cpp */; }; 3B5B0ED0121C52ED005698F8 /* ReedSolomonDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5B0E3C121C52ED005698F8 /* ReedSolomonDecoder.h */; }; 3B5B0ED1121C52ED005698F8 /* ReedSolomonException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5B0E3D121C52ED005698F8 /* ReedSolomonException.cpp */; }; @@ -150,10 +146,21 @@ 3B5B0F32121C52ED005698F8 /* ResultPointCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B5B0EA5121C52ED005698F8 /* ResultPointCallback.h */; }; 3BB87D4314B54C480078117F /* FormatException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BB87D4214B54C480078117F /* FormatException.cpp */; }; 3BB87D4714B54C610078117F /* CharacterSetECI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BB87D4414B54C610078117F /* CharacterSetECI.cpp */; }; - 3BB87D4814B54C610078117F /* ECI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BB87D4514B54C610078117F /* ECI.cpp */; }; 3BB87D4914B54C610078117F /* StringUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BB87D4614B54C610078117F /* StringUtils.cpp */; }; 3BB87D5014B54F1D0078117F /* WhiteRectangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BB87D4F14B54F1D0078117F /* WhiteRectangleDetector.cpp */; }; 3BB87D5214B54F3F0078117F /* NotFoundException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BB87D5114B54F3F0078117F /* NotFoundException.cpp */; }; + E105A91214EC35860011473C /* GenericGF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A90E14EC35860011473C /* GenericGF.cpp */; }; + E105A91314EC35860011473C /* GenericGF.h in Headers */ = {isa = PBXBuildFile; fileRef = E105A90F14EC35860011473C /* GenericGF.h */; }; + E105A91414EC35860011473C /* GenericGFPoly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A91014EC35860011473C /* GenericGFPoly.cpp */; }; + E105A91514EC35860011473C /* GenericGFPoly.h in Headers */ = {isa = PBXBuildFile; fileRef = E105A91114EC35860011473C /* GenericGFPoly.h */; }; + E105A92114EC35AA0011473C /* AztecDetectorResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A91714EC35AA0011473C /* AztecDetectorResult.cpp */; }; + E105A92214EC35AA0011473C /* AztecDetectorResult.h in Headers */ = {isa = PBXBuildFile; fileRef = E105A91814EC35AA0011473C /* AztecDetectorResult.h */; }; + E105A92314EC35AA0011473C /* AztecReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A91914EC35AA0011473C /* AztecReader.cpp */; }; + E105A92414EC35AA0011473C /* AztecReader.h in Headers */ = {isa = PBXBuildFile; fileRef = E105A91A14EC35AA0011473C /* AztecReader.h */; }; + E105A92514EC35AA0011473C /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A91C14EC35AA0011473C /* Decoder.cpp */; }; + E105A92614EC35AA0011473C /* Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E105A91D14EC35AA0011473C /* Decoder.h */; }; + E105A92714EC35AA0011473C /* Detector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E105A91F14EC35AA0011473C /* Detector.cpp */; }; + E105A92814EC35AA0011473C /* Detector.h in Headers */ = {isa = PBXBuildFile; fileRef = E105A92014EC35AA0011473C /* Detector.h */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -195,10 +202,6 @@ 3B5B0E33121C52ED005698F8 /* PerspectiveTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerspectiveTransform.cpp; sourceTree = ""; }; 3B5B0E34121C52ED005698F8 /* PerspectiveTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerspectiveTransform.h; sourceTree = ""; }; 3B5B0E35121C52ED005698F8 /* Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Point.h; sourceTree = ""; }; - 3B5B0E37121C52ED005698F8 /* GF256.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GF256.cpp; sourceTree = ""; }; - 3B5B0E38121C52ED005698F8 /* GF256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GF256.h; sourceTree = ""; }; - 3B5B0E39121C52ED005698F8 /* GF256Poly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GF256Poly.cpp; sourceTree = ""; }; - 3B5B0E3A121C52ED005698F8 /* GF256Poly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GF256Poly.h; sourceTree = ""; }; 3B5B0E3B121C52ED005698F8 /* ReedSolomonDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReedSolomonDecoder.cpp; sourceTree = ""; }; 3B5B0E3C121C52ED005698F8 /* ReedSolomonDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReedSolomonDecoder.h; sourceTree = ""; }; 3B5B0E3D121C52ED005698F8 /* ReedSolomonException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReedSolomonException.cpp; sourceTree = ""; }; @@ -301,10 +304,21 @@ 3B5B0EA5121C52ED005698F8 /* ResultPointCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultPointCallback.h; sourceTree = ""; }; 3BB87D4214B54C480078117F /* FormatException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatException.cpp; sourceTree = ""; }; 3BB87D4414B54C610078117F /* CharacterSetECI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CharacterSetECI.cpp; path = common/CharacterSetECI.cpp; sourceTree = ""; }; - 3BB87D4514B54C610078117F /* ECI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ECI.cpp; path = common/ECI.cpp; sourceTree = ""; }; 3BB87D4614B54C610078117F /* StringUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringUtils.cpp; path = common/StringUtils.cpp; sourceTree = ""; }; 3BB87D4F14B54F1D0078117F /* WhiteRectangleDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WhiteRectangleDetector.cpp; path = common/detector/WhiteRectangleDetector.cpp; sourceTree = ""; }; 3BB87D5114B54F3F0078117F /* NotFoundException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotFoundException.cpp; sourceTree = ""; }; + E105A90E14EC35860011473C /* GenericGF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericGF.cpp; sourceTree = ""; }; + E105A90F14EC35860011473C /* GenericGF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericGF.h; sourceTree = ""; }; + E105A91014EC35860011473C /* GenericGFPoly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericGFPoly.cpp; sourceTree = ""; }; + E105A91114EC35860011473C /* GenericGFPoly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericGFPoly.h; sourceTree = ""; }; + E105A91714EC35AA0011473C /* AztecDetectorResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AztecDetectorResult.cpp; path = aztec/AztecDetectorResult.cpp; sourceTree = ""; }; + E105A91814EC35AA0011473C /* AztecDetectorResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AztecDetectorResult.h; path = aztec/AztecDetectorResult.h; sourceTree = ""; }; + E105A91914EC35AA0011473C /* AztecReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AztecReader.cpp; path = aztec/AztecReader.cpp; sourceTree = ""; }; + E105A91A14EC35AA0011473C /* AztecReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AztecReader.h; path = aztec/AztecReader.h; sourceTree = ""; }; + E105A91C14EC35AA0011473C /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decoder.cpp; sourceTree = ""; }; + E105A91D14EC35AA0011473C /* Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decoder.h; sourceTree = ""; }; + E105A91F14EC35AA0011473C /* Detector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Detector.cpp; sourceTree = ""; }; + E105A92014EC35AA0011473C /* Detector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Detector.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -350,8 +364,6 @@ isa = PBXGroup; children = ( 3B5B0E0F121C52ED005698F8 /* zxing */, - 3B5B0C8C121C4F61005698F8 /* zxing */, - 3B5B0B5F121C4EC3005698F8 /* zxing */, ); name = Classes; sourceTree = ""; @@ -377,173 +389,13 @@ name = "Other Sources"; sourceTree = ""; }; - 3B5B0B5F121C4EC3005698F8 /* zxing */ = { - isa = PBXGroup; - children = ( - 3B5B0B66121C4EC3005698F8 /* common */, - 3B5B0B91121C4EC3005698F8 /* datamatrix */, - 3B5B0BAE121C4EC3005698F8 /* oned */, - 3B5B0BC7121C4EC3005698F8 /* qrcode */, - ); - name = zxing; - path = core/src/zxing; - sourceTree = ""; - }; - 3B5B0B66121C4EC3005698F8 /* common */ = { - isa = PBXGroup; - children = ( - 3B5B0B86121C4EC3005698F8 /* reedsolomon */, - ); - path = common; - sourceTree = ""; - }; - 3B5B0B86121C4EC3005698F8 /* reedsolomon */ = { - isa = PBXGroup; - children = ( - ); - path = reedsolomon; - sourceTree = ""; - }; - 3B5B0B91121C4EC3005698F8 /* datamatrix */ = { - isa = PBXGroup; - children = ( - 3B5B0B94121C4EC3005698F8 /* decoder */, - 3B5B0B9D121C4EC3005698F8 /* detector */, - ); - path = datamatrix; - sourceTree = ""; - }; - 3B5B0B94121C4EC3005698F8 /* decoder */ = { - isa = PBXGroup; - children = ( - ); - path = decoder; - sourceTree = ""; - }; - 3B5B0B9D121C4EC3005698F8 /* detector */ = { - isa = PBXGroup; - children = ( - ); - path = detector; - sourceTree = ""; - }; - 3B5B0BAE121C4EC3005698F8 /* oned */ = { - isa = PBXGroup; - children = ( - ); - path = oned; - sourceTree = ""; - }; - 3B5B0BC7121C4EC3005698F8 /* qrcode */ = { - isa = PBXGroup; - children = ( - 3B5B0BC8121C4EC3005698F8 /* decoder */, - 3B5B0BD5121C4EC3005698F8 /* detector */, - ); - path = qrcode; - sourceTree = ""; - }; - 3B5B0BC8121C4EC3005698F8 /* decoder */ = { - isa = PBXGroup; - children = ( - ); - path = decoder; - sourceTree = ""; - }; - 3B5B0BD5121C4EC3005698F8 /* detector */ = { - isa = PBXGroup; - children = ( - ); - path = detector; - sourceTree = ""; - }; - 3B5B0C8C121C4F61005698F8 /* zxing */ = { - isa = PBXGroup; - children = ( - 3B5B0C93121C4F61005698F8 /* common */, - 3B5B0CBE121C4F61005698F8 /* datamatrix */, - 3B5B0CDB121C4F61005698F8 /* oned */, - 3B5B0CF4121C4F61005698F8 /* qrcode */, - ); - name = zxing; - path = core/src/zxing; - sourceTree = ""; - }; - 3B5B0C93121C4F61005698F8 /* common */ = { - isa = PBXGroup; - children = ( - 3B5B0CB3121C4F61005698F8 /* reedsolomon */, - ); - path = common; - sourceTree = ""; - }; - 3B5B0CB3121C4F61005698F8 /* reedsolomon */ = { - isa = PBXGroup; - children = ( - ); - path = reedsolomon; - sourceTree = ""; - }; - 3B5B0CBE121C4F61005698F8 /* datamatrix */ = { - isa = PBXGroup; - children = ( - 3B5B0CC1121C4F61005698F8 /* decoder */, - 3B5B0CCA121C4F61005698F8 /* detector */, - ); - path = datamatrix; - sourceTree = ""; - }; - 3B5B0CC1121C4F61005698F8 /* decoder */ = { - isa = PBXGroup; - children = ( - ); - path = decoder; - sourceTree = ""; - }; - 3B5B0CCA121C4F61005698F8 /* detector */ = { - isa = PBXGroup; - children = ( - ); - path = detector; - sourceTree = ""; - }; - 3B5B0CDB121C4F61005698F8 /* oned */ = { - isa = PBXGroup; - children = ( - ); - path = oned; - sourceTree = ""; - }; - 3B5B0CF4121C4F61005698F8 /* qrcode */ = { - isa = PBXGroup; - children = ( - 3B5B0CF5121C4F61005698F8 /* decoder */, - 3B5B0D02121C4F61005698F8 /* detector */, - ); - path = qrcode; - sourceTree = ""; - }; - 3B5B0CF5121C4F61005698F8 /* decoder */ = { - isa = PBXGroup; - children = ( - ); - path = decoder; - sourceTree = ""; - }; - 3B5B0D02121C4F61005698F8 /* detector */ = { - isa = PBXGroup; - children = ( - ); - path = detector; - sourceTree = ""; - }; 3B5B0E0F121C52ED005698F8 /* zxing */ = { isa = PBXGroup; children = ( + E105A91614EC35980011473C /* aztec */, 3BB87D5114B54F3F0078117F /* NotFoundException.cpp */, 3BB87D4F14B54F1D0078117F /* WhiteRectangleDetector.cpp */, 3BB87D4414B54C610078117F /* CharacterSetECI.cpp */, - 3BB87D4514B54C610078117F /* ECI.cpp */, 3BB87D4614B54C610078117F /* StringUtils.cpp */, 3BB87D4214B54C480078117F /* FormatException.cpp */, 3B5B0E10121C52ED005698F8 /* BarcodeFormat.cpp */, @@ -623,10 +475,10 @@ 3B5B0E36121C52ED005698F8 /* reedsolomon */ = { isa = PBXGroup; children = ( - 3B5B0E37121C52ED005698F8 /* GF256.cpp */, - 3B5B0E38121C52ED005698F8 /* GF256.h */, - 3B5B0E39121C52ED005698F8 /* GF256Poly.cpp */, - 3B5B0E3A121C52ED005698F8 /* GF256Poly.h */, + E105A90E14EC35860011473C /* GenericGF.cpp */, + E105A90F14EC35860011473C /* GenericGF.h */, + E105A91014EC35860011473C /* GenericGFPoly.cpp */, + E105A91114EC35860011473C /* GenericGFPoly.h */, 3B5B0E3B121C52ED005698F8 /* ReedSolomonDecoder.cpp */, 3B5B0E3C121C52ED005698F8 /* ReedSolomonDecoder.h */, 3B5B0E3D121C52ED005698F8 /* ReedSolomonException.cpp */, @@ -764,6 +616,39 @@ path = detector; sourceTree = ""; }; + E105A91614EC35980011473C /* aztec */ = { + isa = PBXGroup; + children = ( + E105A91714EC35AA0011473C /* AztecDetectorResult.cpp */, + E105A91814EC35AA0011473C /* AztecDetectorResult.h */, + E105A91914EC35AA0011473C /* AztecReader.cpp */, + E105A91A14EC35AA0011473C /* AztecReader.h */, + E105A91B14EC35AA0011473C /* decoder */, + E105A91E14EC35AA0011473C /* detector */, + ); + name = aztec; + sourceTree = ""; + }; + E105A91B14EC35AA0011473C /* decoder */ = { + isa = PBXGroup; + children = ( + E105A91C14EC35AA0011473C /* Decoder.cpp */, + E105A91D14EC35AA0011473C /* Decoder.h */, + ); + name = decoder; + path = aztec/decoder; + sourceTree = ""; + }; + E105A91E14EC35AA0011473C /* detector */ = { + isa = PBXGroup; + children = ( + E105A91F14EC35AA0011473C /* Detector.cpp */, + E105A92014EC35AA0011473C /* Detector.h */, + ); + name = detector; + path = aztec/detector; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -790,8 +675,6 @@ 3B5B0EC7121C52ED005698F8 /* IllegalArgumentException.h in Headers */, 3B5B0EC9121C52ED005698F8 /* PerspectiveTransform.h in Headers */, 3B5B0ECA121C52ED005698F8 /* Point.h in Headers */, - 3B5B0ECC121C52ED005698F8 /* GF256.h in Headers */, - 3B5B0ECE121C52ED005698F8 /* GF256Poly.h in Headers */, 3B5B0ED0121C52ED005698F8 /* ReedSolomonDecoder.h in Headers */, 3B5B0ED2121C52ED005698F8 /* ReedSolomonException.h in Headers */, 3B5B0ED4121C52ED005698F8 /* Str.h in Headers */, @@ -842,6 +725,12 @@ 3B5B0F2E121C52ED005698F8 /* Result.h in Headers */, 3B5B0F30121C52ED005698F8 /* ResultPoint.h in Headers */, 3B5B0F32121C52ED005698F8 /* ResultPointCallback.h in Headers */, + E105A91314EC35860011473C /* GenericGF.h in Headers */, + E105A91514EC35860011473C /* GenericGFPoly.h in Headers */, + E105A92214EC35AA0011473C /* AztecDetectorResult.h in Headers */, + E105A92414EC35AA0011473C /* AztecReader.h in Headers */, + E105A92614EC35AA0011473C /* Decoder.h in Headers */, + E105A92814EC35AA0011473C /* Detector.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -910,8 +799,6 @@ 3B5B0EC4121C52ED005698F8 /* HybridBinarizer.cpp in Sources */, 3B5B0EC6121C52ED005698F8 /* IllegalArgumentException.cpp in Sources */, 3B5B0EC8121C52ED005698F8 /* PerspectiveTransform.cpp in Sources */, - 3B5B0ECB121C52ED005698F8 /* GF256.cpp in Sources */, - 3B5B0ECD121C52ED005698F8 /* GF256Poly.cpp in Sources */, 3B5B0ECF121C52ED005698F8 /* ReedSolomonDecoder.cpp in Sources */, 3B5B0ED1121C52ED005698F8 /* ReedSolomonException.cpp in Sources */, 3B5B0ED3121C52ED005698F8 /* Str.cpp in Sources */, @@ -964,10 +851,15 @@ 3B5B0F31121C52ED005698F8 /* ResultPointCallback.cpp in Sources */, 3BB87D4314B54C480078117F /* FormatException.cpp in Sources */, 3BB87D4714B54C610078117F /* CharacterSetECI.cpp in Sources */, - 3BB87D4814B54C610078117F /* ECI.cpp in Sources */, 3BB87D4914B54C610078117F /* StringUtils.cpp in Sources */, 3BB87D5014B54F1D0078117F /* WhiteRectangleDetector.cpp in Sources */, 3BB87D5214B54F3F0078117F /* NotFoundException.cpp in Sources */, + E105A91214EC35860011473C /* GenericGF.cpp in Sources */, + E105A91414EC35860011473C /* GenericGFPoly.cpp in Sources */, + E105A92114EC35AA0011473C /* AztecDetectorResult.cpp in Sources */, + E105A92314EC35AA0011473C /* AztecReader.cpp in Sources */, + E105A92514EC35AA0011473C /* Decoder.cpp in Sources */, + E105A92714EC35AA0011473C /* Detector.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iphone/ScanTest/Classes/RootViewController.mm b/iphone/ScanTest/Classes/RootViewController.mm index 52ce404b1..837d6e719 100644 --- a/iphone/ScanTest/Classes/RootViewController.mm +++ b/iphone/ScanTest/Classes/RootViewController.mm @@ -1,13 +1,37 @@ -// -// RootViewController.m -// ScanTest -// -// Created by David Kavanagh on 5/10/10. -// Copyright __MyCompanyName__ 2010. All rights reserved. -// +// -*- Mode: ObjC; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/* + * Copyright 2010-2012 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #import "RootViewController.h" + +#ifndef ZXQR +#define ZXQR 1 +#endif + +#if ZXQR #import "QRCodeReader.h" +#endif + +#ifndef ZXAZ +#define ZXAZ 0 +#endif + +#if ZXAZ +#import "AztecReader.h" +#endif @interface RootViewController() @@ -30,14 +54,27 @@ - (IBAction)scanPressed:(id)sender { ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO]; + + NSMutableSet *readers = [[NSMutableSet alloc ] init]; + +#if ZXQR QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init]; - NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil]; + [readers addObject:qrcodeReader]; [qrcodeReader release]; +#endif + +#if ZXAZ + AztecReader *aztecReader = [[AztecReader alloc] init]; + [readers addObject:aztecReader]; + [aztecReader release]; +#endif + widController.readers = readers; [readers release]; + NSBundle *mainBundle = [NSBundle mainBundle]; widController.soundToPlay = - [NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO]; + [NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO]; [self presentModalViewController:widController animated:YES]; [widController release]; } diff --git a/iphone/ZXingWidget/Classes/AztecReader.h b/iphone/ZXingWidget/Classes/AztecReader.h new file mode 100644 index 000000000..ba9e94486 --- /dev/null +++ b/iphone/ZXingWidget/Classes/AztecReader.h @@ -0,0 +1,15 @@ +// +// AztecReader.h +// ZXingWidget +// +// Created by Lukas Stabe on 08.02.12. +// Copyright (c) 2012 EOS UPTRADE GmbH. All rights reserved. +// + +#import "FormatReader.h" + +@interface AztecReader : FormatReader + +- (id) init; + +@end diff --git a/iphone/ZXingWidget/Classes/AztecReader.mm b/iphone/ZXingWidget/Classes/AztecReader.mm new file mode 100644 index 000000000..227d74355 --- /dev/null +++ b/iphone/ZXingWidget/Classes/AztecReader.mm @@ -0,0 +1,25 @@ +// +// AztecReader.m +// ZXingWidget +// +// Created by Lukas Stabe on 08.02.12. +// Copyright (c) 2012 EOS UPTRADE GmbH. All rights reserved. +// + +#import "AztecReader.h" +#import + +@implementation AztecReader + +- (id)init { + zxing::aztec::AztecReader *reader = new zxing::aztec::AztecReader(); + + return [super initWithReader:reader]; +} + +- (zxing::Ref)decode:(zxing::Ref)grayImage andCallback:(zxing::Ref)callback { + //NSLog(@"no callbacks supported for aztec"); + return [self decode:grayImage]; +} + +@end diff --git a/iphone/ZXingWidget/Classes/CBarcodeFormat.h b/iphone/ZXingWidget/Classes/CBarcodeFormat.h index d661159ee..c4f255f5e 100644 --- a/iphone/ZXingWidget/Classes/CBarcodeFormat.h +++ b/iphone/ZXingWidget/Classes/CBarcodeFormat.h @@ -1,3 +1,5 @@ +// -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + #ifndef __CBARCODE_FORMAT_H__ #define __CBARCODE_FORMAT_H__ @@ -22,16 +24,17 @@ // This must remain parallel to zxing::BarcodeFormat. typedef enum BarcodeFormat { - BarcodeFormat_None = 0, - BarcodeFormat_QR_CODE, - BarcodeFormat_DATA_MATRIX, - BarcodeFormat_UPC_E, - BarcodeFormat_UPC_A, - BarcodeFormat_EAN_8, - BarcodeFormat_EAN_13, - BarcodeFormat_CODE_128, - BarcodeFormat_CODE_39, - BarcodeFormat_ITF + BarcodeFormat_None = 0, + BarcodeFormat_QR_CODE, + BarcodeFormat_DATA_MATRIX, + BarcodeFormat_UPC_E, + BarcodeFormat_UPC_A, + BarcodeFormat_EAN_8, + BarcodeFormat_EAN_13, + BarcodeFormat_CODE_128, + BarcodeFormat_CODE_39, + BarcodeFormat_ITF, + BarcodeFormat_AZTEC } BarcodeFormat; #endif // __CBARCODE_FORMAT_H__ diff --git a/iphone/ZXingWidget/Classes/CBarcodeFormat.mm b/iphone/ZXingWidget/Classes/CBarcodeFormat.mm index 060a98759..8351a3f05 100644 --- a/iphone/ZXingWidget/Classes/CBarcodeFormat.mm +++ b/iphone/ZXingWidget/Classes/CBarcodeFormat.mm @@ -1,3 +1,4 @@ +// -*- Mode: ObjC; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /** * Copyright 2011 Google, Inc. * @@ -22,28 +23,30 @@ BarcodeFormat CBarcodeFormatConvert(zxing::BarcodeFormat value); // The purpose of this function is to issue a warning when a value is added to // zxing::BarcodeFormat. BarcodeFormat CBarcodeFormatConvert(zxing::BarcodeFormat value) { - switch (value) { - case zxing::BarcodeFormat_None: - return BarcodeFormat_None; - case zxing::BarcodeFormat_QR_CODE: - return BarcodeFormat_QR_CODE; - case zxing::BarcodeFormat_DATA_MATRIX: - return BarcodeFormat_DATA_MATRIX; - case zxing::BarcodeFormat_UPC_E: - return BarcodeFormat_UPC_E; - case zxing::BarcodeFormat_UPC_A: - return BarcodeFormat_UPC_A; - case zxing::BarcodeFormat_EAN_8: - return BarcodeFormat_EAN_8; - case zxing::BarcodeFormat_EAN_13: - return BarcodeFormat_EAN_13; - case zxing::BarcodeFormat_CODE_128: - return BarcodeFormat_CODE_128; - case zxing::BarcodeFormat_CODE_39: - return BarcodeFormat_CODE_39; - case zxing::BarcodeFormat_ITF: - return BarcodeFormat_ITF; - } + switch (value) { + case zxing::BarcodeFormat_None: + return BarcodeFormat_None; + case zxing::BarcodeFormat_QR_CODE: + return BarcodeFormat_QR_CODE; + case zxing::BarcodeFormat_DATA_MATRIX: + return BarcodeFormat_DATA_MATRIX; + case zxing::BarcodeFormat_UPC_E: + return BarcodeFormat_UPC_E; + case zxing::BarcodeFormat_UPC_A: + return BarcodeFormat_UPC_A; + case zxing::BarcodeFormat_EAN_8: + return BarcodeFormat_EAN_8; + case zxing::BarcodeFormat_EAN_13: + return BarcodeFormat_EAN_13; + case zxing::BarcodeFormat_CODE_128: + return BarcodeFormat_CODE_128; + case zxing::BarcodeFormat_CODE_39: + return BarcodeFormat_CODE_39; + case zxing::BarcodeFormat_ITF: + return BarcodeFormat_ITF; + case zxing::BarcodeFormat_AZTEC: + return BarcodeFormat_AZTEC; + } return BarcodeFormat_None; } diff --git a/iphone/ZXingWidget/Classes/Decoder.mm b/iphone/ZXingWidget/Classes/Decoder.mm index 9959137b4..7a0056cfe 100644 --- a/iphone/ZXingWidget/Classes/Decoder.mm +++ b/iphone/ZXingWidget/Classes/Decoder.mm @@ -1,11 +1,6 @@ -// -// Decoder.m -// ZXing -// -// Created by Christian Brunschen on 31/03/2008. -// +// -*- Mode: ObjC; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /* - * Copyright 2008 ZXing authors + * Copyright 2008-2012 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +31,7 @@ class ZXingWidgetControllerCallback : public zxing::ResultPointCallback { private: Decoder* decoder; public: - ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {} +ZXingWidgetControllerCallback(Decoder* _decoder) : decoder(_decoder) {} void foundPossibleResultPoint(ResultPoint const& result) { CGPoint point; point.x = result.getX(); @@ -89,7 +84,7 @@ public: CGSize size = [image size]; #ifdef DEBUG NSLog(@"decoding: image is (%.1f x %.1f), cropRect is (%.1f,%.1f)x(%.1f,%.1f)", size.width, size.height, - cropRect.origin.x, cropRect.origin.y, cropRect.size.width, cropRect.size.height); + cropRect.origin.x, cropRect.origin.y, cropRect.size.width, cropRect.size.height); #endif float scale = fminf(1.0f, fmaxf(SUBSET_SIZE / cropRect.size.width, SUBSET_SIZE / cropRect.size.height)); CGPoint offset = CGPointMake(-cropRect.origin.x, -cropRect.origin.y); @@ -113,9 +108,9 @@ public: CGColorSpaceRef grayColorSpace = CGColorSpaceCreateDeviceGray(); CGContextRef ctx = - CGBitmapContextCreate(subsetData, subsetWidth, subsetHeight, - 8, subsetBytesPerRow, grayColorSpace, - kCGImageAlphaNone); + CGBitmapContextCreate(subsetData, subsetWidth, subsetHeight, + 8, subsetBytesPerRow, grayColorSpace, + kCGImageAlphaNone); CGColorSpaceRelease(grayColorSpace); CGContextSetInterpolationQuality(ctx, kCGInterpolationNone); CGContextSetAllowsAntialiasing(ctx, false); @@ -165,7 +160,7 @@ public: //NSSet *formatReaders = [FormatReader formatReaders]; NSSet *formatReaders = self.readers; Ref source - (new GreyscaleLuminanceSource(subsetData, subsetBytesPerRow, subsetHeight, 0, 0, subsetWidth, subsetHeight)); + (new GreyscaleLuminanceSource(subsetData, subsetBytesPerRow, subsetHeight, 0, 0, subsetWidth, subsetHeight)); Ref binarizer (new HybridBinarizer(source)); source = 0; @@ -185,15 +180,15 @@ public: NSMutableArray *points = nil; NSString *resultString = nil; try { - #ifdef DEBUG +#ifdef DEBUG NSLog(@"decoding gray image"); - #endif +#endif ResultPointCallback* callback_pointer(new ZXingWidgetControllerCallback(self)); Ref callback(callback_pointer); Ref result([reader decode:grayImage andCallback:callback]); - #ifdef DEBUG +#ifdef DEBUG NSLog(@"gray image decoded"); - #endif +#endif Ref resultText(result->getText()); const char *cString = resultText->getText().c_str(); @@ -212,12 +207,12 @@ public: } catch (ReaderException &rex) { #ifdef DEBUG NSLog(@"failed to decode, caught ReaderException '%s'", - rex.what()); + rex.what()); #endif } catch (IllegalArgumentException &iex) { #ifdef DEBUG NSLog(@"failed to decode, caught IllegalArgumentException '%s'", - iex.what()); + iex.what()); #endif } catch (...) { NSLog(@"Caught unknown exception!"); @@ -240,24 +235,24 @@ public: } #endif - free(subsetData); - self.subsetData = NULL; + free(subsetData); + self.subsetData = NULL; - // DONT COMMIT - // [decoderResult release]; - // decoderResult = nil; + // DONT COMMIT + // [decoderResult release]; + // decoderResult = nil; if (decoderResult) { [self performSelectorOnMainThread:@selector(didDecodeImage:) - withObject:[decoderResult copy] - waitUntilDone:NO]; + withObject:[decoderResult copy] + waitUntilDone:NO]; [decoderResult release]; returnCode = YES; } else { [self performSelectorOnMainThread:@selector(failedToDecodeImage:) - withObject:NSLocalizedString(@"Decoder BarcodeDetectionFailure", @"No barcode detected.") - waitUntilDone:NO]; + withObject:NSLocalizedString(@"Decoder BarcodeDetectionFailure", @"No barcode detected.") + waitUntilDone:NO]; } } diff --git a/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj b/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj index ca4a6c32a..2ca67fd41 100644 --- a/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj +++ b/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj @@ -122,12 +122,24 @@ 3B117EF1145B220A0035037B /* MonochromeRectangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B117EEF145B220A0035037B /* MonochromeRectangleDetector.cpp */; }; 3B117EF2145B220A0035037B /* WhiteRectangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B117EF0145B220A0035037B /* WhiteRectangleDetector.cpp */; }; 3B117EF5145B221D0035037B /* NotFoundException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B117EF4145B221D0035037B /* NotFoundException.cpp */; }; + 3B248F7D14EF3A660065F0DA /* GenericGF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F7914EF3A660065F0DA /* GenericGF.cpp */; }; + 3B248F7E14EF3A660065F0DA /* GenericGF.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F7A14EF3A660065F0DA /* GenericGF.h */; }; + 3B248F7F14EF3A660065F0DA /* GenericGFPoly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F7B14EF3A660065F0DA /* GenericGFPoly.cpp */; }; + 3B248F8014EF3A660065F0DA /* GenericGFPoly.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F7C14EF3A660065F0DA /* GenericGFPoly.h */; }; + 3B248F8E14EF3A980065F0DA /* AztecDetectorResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F8414EF3A980065F0DA /* AztecDetectorResult.cpp */; }; + 3B248F8F14EF3A980065F0DA /* AztecDetectorResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F8514EF3A980065F0DA /* AztecDetectorResult.h */; }; + 3B248F9014EF3A980065F0DA /* AztecReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F8614EF3A980065F0DA /* AztecReader.cpp */; }; + 3B248F9114EF3A980065F0DA /* AztecReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F8714EF3A980065F0DA /* AztecReader.h */; }; + 3B248F9214EF3A980065F0DA /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F8914EF3A980065F0DA /* Decoder.cpp */; }; + 3B248F9314EF3A980065F0DA /* Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F8A14EF3A980065F0DA /* Decoder.h */; }; + 3B248F9414EF3A980065F0DA /* Detector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F8C14EF3A980065F0DA /* Detector.cpp */; }; + 3B248F9514EF3A980065F0DA /* Detector.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F8D14EF3A980065F0DA /* Detector.h */; }; + 3B248F9814EF3AF80065F0DA /* AztecReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B248F9614EF3AF80065F0DA /* AztecReader.h */; }; + 3B248F9914EF3AF80065F0DA /* AztecReader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3B248F9714EF3AF80065F0DA /* AztecReader.mm */; }; 3B27C5D8144735CE005157C4 /* FormatException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B27C5D6144735CE005157C4 /* FormatException.cpp */; }; 3B27C5D9144735CE005157C4 /* FormatException.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B27C5D7144735CE005157C4 /* FormatException.h */; }; 3B27C5E1144735E6005157C4 /* CharacterSetECI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B27C5DB144735E6005157C4 /* CharacterSetECI.cpp */; }; 3B27C5E2144735E6005157C4 /* CharacterSetECI.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B27C5DC144735E6005157C4 /* CharacterSetECI.h */; }; - 3B27C5E3144735E6005157C4 /* ECI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B27C5DD144735E6005157C4 /* ECI.cpp */; }; - 3B27C5E4144735E6005157C4 /* ECI.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B27C5DE144735E6005157C4 /* ECI.h */; }; 3B27C5E5144735E6005157C4 /* StringUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B27C5DF144735E6005157C4 /* StringUtils.cpp */; }; 3B27C5E6144735E6005157C4 /* StringUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B27C5E0144735E6005157C4 /* StringUtils.h */; }; 3B72D96F12130EF6007CEF32 /* ResultPointCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B72D96D12130EF6007CEF32 /* ResultPointCallback.cpp */; }; @@ -173,10 +185,6 @@ E534596111987396000CB77F /* PerspectiveTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E53458D411987396000CB77F /* PerspectiveTransform.cpp */; }; E534596211987396000CB77F /* PerspectiveTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = E53458D511987396000CB77F /* PerspectiveTransform.h */; }; E534596311987396000CB77F /* Point.h in Headers */ = {isa = PBXBuildFile; fileRef = E53458D611987396000CB77F /* Point.h */; }; - E534596411987396000CB77F /* GF256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E53458D811987396000CB77F /* GF256.cpp */; }; - E534596511987396000CB77F /* GF256.h in Headers */ = {isa = PBXBuildFile; fileRef = E53458D911987396000CB77F /* GF256.h */; }; - E534596611987396000CB77F /* GF256Poly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E53458DA11987396000CB77F /* GF256Poly.cpp */; }; - E534596711987396000CB77F /* GF256Poly.h in Headers */ = {isa = PBXBuildFile; fileRef = E53458DB11987396000CB77F /* GF256Poly.h */; }; E534596811987396000CB77F /* ReedSolomonDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E53458DC11987396000CB77F /* ReedSolomonDecoder.cpp */; }; E534596911987396000CB77F /* ReedSolomonDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E53458DD11987396000CB77F /* ReedSolomonDecoder.h */; }; E534596A11987396000CB77F /* ReedSolomonException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E53458DE11987396000CB77F /* ReedSolomonException.cpp */; }; @@ -404,12 +412,24 @@ 3B117EEF145B220A0035037B /* MonochromeRectangleDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MonochromeRectangleDetector.cpp; path = detector/MonochromeRectangleDetector.cpp; sourceTree = ""; }; 3B117EF0145B220A0035037B /* WhiteRectangleDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WhiteRectangleDetector.cpp; path = detector/WhiteRectangleDetector.cpp; sourceTree = ""; }; 3B117EF4145B221D0035037B /* NotFoundException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotFoundException.cpp; sourceTree = ""; }; + 3B248F7914EF3A660065F0DA /* GenericGF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericGF.cpp; sourceTree = ""; }; + 3B248F7A14EF3A660065F0DA /* GenericGF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericGF.h; sourceTree = ""; }; + 3B248F7B14EF3A660065F0DA /* GenericGFPoly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericGFPoly.cpp; sourceTree = ""; }; + 3B248F7C14EF3A660065F0DA /* GenericGFPoly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericGFPoly.h; sourceTree = ""; }; + 3B248F8414EF3A980065F0DA /* AztecDetectorResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AztecDetectorResult.cpp; sourceTree = ""; }; + 3B248F8514EF3A980065F0DA /* AztecDetectorResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AztecDetectorResult.h; sourceTree = ""; }; + 3B248F8614EF3A980065F0DA /* AztecReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AztecReader.cpp; sourceTree = ""; }; + 3B248F8714EF3A980065F0DA /* AztecReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AztecReader.h; sourceTree = ""; }; + 3B248F8914EF3A980065F0DA /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decoder.cpp; sourceTree = ""; }; + 3B248F8A14EF3A980065F0DA /* Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decoder.h; sourceTree = ""; }; + 3B248F8C14EF3A980065F0DA /* Detector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Detector.cpp; sourceTree = ""; }; + 3B248F8D14EF3A980065F0DA /* Detector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Detector.h; sourceTree = ""; }; + 3B248F9614EF3AF80065F0DA /* AztecReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AztecReader.h; path = Classes/AztecReader.h; sourceTree = ""; }; + 3B248F9714EF3AF80065F0DA /* AztecReader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AztecReader.mm; path = Classes/AztecReader.mm; sourceTree = ""; }; 3B27C5D6144735CE005157C4 /* FormatException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatException.cpp; sourceTree = ""; }; 3B27C5D7144735CE005157C4 /* FormatException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatException.h; sourceTree = ""; }; 3B27C5DB144735E6005157C4 /* CharacterSetECI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CharacterSetECI.cpp; sourceTree = ""; }; 3B27C5DC144735E6005157C4 /* CharacterSetECI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterSetECI.h; sourceTree = ""; }; - 3B27C5DD144735E6005157C4 /* ECI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ECI.cpp; sourceTree = ""; }; - 3B27C5DE144735E6005157C4 /* ECI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ECI.h; sourceTree = ""; }; 3B27C5DF144735E6005157C4 /* StringUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringUtils.cpp; sourceTree = ""; }; 3B27C5E0144735E6005157C4 /* StringUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringUtils.h; sourceTree = ""; }; 3B72D96D12130EF6007CEF32 /* ResultPointCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResultPointCallback.cpp; sourceTree = ""; }; @@ -456,10 +476,6 @@ E53458D411987396000CB77F /* PerspectiveTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerspectiveTransform.cpp; sourceTree = ""; }; E53458D511987396000CB77F /* PerspectiveTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerspectiveTransform.h; sourceTree = ""; }; E53458D611987396000CB77F /* Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Point.h; sourceTree = ""; }; - E53458D811987396000CB77F /* GF256.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GF256.cpp; sourceTree = ""; }; - E53458D911987396000CB77F /* GF256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GF256.h; sourceTree = ""; }; - E53458DA11987396000CB77F /* GF256Poly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GF256Poly.cpp; sourceTree = ""; }; - E53458DB11987396000CB77F /* GF256Poly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GF256Poly.h; sourceTree = ""; }; E53458DC11987396000CB77F /* ReedSolomonDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReedSolomonDecoder.cpp; sourceTree = ""; }; E53458DD11987396000CB77F /* ReedSolomonDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReedSolomonDecoder.h; sourceTree = ""; }; E53458DE11987396000CB77F /* ReedSolomonException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReedSolomonException.cpp; sourceTree = ""; }; @@ -630,6 +646,8 @@ 08FB77AEFE84172EC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 3B248F9614EF3AF80065F0DA /* AztecReader.h */, + 3B248F9714EF3AF80065F0DA /* AztecReader.mm */, 1D603E6213E20AF1006F4B51 /* ArrayAndStringCategories.h */, 1D603E6313E20AF1006F4B51 /* ArrayAndStringCategories.m */, 1DFA090A13CE1A3900599044 /* CBarcodeFormat.h */, @@ -685,6 +703,37 @@ name = "Other Sources"; sourceTree = ""; }; + 3B248F8314EF3A980065F0DA /* aztec */ = { + isa = PBXGroup; + children = ( + 3B248F8414EF3A980065F0DA /* AztecDetectorResult.cpp */, + 3B248F8514EF3A980065F0DA /* AztecDetectorResult.h */, + 3B248F8614EF3A980065F0DA /* AztecReader.cpp */, + 3B248F8714EF3A980065F0DA /* AztecReader.h */, + 3B248F8814EF3A980065F0DA /* decoder */, + 3B248F8B14EF3A980065F0DA /* detector */, + ); + path = aztec; + sourceTree = ""; + }; + 3B248F8814EF3A980065F0DA /* decoder */ = { + isa = PBXGroup; + children = ( + 3B248F8914EF3A980065F0DA /* Decoder.cpp */, + 3B248F8A14EF3A980065F0DA /* Decoder.h */, + ); + path = decoder; + sourceTree = ""; + }; + 3B248F8B14EF3A980065F0DA /* detector */ = { + isa = PBXGroup; + children = ( + 3B248F8C14EF3A980065F0DA /* Detector.cpp */, + 3B248F8D14EF3A980065F0DA /* Detector.h */, + ); + path = detector; + sourceTree = ""; + }; E53458B311987396000CB77F /* CoreSrc */ = { isa = PBXGroup; children = ( @@ -697,6 +746,7 @@ E53458B411987396000CB77F /* zxing */ = { isa = PBXGroup; children = ( + 3B248F8314EF3A980065F0DA /* aztec */, 3B117EF4145B221D0035037B /* NotFoundException.cpp */, 3B27C5D6144735CE005157C4 /* FormatException.cpp */, 3B27C5D7144735CE005157C4 /* FormatException.h */, @@ -739,8 +789,6 @@ 3B117EF0145B220A0035037B /* WhiteRectangleDetector.cpp */, 3B27C5DB144735E6005157C4 /* CharacterSetECI.cpp */, 3B27C5DC144735E6005157C4 /* CharacterSetECI.h */, - 3B27C5DD144735E6005157C4 /* ECI.cpp */, - 3B27C5DE144735E6005157C4 /* ECI.h */, 3B27C5DF144735E6005157C4 /* StringUtils.cpp */, 3B27C5E0144735E6005157C4 /* StringUtils.h */, 3B81AAF6120F0A7E0022E5D4 /* GreyscaleRotatedLuminanceSource.cpp */, @@ -784,10 +832,10 @@ E53458D711987396000CB77F /* reedsolomon */ = { isa = PBXGroup; children = ( - E53458D811987396000CB77F /* GF256.cpp */, - E53458D911987396000CB77F /* GF256.h */, - E53458DA11987396000CB77F /* GF256Poly.cpp */, - E53458DB11987396000CB77F /* GF256Poly.h */, + 3B248F7914EF3A660065F0DA /* GenericGF.cpp */, + 3B248F7A14EF3A660065F0DA /* GenericGF.h */, + 3B248F7B14EF3A660065F0DA /* GenericGFPoly.cpp */, + 3B248F7C14EF3A660065F0DA /* GenericGFPoly.h */, E53458DC11987396000CB77F /* ReedSolomonDecoder.cpp */, E53458DD11987396000CB77F /* ReedSolomonDecoder.h */, E53458DE11987396000CB77F /* ReedSolomonException.cpp */, @@ -1051,8 +1099,6 @@ E534595E11987396000CB77F /* IllegalArgumentException.h in Headers */, E534596211987396000CB77F /* PerspectiveTransform.h in Headers */, E534596311987396000CB77F /* Point.h in Headers */, - E534596511987396000CB77F /* GF256.h in Headers */, - E534596711987396000CB77F /* GF256Poly.h in Headers */, E534596911987396000CB77F /* ReedSolomonDecoder.h in Headers */, E534596B11987396000CB77F /* ReedSolomonException.h in Headers */, E534596D11987396000CB77F /* Str.h in Headers */, @@ -1157,8 +1203,14 @@ 1D60412313E36C2D006F4B51 /* ISBNParsedResult.h in Headers */, 3B27C5D9144735CE005157C4 /* FormatException.h in Headers */, 3B27C5E2144735E6005157C4 /* CharacterSetECI.h in Headers */, - 3B27C5E4144735E6005157C4 /* ECI.h in Headers */, 3B27C5E6144735E6005157C4 /* StringUtils.h in Headers */, + 3B248F7E14EF3A660065F0DA /* GenericGF.h in Headers */, + 3B248F8014EF3A660065F0DA /* GenericGFPoly.h in Headers */, + 3B248F8F14EF3A980065F0DA /* AztecDetectorResult.h in Headers */, + 3B248F9114EF3A980065F0DA /* AztecReader.h in Headers */, + 3B248F9314EF3A980065F0DA /* Decoder.h in Headers */, + 3B248F9514EF3A980065F0DA /* Detector.h in Headers */, + 3B248F9814EF3AF80065F0DA /* AztecReader.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1291,8 +1343,6 @@ E534595B11987396000CB77F /* GridSampler.cpp in Sources */, E534595D11987396000CB77F /* IllegalArgumentException.cpp in Sources */, E534596111987396000CB77F /* PerspectiveTransform.cpp in Sources */, - E534596411987396000CB77F /* GF256.cpp in Sources */, - E534596611987396000CB77F /* GF256Poly.cpp in Sources */, E534596811987396000CB77F /* ReedSolomonDecoder.cpp in Sources */, E534596A11987396000CB77F /* ReedSolomonException.cpp in Sources */, E534596C11987396000CB77F /* Str.cpp in Sources */, @@ -1397,11 +1447,17 @@ 1D60412413E36C2D006F4B51 /* ISBNParsedResult.m in Sources */, 3B27C5D8144735CE005157C4 /* FormatException.cpp in Sources */, 3B27C5E1144735E6005157C4 /* CharacterSetECI.cpp in Sources */, - 3B27C5E3144735E6005157C4 /* ECI.cpp in Sources */, 3B27C5E5144735E6005157C4 /* StringUtils.cpp in Sources */, 3B117EF1145B220A0035037B /* MonochromeRectangleDetector.cpp in Sources */, 3B117EF2145B220A0035037B /* WhiteRectangleDetector.cpp in Sources */, 3B117EF5145B221D0035037B /* NotFoundException.cpp in Sources */, + 3B248F7D14EF3A660065F0DA /* GenericGF.cpp in Sources */, + 3B248F7F14EF3A660065F0DA /* GenericGFPoly.cpp in Sources */, + 3B248F8E14EF3A980065F0DA /* AztecDetectorResult.cpp in Sources */, + 3B248F9014EF3A980065F0DA /* AztecReader.cpp in Sources */, + 3B248F9214EF3A980065F0DA /* Decoder.cpp in Sources */, + 3B248F9414EF3A980065F0DA /* Detector.cpp in Sources */, + 3B248F9914EF3AF80065F0DA /* AztecReader.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1426,9 +1482,9 @@ "\"$(SDKROOT)/Developer/Library/Frameworks\"", "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", ); - "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; INFOPLIST_FILE = "ZXingTests-Info.plist"; OTHER_LDFLAGS = ( "-framework", @@ -1453,8 +1509,8 @@ "\"$(SDKROOT)/Developer/Library/Frameworks\"", "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", ); - "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; INFOPLIST_FILE = "ZXingTests-Info.plist"; OTHER_LDFLAGS = ( "-framework", @@ -1477,12 +1533,12 @@ COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = YES; EXPORTED_SYMBOLS_FILE = exportList; - "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ZXingWidget_Prefix.pch; GCC_SYMBOLS_PRIVATE_EXTERN = NO; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; HEADER_SEARCH_PATHS = ../../cpp/core/src; INSTALL_PATH = /usr/local/lib; LD_GENERATE_MAP_FILE = YES; @@ -1503,11 +1559,11 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ZXingWidget_Prefix.pch; GCC_SYMBOLS_PRIVATE_EXTERN = NO; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; HEADER_SEARCH_PATHS = ../../cpp/core/src; INSTALL_PATH = /usr/local/lib; PRODUCT_NAME = ZXingWidget; @@ -1523,9 +1579,9 @@ armv6, armv7, ); - "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_OPTIMIZATION_LEVEL = 0; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -1551,8 +1607,8 @@ armv6, armv7, ); - "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_C_LANGUAGE_STANDARD = c99; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES;