Merge lp:~dpm/qreator/qreator-touch-with-plugin into lp:qreator/touch

Proposed by David Planella on 2014-05-10
Status: Merged
Merged at revision: 18
Proposed branch: lp:~dpm/qreator/qreator-touch-with-plugin
Merge into: lp:qreator/touch
Diff against target: 20868 lines (+19349/-198)
215 files modified
.bzrignore (+4/-0)
3rdParty/CMakeLists.txt (+1/-0)
3rdParty/lib.pro (+2/-0)
3rdParty/zxing/BarcodeFormat.cpp (+37/-0)
3rdParty/zxing/BarcodeFormat.h (+44/-0)
3rdParty/zxing/Binarizer.cpp (+37/-0)
3rdParty/zxing/Binarizer.h (+46/-0)
3rdParty/zxing/BinaryBitmap.cpp (+67/-0)
3rdParty/zxing/BinaryBitmap.h (+57/-0)
3rdParty/zxing/CMakeLists.txt (+110/-0)
3rdParty/zxing/DecodeHints.cpp (+120/-0)
3rdParty/zxing/DecodeHints.h (+72/-0)
3rdParty/zxing/Exception.cpp (+40/-0)
3rdParty/zxing/Exception.h (+40/-0)
3rdParty/zxing/FormatException.cpp (+35/-0)
3rdParty/zxing/FormatException.h (+35/-0)
3rdParty/zxing/LuminanceSource.cpp (+80/-0)
3rdParty/zxing/LuminanceSource.h (+52/-0)
3rdParty/zxing/MultiFormatReader.cpp (+106/-0)
3rdParty/zxing/MultiFormatReader.h (+49/-0)
3rdParty/zxing/NotFoundException.cpp (+28/-0)
3rdParty/zxing/NotFoundException.h (+33/-0)
3rdParty/zxing/Reader.cpp (+31/-0)
3rdParty/zxing/Reader.h (+40/-0)
3rdParty/zxing/ReaderException.cpp (+35/-0)
3rdParty/zxing/ReaderException.h (+35/-0)
3rdParty/zxing/Result.cpp (+64/-0)
3rdParty/zxing/Result.h (+54/-0)
3rdParty/zxing/ResultPoint.cpp (+100/-0)
3rdParty/zxing/ResultPoint.h (+54/-0)
3rdParty/zxing/ResultPointCallback.cpp (+26/-0)
3rdParty/zxing/ResultPointCallback.h (+39/-0)
3rdParty/zxing/aztec/AztecDetectorResult.cpp (+45/-0)
3rdParty/zxing/aztec/AztecDetectorResult.h (+42/-0)
3rdParty/zxing/aztec/AztecReader.cpp (+64/-0)
3rdParty/zxing/aztec/AztecReader.h (+49/-0)
3rdParty/zxing/aztec/decoder/AztecDecoder.cpp (+496/-0)
3rdParty/zxing/aztec/decoder/Decoder.h (+63/-0)
3rdParty/zxing/aztec/detector/AztecDetector.cpp (+541/-0)
3rdParty/zxing/aztec/detector/Detector.h (+87/-0)
3rdParty/zxing/common/Array.cpp (+22/-0)
3rdParty/zxing/common/Array.h (+208/-0)
3rdParty/zxing/common/BitArray.cpp (+127/-0)
3rdParty/zxing/common/BitArray.h (+70/-0)
3rdParty/zxing/common/BitMatrix.cpp (+157/-0)
3rdParty/zxing/common/BitMatrix.h (+87/-0)
3rdParty/zxing/common/BitSource.cpp (+74/-0)
3rdParty/zxing/common/BitSource.h (+70/-0)
3rdParty/zxing/common/CharacterSetECI.cpp (+104/-0)
3rdParty/zxing/common/CharacterSetECI.h (+53/-0)
3rdParty/zxing/common/Counted.cpp (+32/-0)
3rdParty/zxing/common/Counted.h (+202/-0)
3rdParty/zxing/common/DecoderResult.cpp (+46/-0)
3rdParty/zxing/common/DecoderResult.h (+51/-0)
3rdParty/zxing/common/DetectorResult.cpp (+38/-0)
3rdParty/zxing/common/DetectorResult.h (+43/-0)
3rdParty/zxing/common/EdgeDetector.cpp (+191/-0)
3rdParty/zxing/common/EdgeDetector.h (+38/-0)
3rdParty/zxing/common/GlobalHistogramBinarizer.cpp (+209/-0)
3rdParty/zxing/common/GlobalHistogramBinarizer.h (+47/-0)
3rdParty/zxing/common/GreyscaleLuminanceSource.cpp (+70/-0)
3rdParty/zxing/common/GreyscaleLuminanceSource.h (+62/-0)
3rdParty/zxing/common/GreyscaleRotatedLuminanceSource.cpp (+65/-0)
3rdParty/zxing/common/GreyscaleRotatedLuminanceSource.h (+60/-0)
3rdParty/zxing/common/GridSampler.cpp (+122/-0)
3rdParty/zxing/common/GridSampler.h (+45/-0)
3rdParty/zxing/common/HybridBinarizer.cpp (+221/-0)
3rdParty/zxing/common/HybridBinarizer.h (+68/-0)
3rdParty/zxing/common/IllegalArgumentException.cpp (+31/-0)
3rdParty/zxing/common/IllegalArgumentException.h (+33/-0)
3rdParty/zxing/common/PerspectiveTransform.cpp (+107/-0)
3rdParty/zxing/common/PerspectiveTransform.h (+49/-0)
3rdParty/zxing/common/Point.h (+47/-0)
3rdParty/zxing/common/Str.cpp (+38/-0)
3rdParty/zxing/common/Str.h (+40/-0)
3rdParty/zxing/common/StringUtils.cpp (+198/-0)
3rdParty/zxing/common/StringUtils.h (+52/-0)
3rdParty/zxing/common/detector/MonochromeRectangleDetector.cpp (+171/-0)
3rdParty/zxing/common/detector/MonochromeRectangleDetector.h (+60/-0)
3rdParty/zxing/common/detector/WhiteRectangleDetector.cpp (+336/-0)
3rdParty/zxing/common/detector/WhiteRectangleDetector.h (+61/-0)
3rdParty/zxing/common/reedsolomon/GenericGF.cpp (+147/-0)
3rdParty/zxing/common/reedsolomon/GenericGF.h (+78/-0)
3rdParty/zxing/common/reedsolomon/GenericGFPoly.cpp (+215/-0)
3rdParty/zxing/common/reedsolomon/GenericGFPoly.h (+54/-0)
3rdParty/zxing/common/reedsolomon/ReedSolomonDecoder.cpp (+199/-0)
3rdParty/zxing/common/reedsolomon/ReedSolomonDecoder.h (+48/-0)
3rdParty/zxing/common/reedsolomon/ReedSolomonException.cpp (+30/-0)
3rdParty/zxing/common/reedsolomon/ReedSolomonException.h (+33/-0)
3rdParty/zxing/datamatrix/DataMatrixReader.cpp (+84/-0)
3rdParty/zxing/datamatrix/DataMatrixReader.h (+45/-0)
3rdParty/zxing/datamatrix/DataMatrixVersion.cpp (+199/-0)
3rdParty/zxing/datamatrix/Version.h (+87/-0)
3rdParty/zxing/datamatrix/decoder/BitMatrixParser.h (+59/-0)
3rdParty/zxing/datamatrix/decoder/DataBlock.h (+49/-0)
3rdParty/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp (+361/-0)
3rdParty/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp (+113/-0)
3rdParty/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp (+417/-0)
3rdParty/zxing/datamatrix/decoder/DataMatrixDecoder.cpp (+94/-0)
3rdParty/zxing/datamatrix/decoder/DecodedBitStreamParser.h (+104/-0)
3rdParty/zxing/datamatrix/decoder/Decoder.h (+49/-0)
3rdParty/zxing/datamatrix/detector/CornerPoint.h (+43/-0)
3rdParty/zxing/datamatrix/detector/DataMatrixCornerPoint.cpp (+46/-0)
3rdParty/zxing/datamatrix/detector/DataMatrixDetector.cpp (+434/-0)
3rdParty/zxing/datamatrix/detector/DataMatrixDetectorException.cpp (+23/-0)
3rdParty/zxing/datamatrix/detector/DataMatrixMonochromeRectangleDetector.cpp (+172/-0)
3rdParty/zxing/datamatrix/detector/Detector.h (+94/-0)
3rdParty/zxing/datamatrix/detector/DetectorException.h (+23/-0)
3rdParty/zxing/datamatrix/detector/MonochromeRectangleDetector.h (+61/-0)
3rdParty/zxing/multi/ByQuadrantReader.cpp (+71/-0)
3rdParty/zxing/multi/ByQuadrantReader.h (+40/-0)
3rdParty/zxing/multi/GenericMultipleBarcodeReader.cpp (+128/-0)
3rdParty/zxing/multi/GenericMultipleBarcodeReader.h (+47/-0)
3rdParty/zxing/multi/MultipleBarcodeReader.cpp (+29/-0)
3rdParty/zxing/multi/MultipleBarcodeReader.h (+39/-0)
3rdParty/zxing/multi/qrcode/QRCodeMultiReader.cpp (+57/-0)
3rdParty/zxing/multi/qrcode/QRCodeMultiReader.h (+34/-0)
3rdParty/zxing/multi/qrcode/detector/MultiDetector.cpp (+46/-0)
3rdParty/zxing/multi/qrcode/detector/MultiDetector.h (+35/-0)
3rdParty/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp (+230/-0)
3rdParty/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h (+45/-0)
3rdParty/zxing/oned/Code128Reader.cpp (+490/-0)
3rdParty/zxing/oned/Code128Reader.h (+60/-0)
3rdParty/zxing/oned/Code39Reader.cpp (+348/-0)
3rdParty/zxing/oned/Code39Reader.h (+58/-0)
3rdParty/zxing/oned/EAN13Reader.cpp (+99/-0)
3rdParty/zxing/oned/EAN13Reader.h (+44/-0)
3rdParty/zxing/oned/EAN8Reader.cpp (+72/-0)
3rdParty/zxing/oned/EAN8Reader.h (+41/-0)
3rdParty/zxing/oned/ITFReader.cpp (+367/-0)
3rdParty/zxing/oned/ITFReader.h (+53/-0)
3rdParty/zxing/oned/MultiFormatOneDReader.cpp (+66/-0)
3rdParty/zxing/oned/MultiFormatOneDReader.h (+38/-0)
3rdParty/zxing/oned/MultiFormatUPCEANReader.cpp (+87/-0)
3rdParty/zxing/oned/MultiFormatUPCEANReader.h (+38/-0)
3rdParty/zxing/oned/OneDReader.cpp (+207/-0)
3rdParty/zxing/oned/OneDReader.h (+50/-0)
3rdParty/zxing/oned/OneDResultPoint.cpp (+28/-0)
3rdParty/zxing/oned/OneDResultPoint.h (+35/-0)
3rdParty/zxing/oned/UPCAReader.cpp (+65/-0)
3rdParty/zxing/oned/UPCAReader.h (+49/-0)
3rdParty/zxing/oned/UPCEANReader.cpp (+311/-0)
3rdParty/zxing/oned/UPCEANReader.h (+75/-0)
3rdParty/zxing/oned/UPCEReader.cpp (+147/-0)
3rdParty/zxing/oned/UPCEReader.h (+44/-0)
3rdParty/zxing/qrcode/ErrorCorrectionLevel.h (+52/-0)
3rdParty/zxing/qrcode/FormatInformation.h (+54/-0)
3rdParty/zxing/qrcode/QRCodeReader.cpp (+86/-0)
3rdParty/zxing/qrcode/QRCodeReader.h (+47/-0)
3rdParty/zxing/qrcode/QRErrorCorrectionLevel.cpp (+65/-0)
3rdParty/zxing/qrcode/QRFormatInformation.cpp (+118/-0)
3rdParty/zxing/qrcode/QRVersion.cpp (+557/-0)
3rdParty/zxing/qrcode/Version.h (+85/-0)
3rdParty/zxing/qrcode/decoder/BitMatrixParser.h (+56/-0)
3rdParty/zxing/qrcode/decoder/DataBlock.h (+50/-0)
3rdParty/zxing/qrcode/decoder/DataMask.h (+50/-0)
3rdParty/zxing/qrcode/decoder/DecodedBitStreamParser.h (+72/-0)
3rdParty/zxing/qrcode/decoder/Decoder.h (+46/-0)
3rdParty/zxing/qrcode/decoder/Mode.h (+58/-0)
3rdParty/zxing/qrcode/decoder/QRBitMatrixParser.cpp (+186/-0)
3rdParty/zxing/qrcode/decoder/QRDataBlock.cpp (+118/-0)
3rdParty/zxing/qrcode/decoder/QRDataMask.cpp (+159/-0)
3rdParty/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp (+416/-0)
3rdParty/zxing/qrcode/decoder/QRDecoder.cpp (+102/-0)
3rdParty/zxing/qrcode/decoder/QRMode.cpp (+86/-0)
3rdParty/zxing/qrcode/detector/AlignmentPattern.h (+45/-0)
3rdParty/zxing/qrcode/detector/AlignmentPatternFinder.h (+68/-0)
3rdParty/zxing/qrcode/detector/Detector.h (+66/-0)
3rdParty/zxing/qrcode/detector/FinderPattern.h (+47/-0)
3rdParty/zxing/qrcode/detector/FinderPatternFinder.h (+71/-0)
3rdParty/zxing/qrcode/detector/FinderPatternInfo.h (+47/-0)
3rdParty/zxing/qrcode/detector/QRAlignmentPattern.cpp (+51/-0)
3rdParty/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp (+209/-0)
3rdParty/zxing/qrcode/detector/QRDetector.cpp (+298/-0)
3rdParty/zxing/qrcode/detector/QREdgeDetector.cpp (+168/-0)
3rdParty/zxing/qrcode/detector/QREdgeDetector.h (+48/-0)
3rdParty/zxing/qrcode/detector/QRFinderPattern.cpp (+71/-0)
3rdParty/zxing/qrcode/detector/QRFinderPatternFinder.cpp (+541/-0)
3rdParty/zxing/qrcode/detector/QRFinderPatternInfo.cpp (+41/-0)
3rdParty/zxing/zxing.pro (+199/-0)
CMakeLists.txt (+43/-0)
com.ubuntu.developer.dplanella.qreator.desktop (+4/-4)
manifest.json (+15/-0)
qreator-touch.qmlproject (+0/-20)
qreator.json (+9/-0)
src/CMakeLists.txt (+2/-0)
src/app/CMakeLists.txt (+25/-0)
src/app/app.pro (+29/-0)
src/app/camerahelper.cpp (+65/-0)
src/app/camerahelper.h (+42/-0)
src/app/main.cpp (+64/-0)
src/app/qml/components/Decoder.qml (+19/-4)
src/app/qml/components/DeviceOrientation.qml (+5/-5)
src/app/qml/qrcodes/QrCodeText.qml (+1/-1)
src/app/qml/qrcodes/QrCodeUrl.qml (+1/-1)
src/app/qml/qrcodes/QrCodeWifi.qml (+16/-16)
src/app/qml/qreator.qml (+44/-63)
src/app/qml/ui/CreatorPage.qml (+32/-47)
src/app/qml/ui/QrCodeDialog.qml (+4/-0)
src/app/qml/ui/QrCodeToolbar.qml (+33/-12)
src/app/qml/ui/ScannerPage.qml (+36/-25)
src/plugin/CMakeLists.txt (+6/-0)
src/plugin/plugin.pro (+2/-0)
src/plugin/qzxing/CMakeLists.txt (+34/-0)
src/plugin/qzxing/CameraImageWrapper.cpp (+146/-0)
src/plugin/qzxing/CameraImageWrapper.h (+47/-0)
src/plugin/qzxing/plugins.qmltypes (+84/-0)
src/plugin/qzxing/qmldir (+3/-0)
src/plugin/qzxing/qzxing.cpp (+124/-0)
src/plugin/qzxing/qzxing.h (+79/-0)
src/plugin/qzxing/qzxing.pro (+51/-0)
src/plugin/qzxing/qzxing_global.h (+12/-0)
src/plugin/qzxing/qzxing_plugin.cpp (+17/-0)
src/plugin/qzxing/qzxing_plugin.h (+21/-0)
src/src.pro (+2/-0)
To merge this branch: bzr merge lp:~dpm/qreator/qreator-touch-with-plugin
Reviewer Review Type Date Requested Status
Qreator Hackers 2014-05-10 Pending
Review via email: mp+219101@code.launchpad.net

This proposal supersedes a proposal from 2014-05-10.

Description of the change

Initial merge of the QZXing plugin into the app's code, and conversion to CMake. Now the app and the plugin can be built and distributed together in a click package. The .deb packaging will still generate 2 independent packages, but it will probably require some more fixes.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2013-06-15 09:30:23 +0000
3+++ .bzrignore 2014-05-10 17:38:08 +0000
4@@ -1,3 +1,7 @@
5 qreator.qmlproject.user
6 qreator-touch.qmlproject.user
7 jsqrcode
8+plugins
9+.excludes
10+qreator.pro.user
11+CMakeLists.txt.user
12
13=== added directory '3rdParty'
14=== added file '3rdParty/CMakeLists.txt'
15--- 3rdParty/CMakeLists.txt 1970-01-01 00:00:00 +0000
16+++ 3rdParty/CMakeLists.txt 2014-05-10 17:38:08 +0000
17@@ -0,0 +1,1 @@
18+add_subdirectory(zxing)
19
20=== added file '3rdParty/lib.pro'
21--- 3rdParty/lib.pro 1970-01-01 00:00:00 +0000
22+++ 3rdParty/lib.pro 2014-05-10 17:38:08 +0000
23@@ -0,0 +1,2 @@
24+TEMPLATE = subdirs
25+SUBDIRS = zxing
26
27=== added directory '3rdParty/zxing'
28=== added file '3rdParty/zxing/BarcodeFormat.cpp'
29--- 3rdParty/zxing/BarcodeFormat.cpp 1970-01-01 00:00:00 +0000
30+++ 3rdParty/zxing/BarcodeFormat.cpp 2014-05-10 17:38:08 +0000
31@@ -0,0 +1,37 @@
32+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
33+/*
34+ * Created by Christian Brunschen on 13/05/2008.
35+ * Copyright 2008 ZXing authors All rights reserved.
36+ *
37+ * Licensed under the Apache License, Version 2.0 (the "License");
38+ * you may not use this file except in compliance with the License.
39+ * You may obtain a copy of the License at
40+ *
41+ * http://www.apache.org/licenses/LICENSE-2.0
42+ *
43+ * Unless required by applicable law or agreed to in writing, software
44+ * distributed under the License is distributed on an "AS IS" BASIS,
45+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46+ * See the License for the specific language governing permissions and
47+ * limitations under the License.
48+ */
49+
50+#include <zxing/BarcodeFormat.h>
51+
52+namespace zxing {
53+
54+const char *barcodeFormatNames[] = {
55+ "None",
56+ "QR_CODE",
57+ "DATA_MATRIX",
58+ "UPC_E",
59+ "UPC_A",
60+ "EAN_8",
61+ "EAN_13",
62+ "CODE_128",
63+ "CODE_39",
64+ "ITF",
65+ "AZTEC"
66+};
67+
68+}
69
70=== added file '3rdParty/zxing/BarcodeFormat.h'
71--- 3rdParty/zxing/BarcodeFormat.h 1970-01-01 00:00:00 +0000
72+++ 3rdParty/zxing/BarcodeFormat.h 2014-05-10 17:38:08 +0000
73@@ -0,0 +1,44 @@
74+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
75+#ifndef __BARCODE_FORMAT_H__
76+#define __BARCODE_FORMAT_H__
77+
78+/*
79+ * BarcodeFormat.h
80+ * zxing
81+ *
82+ * Copyright 2010 ZXing authors All rights reserved.
83+ *
84+ * Licensed under the Apache License, Version 2.0 (the "License");
85+ * you may not use this file except in compliance with the License.
86+ * You may obtain a copy of the License at
87+ *
88+ * http://www.apache.org/licenses/LICENSE-2.0
89+ *
90+ * Unless required by applicable law or agreed to in writing, software
91+ * distributed under the License is distributed on an "AS IS" BASIS,
92+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
93+ * See the License for the specific language governing permissions and
94+ * limitations under the License.
95+ */
96+
97+namespace zxing {
98+
99+ typedef enum BarcodeFormat {
100+ BarcodeFormat_None = 0,
101+ BarcodeFormat_QR_CODE,
102+ BarcodeFormat_DATA_MATRIX,
103+ BarcodeFormat_UPC_E,
104+ BarcodeFormat_UPC_A,
105+ BarcodeFormat_EAN_8,
106+ BarcodeFormat_EAN_13,
107+ BarcodeFormat_CODE_128,
108+ BarcodeFormat_CODE_39,
109+ BarcodeFormat_ITF,
110+ BarcodeFormat_AZTEC
111+ } BarcodeFormat;
112+
113+ /* if you update the enum, please update the name in BarcodeFormat.cpp */
114+ extern const char *barcodeFormatNames[];
115+}
116+
117+#endif // __BARCODE_FORMAT_H__
118
119=== added file '3rdParty/zxing/Binarizer.cpp'
120--- 3rdParty/zxing/Binarizer.cpp 1970-01-01 00:00:00 +0000
121+++ 3rdParty/zxing/Binarizer.cpp 2014-05-10 17:38:08 +0000
122@@ -0,0 +1,37 @@
123+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
124+/*
125+ * Binarizer.cpp
126+ * zxing
127+ *
128+ * Created by Ralf Kistner on 16/10/2009.
129+ * Copyright 2008 ZXing authors All rights reserved.
130+ * Modified by Lukasz Warchol on 02/02/2010.
131+ *
132+ * Licensed under the Apache License, Version 2.0 (the "License");
133+ * you may not use this file except in compliance with the License.
134+ * You may obtain a copy of the License at
135+ *
136+ * http://www.apache.org/licenses/LICENSE-2.0
137+ *
138+ * Unless required by applicable law or agreed to in writing, software
139+ * distributed under the License is distributed on an "AS IS" BASIS,
140+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141+ * See the License for the specific language governing permissions and
142+ * limitations under the License.
143+ */
144+
145+#include <zxing/Binarizer.h>
146+
147+namespace zxing {
148+
149+ Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source) {
150+ }
151+
152+ Binarizer::~Binarizer() {
153+ }
154+
155+ Ref<LuminanceSource> Binarizer::getLuminanceSource() const {
156+ return source_;
157+ }
158+
159+}
160
161=== added file '3rdParty/zxing/Binarizer.h'
162--- 3rdParty/zxing/Binarizer.h 1970-01-01 00:00:00 +0000
163+++ 3rdParty/zxing/Binarizer.h 2014-05-10 17:38:08 +0000
164@@ -0,0 +1,46 @@
165+#ifndef BINARIZER_H_
166+#define BINARIZER_H_
167+
168+/*
169+ * Binarizer.h
170+ * zxing
171+ *
172+ * Copyright 2010 ZXing authors All rights reserved.
173+ *
174+ * Licensed under the Apache License, Version 2.0 (the "License");
175+ * you may not use this file except in compliance with the License.
176+ * You may obtain a copy of the License at
177+ *
178+ * http://www.apache.org/licenses/LICENSE-2.0
179+ *
180+ * Unless required by applicable law or agreed to in writing, software
181+ * distributed under the License is distributed on an "AS IS" BASIS,
182+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183+ * See the License for the specific language governing permissions and
184+ * limitations under the License.
185+ */
186+
187+#include <zxing/LuminanceSource.h>
188+#include <zxing/common/BitArray.h>
189+#include <zxing/common/BitMatrix.h>
190+#include <zxing/common/Counted.h>
191+
192+namespace zxing {
193+
194+class Binarizer : public Counted {
195+ private:
196+ Ref<LuminanceSource> source_;
197+
198+ public:
199+ Binarizer(Ref<LuminanceSource> source);
200+ virtual ~Binarizer();
201+
202+ virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row) = 0;
203+ virtual Ref<BitMatrix> getBlackMatrix() = 0;
204+
205+ Ref<LuminanceSource> getLuminanceSource() const ;
206+ virtual Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source) = 0;
207+};
208+
209+}
210+#endif /* BINARIZER_H_ */
211
212=== added file '3rdParty/zxing/BinaryBitmap.cpp'
213--- 3rdParty/zxing/BinaryBitmap.cpp 1970-01-01 00:00:00 +0000
214+++ 3rdParty/zxing/BinaryBitmap.cpp 2014-05-10 17:38:08 +0000
215@@ -0,0 +1,67 @@
216+/*
217+ * BinaryBitmap.cpp
218+ * zxing
219+ *
220+ * Copyright 2010 ZXing authors All rights reserved.
221+ *
222+ * Licensed under the Apache License, Version 2.0 (the "License");
223+ * you may not use this file except in compliance with the License.
224+ * You may obtain a copy of the License at
225+ *
226+ * http://www.apache.org/licenses/LICENSE-2.0
227+ *
228+ * Unless required by applicable law or agreed to in writing, software
229+ * distributed under the License is distributed on an "AS IS" BASIS,
230+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
231+ * See the License for the specific language governing permissions and
232+ * limitations under the License.
233+ */
234+
235+#include <zxing/BinaryBitmap.h>
236+
237+namespace zxing {
238+
239+ BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : binarizer_(binarizer) {
240+
241+ }
242+
243+ BinaryBitmap::~BinaryBitmap() {
244+ }
245+
246+ Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
247+ return binarizer_->getBlackRow(y, row);
248+ }
249+
250+ Ref<BitMatrix> BinaryBitmap::getBlackMatrix() {
251+ return binarizer_->getBlackMatrix();
252+ }
253+
254+ int BinaryBitmap::getWidth() const {
255+ return getLuminanceSource()->getWidth();
256+ }
257+
258+ int BinaryBitmap::getHeight() const {
259+ return getLuminanceSource()->getHeight();
260+ }
261+
262+ Ref<LuminanceSource> BinaryBitmap::getLuminanceSource() const {
263+ return binarizer_->getLuminanceSource();
264+ }
265+
266+
267+ bool BinaryBitmap::isCropSupported() const {
268+ return getLuminanceSource()->isCropSupported();
269+ }
270+
271+ Ref<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height) {
272+ return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
273+ }
274+
275+ bool BinaryBitmap::isRotateSupported() const {
276+ return getLuminanceSource()->isRotateSupported();
277+ }
278+
279+ Ref<BinaryBitmap> BinaryBitmap::rotateCounterClockwise() {
280+ return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
281+ }
282+}
283
284=== added file '3rdParty/zxing/BinaryBitmap.h'
285--- 3rdParty/zxing/BinaryBitmap.h 1970-01-01 00:00:00 +0000
286+++ 3rdParty/zxing/BinaryBitmap.h 2014-05-10 17:38:08 +0000
287@@ -0,0 +1,57 @@
288+#ifndef __BINARYBITMAP_H__
289+#define __BINARYBITMAP_H__
290+
291+/*
292+ * BinaryBitmap.h
293+ * zxing
294+ *
295+ * Copyright 2010 ZXing authors All rights reserved.
296+ *
297+ * Licensed under the Apache License, Version 2.0 (the "License");
298+ * you may not use this file except in compliance with the License.
299+ * You may obtain a copy of the License at
300+ *
301+ * http://www.apache.org/licenses/LICENSE-2.0
302+ *
303+ * Unless required by applicable law or agreed to in writing, software
304+ * distributed under the License is distributed on an "AS IS" BASIS,
305+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
306+ * See the License for the specific language governing permissions and
307+ * limitations under the License.
308+ */
309+
310+#include <zxing/common/Counted.h>
311+#include <zxing/common/BitMatrix.h>
312+#include <zxing/common/BitArray.h>
313+#include <zxing/Binarizer.h>
314+
315+namespace zxing {
316+
317+ class BinaryBitmap : public Counted {
318+ private:
319+ Ref<Binarizer> binarizer_;
320+ int cached_y_;
321+
322+ public:
323+ BinaryBitmap(Ref<Binarizer> binarizer);
324+ virtual ~BinaryBitmap();
325+
326+ Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
327+ Ref<BitMatrix> getBlackMatrix();
328+
329+ Ref<LuminanceSource> getLuminanceSource() const;
330+
331+ int getWidth() const;
332+ int getHeight() const;
333+
334+ bool isRotateSupported() const;
335+ Ref<BinaryBitmap> rotateCounterClockwise();
336+
337+ bool isCropSupported() const;
338+ Ref<BinaryBitmap> crop(int left, int top, int width, int height);
339+
340+ };
341+
342+}
343+
344+#endif /* BINARYBITMAP_H_ */
345
346=== added file '3rdParty/zxing/CMakeLists.txt'
347--- 3rdParty/zxing/CMakeLists.txt 1970-01-01 00:00:00 +0000
348+++ 3rdParty/zxing/CMakeLists.txt 2014-05-10 17:38:08 +0000
349@@ -0,0 +1,110 @@
350+include_directories(
351+ ${CMAKE_CURRENT_SOURCE_DIR}/../
352+ /usr/include/qt5/QtCore/
353+ /usr/include/qt5/
354+)
355+
356+#get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
357+
358+add_definitions(
359+ -DNOFMAXL
360+ -DZXING_ICONV_CONST
361+ -DQZXING_LIBRARY
362+ #-DNO_ICONV
363+)
364+
365+#CONFIG += qt staticlib object_parallel_to_source
366+
367+#QMAKE_CXXFLAGS += -std=c++0x -fPIC
368+
369+SET(libzxing_SRCS
370+ ResultPointCallback.cpp
371+ ResultPoint.cpp
372+ Result.cpp
373+ ReaderException.cpp
374+ Reader.cpp
375+ NotFoundException.cpp
376+ MultiFormatReader.cpp
377+ LuminanceSource.cpp
378+ FormatException.cpp
379+ Exception.cpp
380+ DecodeHints.cpp
381+ BinaryBitmap.cpp
382+ Binarizer.cpp
383+ BarcodeFormat.cpp
384+ aztec/AztecReader.cpp
385+ aztec/AztecDetectorResult.cpp
386+ common/StringUtils.cpp
387+ common/Str.cpp
388+ common/PerspectiveTransform.cpp
389+ common/IllegalArgumentException.cpp
390+ common/HybridBinarizer.cpp
391+ common/GridSampler.cpp
392+ common/GreyscaleRotatedLuminanceSource.cpp
393+ common/GreyscaleLuminanceSource.cpp
394+ common/GlobalHistogramBinarizer.cpp
395+ common/EdgeDetector.cpp
396+ common/DetectorResult.cpp
397+ common/DecoderResult.cpp
398+ common/Counted.cpp
399+ common/CharacterSetECI.cpp
400+ common/BitSource.cpp
401+ common/BitMatrix.cpp
402+ common/BitArray.cpp
403+ common/Array.cpp
404+ common/detector/WhiteRectangleDetector.cpp
405+ common/detector/MonochromeRectangleDetector.cpp
406+ common/reedsolomon/ReedSolomonException.cpp
407+ common/reedsolomon/ReedSolomonDecoder.cpp
408+ common/reedsolomon/GenericGFPoly.cpp
409+ common/reedsolomon/GenericGF.cpp
410+ datamatrix/DataMatrixReader.cpp
411+ oned/UPCEReader.cpp
412+ oned/UPCEANReader.cpp
413+ oned/UPCAReader.cpp
414+ oned/OneDResultPoint.cpp
415+ oned/OneDReader.cpp
416+ oned/MultiFormatUPCEANReader.cpp
417+ oned/MultiFormatOneDReader.cpp
418+ oned/ITFReader.cpp
419+ oned/EAN13Reader.cpp
420+ oned/EAN8Reader.cpp
421+ oned/Code128Reader.cpp
422+ oned/Code39Reader.cpp
423+ qrcode/QRCodeReader.cpp
424+ qrcode/detector/QREdgeDetector.cpp
425+ multi/MultipleBarcodeReader.cpp
426+ multi/GenericMultipleBarcodeReader.cpp
427+ multi/ByQuadrantReader.cpp
428+ multi/qrcode/QRCodeMultiReader.cpp
429+ multi/qrcode/detector/MultiFinderPatternFinder.cpp
430+ multi/qrcode/detector/MultiDetector.cpp
431+ aztec/decoder/AztecDecoder.cpp
432+ aztec/detector/AztecDetector.cpp
433+ datamatrix/DataMatrixVersion.cpp
434+ datamatrix/decoder/DataMatrixDecoder.cpp
435+ datamatrix/decoder/DataMatrixBitMatrixParser.cpp
436+ datamatrix/decoder/DataMatrixDataBlock.cpp
437+ datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp
438+ datamatrix/detector/DataMatrixCornerPoint.cpp
439+ datamatrix/detector/DataMatrixDetector.cpp
440+ datamatrix/detector/DataMatrixDetectorException.cpp
441+ datamatrix/detector/DataMatrixMonochromeRectangleDetector.cpp
442+ qrcode/decoder/QRBitMatrixParser.cpp
443+ qrcode/decoder/QRDataBlock.cpp
444+ qrcode/decoder/QRDataMask.cpp
445+ qrcode/decoder/QRDecodedBitStreamParser.cpp
446+ qrcode/decoder/QRDecoder.cpp
447+ qrcode/decoder/QRMode.cpp
448+ qrcode/detector/QRAlignmentPattern.cpp
449+ qrcode/detector/QRAlignmentPatternFinder.cpp
450+ qrcode/detector/QRDetector.cpp
451+ qrcode/detector/QRFinderPattern.cpp
452+ qrcode/detector/QRFinderPatternFinder.cpp
453+ qrcode/detector/QRFinderPatternInfo.cpp
454+ qrcode/QRVersion.cpp
455+ qrcode/QRFormatInformation.cpp
456+ qrcode/QRErrorCorrectionLevel.cpp
457+)
458+
459+add_library(libzxing ${libzxing_SRCS})
460
461=== added file '3rdParty/zxing/DecodeHints.cpp'
462--- 3rdParty/zxing/DecodeHints.cpp 1970-01-01 00:00:00 +0000
463+++ 3rdParty/zxing/DecodeHints.cpp 2014-05-10 17:38:08 +0000
464@@ -0,0 +1,120 @@
465+/*
466+ * DecodeHintType.cpp
467+ * zxing
468+ *
469+ * Copyright 2010 ZXing authors All rights reserved.
470+ *
471+ * Licensed under the Apache License, Version 2.0 (the "License");
472+ * you may not use this file except in compliance with the License.
473+ * You may obtain a copy of the License at
474+ *
475+ * http://www.apache.org/licenses/LICENSE-2.0
476+ *
477+ * Unless required by applicable law or agreed to in writing, software
478+ * distributed under the License is distributed on an "AS IS" BASIS,
479+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480+ * See the License for the specific language governing permissions and
481+ * limitations under the License.
482+ */
483+
484+#include <zxing/DecodeHints.h>
485+#include <zxing/common/IllegalArgumentException.h>
486+namespace zxing {
487+
488+const DecodeHintType DecodeHints::CHARACTER_SET;
489+
490+const DecodeHints DecodeHints::PRODUCT_HINT(
491+ BARCODEFORMAT_UPC_E_HINT |
492+ BARCODEFORMAT_UPC_A_HINT |
493+ BARCODEFORMAT_EAN_8_HINT |
494+ BARCODEFORMAT_EAN_13_HINT);
495+
496+const DecodeHints DecodeHints::ONED_HINT(
497+ BARCODEFORMAT_UPC_E_HINT |
498+ BARCODEFORMAT_UPC_A_HINT |
499+ BARCODEFORMAT_EAN_8_HINT |
500+ BARCODEFORMAT_EAN_13_HINT |
501+ BARCODEFORMAT_CODE_128_HINT |
502+ BARCODEFORMAT_CODE_39_HINT |
503+ BARCODEFORMAT_ITF_HINT);
504+
505+const DecodeHints DecodeHints::DEFAULT_HINT(
506+ BARCODEFORMAT_UPC_E_HINT |
507+ BARCODEFORMAT_UPC_A_HINT |
508+ BARCODEFORMAT_EAN_8_HINT |
509+ BARCODEFORMAT_EAN_13_HINT |
510+ BARCODEFORMAT_CODE_128_HINT |
511+ BARCODEFORMAT_CODE_39_HINT |
512+ BARCODEFORMAT_ITF_HINT |
513+ BARCODEFORMAT_DATA_MATRIX_HINT |
514+ BARCODEFORMAT_AZTEC_HINT |
515+ BARCODEFORMAT_QR_CODE_HINT);
516+
517+DecodeHints::DecodeHints() {
518+ hints = 0;
519+}
520+
521+DecodeHints::DecodeHints(DecodeHintType init) {
522+ hints = init;
523+}
524+
525+void DecodeHints::addFormat(BarcodeFormat toadd) {
526+ switch (toadd) {
527+ case BarcodeFormat_AZTEC: hints |= BARCODEFORMAT_AZTEC_HINT; break;
528+ case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break;
529+ case BarcodeFormat_DATA_MATRIX: hints |= BARCODEFORMAT_DATA_MATRIX_HINT; break;
530+ case BarcodeFormat_UPC_E: hints |= BARCODEFORMAT_UPC_E_HINT; break;
531+ case BarcodeFormat_UPC_A: hints |= BARCODEFORMAT_UPC_A_HINT; break;
532+ case BarcodeFormat_EAN_8: hints |= BARCODEFORMAT_EAN_8_HINT; break;
533+ case BarcodeFormat_EAN_13: hints |= BARCODEFORMAT_EAN_13_HINT; break;
534+ case BarcodeFormat_CODE_128: hints |= BARCODEFORMAT_CODE_128_HINT; break;
535+ case BarcodeFormat_CODE_39: hints |= BARCODEFORMAT_CODE_39_HINT; break;
536+ case BarcodeFormat_ITF: hints |= BARCODEFORMAT_ITF_HINT; break;
537+ default: throw IllegalArgumentException("Unrecognizd barcode format");
538+ }
539+}
540+
541+bool DecodeHints::containsFormat(BarcodeFormat tocheck) const {
542+ DecodeHintType checkAgainst;
543+ switch (tocheck) {
544+ case BarcodeFormat_AZTEC: checkAgainst = BARCODEFORMAT_AZTEC_HINT; break;
545+ case BarcodeFormat_QR_CODE: checkAgainst = BARCODEFORMAT_QR_CODE_HINT; break;
546+ case BarcodeFormat_DATA_MATRIX: checkAgainst = BARCODEFORMAT_DATA_MATRIX_HINT; break;
547+ case BarcodeFormat_UPC_E: checkAgainst = BARCODEFORMAT_UPC_E_HINT; break;
548+ case BarcodeFormat_UPC_A: checkAgainst = BARCODEFORMAT_UPC_A_HINT; break;
549+ case BarcodeFormat_EAN_8: checkAgainst = BARCODEFORMAT_EAN_8_HINT; break;
550+ case BarcodeFormat_EAN_13: checkAgainst = BARCODEFORMAT_EAN_13_HINT; break;
551+ case BarcodeFormat_CODE_128: checkAgainst = BARCODEFORMAT_CODE_128_HINT; break;
552+ case BarcodeFormat_CODE_39: checkAgainst = BARCODEFORMAT_CODE_39_HINT; break;
553+ case BarcodeFormat_ITF: checkAgainst = BARCODEFORMAT_ITF_HINT; break;
554+ default: throw IllegalArgumentException("Unrecognizd barcode format");
555+ }
556+ return (hints & checkAgainst);
557+}
558+
559+void DecodeHints::setTryHarder(bool toset) {
560+ if (toset) {
561+ hints |= TRYHARDER_HINT;
562+ } else {
563+ hints &= ~TRYHARDER_HINT;
564+ }
565+}
566+
567+bool DecodeHints::getTryHarder() const {
568+ return (hints & TRYHARDER_HINT);
569+}
570+
571+void DecodeHints::setResultPointCallback(Ref<ResultPointCallback> const& _callback) {
572+ callback = _callback;
573+}
574+
575+Ref<ResultPointCallback> DecodeHints::getResultPointCallback() const {
576+ return callback;
577+}
578+
579+DecodeHintType DecodeHints::getCurrentHint()
580+{
581+ return hints;
582+}
583+
584+} /* namespace */
585
586=== added file '3rdParty/zxing/DecodeHints.h'
587--- 3rdParty/zxing/DecodeHints.h 1970-01-01 00:00:00 +0000
588+++ 3rdParty/zxing/DecodeHints.h 2014-05-10 17:38:08 +0000
589@@ -0,0 +1,72 @@
590+#ifndef __DECODEHINTS_H_
591+#define __DECODEHINTS_H_
592+/*
593+ * DecodeHintType.h
594+ * zxing
595+ *
596+ * Copyright 2010 ZXing authors All rights reserved.
597+ *
598+ * Licensed under the Apache License, Version 2.0 (the "License");
599+ * you may not use this file except in compliance with the License.
600+ * You may obtain a copy of the License at
601+ *
602+ * http://www.apache.org/licenses/LICENSE-2.0
603+ *
604+ * Unless required by applicable law or agreed to in writing, software
605+ * distributed under the License is distributed on an "AS IS" BASIS,
606+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
607+ * See the License for the specific language governing permissions and
608+ * limitations under the License.
609+ */
610+
611+#include <zxing/BarcodeFormat.h>
612+#include <zxing/ResultPointCallback.h>
613+
614+namespace zxing {
615+
616+typedef unsigned int DecodeHintType;
617+
618+class DecodeHints {
619+
620+ private:
621+
622+ DecodeHintType hints;
623+
624+ Ref<ResultPointCallback> callback;
625+
626+ public:
627+
628+ static const DecodeHintType BARCODEFORMAT_QR_CODE_HINT = 1 << BarcodeFormat_QR_CODE;
629+ static const DecodeHintType BARCODEFORMAT_DATA_MATRIX_HINT = 1 << BarcodeFormat_DATA_MATRIX;
630+ static const DecodeHintType BARCODEFORMAT_UPC_E_HINT = 1 << BarcodeFormat_UPC_E;
631+ static const DecodeHintType BARCODEFORMAT_UPC_A_HINT = 1 << BarcodeFormat_UPC_A;
632+ static const DecodeHintType BARCODEFORMAT_EAN_8_HINT = 1 << BarcodeFormat_EAN_8;
633+ static const DecodeHintType BARCODEFORMAT_EAN_13_HINT = 1 << BarcodeFormat_EAN_13;
634+ static const DecodeHintType BARCODEFORMAT_CODE_128_HINT = 1 << BarcodeFormat_CODE_128;
635+ static const DecodeHintType BARCODEFORMAT_CODE_39_HINT = 1 << BarcodeFormat_CODE_39;
636+ static const DecodeHintType BARCODEFORMAT_ITF_HINT = 1 << BarcodeFormat_ITF;
637+ static const DecodeHintType BARCODEFORMAT_AZTEC_HINT = 1 << BarcodeFormat_AZTEC;
638+ static const DecodeHintType CHARACTER_SET = 1 << 30;
639+ static const DecodeHintType TRYHARDER_HINT = 1 << 31;
640+
641+ static const DecodeHints PRODUCT_HINT;
642+ static const DecodeHints ONED_HINT;
643+ static const DecodeHints DEFAULT_HINT;
644+
645+ DecodeHints();
646+ DecodeHints(DecodeHintType init);
647+
648+ void addFormat(BarcodeFormat toadd);
649+ bool containsFormat(BarcodeFormat tocheck) const;
650+ void setTryHarder(bool toset);
651+ bool getTryHarder() const;
652+
653+ void setResultPointCallback(Ref<ResultPointCallback> const&);
654+ Ref<ResultPointCallback> getResultPointCallback() const;
655+
656+ DecodeHintType getCurrentHint();
657+};
658+
659+}
660+
661+#endif
662
663=== added file '3rdParty/zxing/Exception.cpp'
664--- 3rdParty/zxing/Exception.cpp 1970-01-01 00:00:00 +0000
665+++ 3rdParty/zxing/Exception.cpp 2014-05-10 17:38:08 +0000
666@@ -0,0 +1,40 @@
667+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
668+/*
669+ * Exception.cpp
670+ * ZXing
671+ *
672+ * Created by Christian Brunschen on 03/06/2008.
673+ * Copyright 2008-2011 ZXing authors All rights reserved.
674+ *
675+ * Licensed under the Apache License, Version 2.0 (the "License");
676+ * you may not use this file except in compliance with the License.
677+ * You may obtain a copy of the License at
678+ *
679+ * http://www.apache.org/licenses/LICENSE-2.0
680+ *
681+ * Unless required by applicable law or agreed to in writing, software
682+ * distributed under the License is distributed on an "AS IS" BASIS,
683+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
684+ * See the License for the specific language governing permissions and
685+ * limitations under the License.
686+
687+ */
688+
689+#include <zxing/Exception.h>
690+
691+namespace zxing {
692+
693+Exception::Exception() {}
694+
695+Exception::Exception(const char *msg) :
696+ message(msg) {
697+}
698+
699+const char* Exception::what() const throw() {
700+ return message.c_str();
701+}
702+
703+Exception::~Exception() throw() {
704+}
705+
706+}
707
708=== added file '3rdParty/zxing/Exception.h'
709--- 3rdParty/zxing/Exception.h 1970-01-01 00:00:00 +0000
710+++ 3rdParty/zxing/Exception.h 2014-05-10 17:38:08 +0000
711@@ -0,0 +1,40 @@
712+#ifndef __EXCEPTION_H__
713+#define __EXCEPTION_H__
714+
715+/*
716+ * Exception.h
717+ * ZXing
718+ *
719+ * Copyright 2010 ZXing authors All rights reserved.
720+ *
721+ * Licensed under the Apache License, Version 2.0 (the "License");
722+ * you may not use this file except in compliance with the License.
723+ * You may obtain a copy of the License at
724+ *
725+ * http://www.apache.org/licenses/LICENSE-2.0
726+ *
727+ * Unless required by applicable law or agreed to in writing, software
728+ * distributed under the License is distributed on an "AS IS" BASIS,
729+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
730+ * See the License for the specific language governing permissions and
731+ * limitations under the License.
732+ */
733+
734+#include <string>
735+#include <exception>
736+
737+namespace zxing {
738+
739+class Exception : public std::exception {
740+private:
741+ std::string message;
742+
743+public:
744+ Exception();
745+ Exception(const char *msg);
746+ virtual const char* what() const throw();
747+ virtual ~Exception() throw();
748+};
749+
750+}
751+#endif // __EXCEPTION_H__
752
753=== added file '3rdParty/zxing/FormatException.cpp'
754--- 3rdParty/zxing/FormatException.cpp 1970-01-01 00:00:00 +0000
755+++ 3rdParty/zxing/FormatException.cpp 2014-05-10 17:38:08 +0000
756@@ -0,0 +1,35 @@
757+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
758+/*
759+ * FormatException.cpp
760+ * zxing
761+ *
762+ * Created by Christian Brunschen on 13/05/2008.
763+ * Copyright 2008 ZXing authors All rights reserved.
764+ *
765+ * Licensed under the Apache License, Version 2.0 (the "License");
766+ * you may not use this file except in compliance with the License.
767+ * You may obtain a copy of the License at
768+ *
769+ * http://www.apache.org/licenses/LICENSE-2.0
770+ *
771+ * Unless required by applicable law or agreed to in writing, software
772+ * distributed under the License is distributed on an "AS IS" BASIS,
773+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
774+ * See the License for the specific language governing permissions and
775+ * limitations under the License.
776+ */
777+
778+#include <zxing/FormatException.h>
779+
780+namespace zxing {
781+
782+FormatException::FormatException() {}
783+
784+FormatException::FormatException(const char *msg) :
785+ ReaderException(msg) {
786+}
787+
788+FormatException::~FormatException() throw() {
789+}
790+
791+}
792
793=== added file '3rdParty/zxing/FormatException.h'
794--- 3rdParty/zxing/FormatException.h 1970-01-01 00:00:00 +0000
795+++ 3rdParty/zxing/FormatException.h 2014-05-10 17:38:08 +0000
796@@ -0,0 +1,35 @@
797+#ifndef __FORMAT_EXCEPTION_H__
798+#define __FORMAT_EXCEPTION_H__
799+
800+/*
801+ * FormatException.h
802+ * zxing
803+ *
804+ * Copyright 2010 ZXing authors All rights reserved.
805+ *
806+ * Licensed under the Apache License, Version 2.0 (the "License");
807+ * you may not use this file except in compliance with the License.
808+ * You may obtain a copy of the License at
809+ *
810+ * http://www.apache.org/licenses/LICENSE-2.0
811+ *
812+ * Unless required by applicable law or agreed to in writing, software
813+ * distributed under the License is distributed on an "AS IS" BASIS,
814+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
815+ * See the License for the specific language governing permissions and
816+ * limitations under the License.
817+ */
818+
819+#include <zxing/ReaderException.h>
820+
821+namespace zxing {
822+
823+class FormatException : public ReaderException {
824+public:
825+ FormatException();
826+ FormatException(const char *msg);
827+ ~FormatException() throw();
828+};
829+
830+}
831+#endif // __FORMAT_EXCEPTION_H__
832
833=== added file '3rdParty/zxing/LuminanceSource.cpp'
834--- 3rdParty/zxing/LuminanceSource.cpp 1970-01-01 00:00:00 +0000
835+++ 3rdParty/zxing/LuminanceSource.cpp 2014-05-10 17:38:08 +0000
836@@ -0,0 +1,80 @@
837+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
838+/*
839+ * LuminanceSource.cpp
840+ * zxing
841+ *
842+ * Copyright 2008 ZXing authors All rights reserved.
843+ *
844+ * Licensed under the Apache License, Version 2.0 (the "License");
845+ * you may not use this file except in compliance with the License.
846+ * You may obtain a copy of the License at
847+ *
848+ * http://www.apache.org/licenses/LICENSE-2.0
849+ *
850+ * Unless required by applicable law or agreed to in writing, software
851+ * distributed under the License is distributed on an "AS IS" BASIS,
852+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
853+ * See the License for the specific language governing permissions and
854+ * limitations under the License.
855+ */
856+
857+#include <sstream>
858+#include <zxing/LuminanceSource.h>
859+#include <zxing/common/IllegalArgumentException.h>
860+
861+namespace zxing {
862+
863+LuminanceSource::LuminanceSource() {
864+}
865+
866+LuminanceSource::~LuminanceSource() {
867+}
868+
869+bool LuminanceSource::isCropSupported() const {
870+ return false;
871+}
872+
873+Ref<LuminanceSource> LuminanceSource::crop(int left, int top, int width, int height) {
874+ (void)left;
875+ (void)top;
876+ (void)width;
877+ (void)height;
878+ throw IllegalArgumentException("This luminance source does not support cropping.");
879+}
880+
881+bool LuminanceSource::isRotateSupported() const {
882+ return false;
883+}
884+
885+Ref<LuminanceSource> LuminanceSource::rotateCounterClockwise() {
886+ throw IllegalArgumentException("This luminance source does not support rotation.");
887+}
888+
889+LuminanceSource::operator std::string() {
890+ unsigned char* row = 0;
891+ std::ostringstream oss;
892+ for (int y = 0; y < getHeight(); y++) {
893+ row = getRow(y, row);
894+ for (int x = 0; x < getWidth(); x++) {
895+ int luminance = row[x] & 0xFF;
896+ char c;
897+ if (luminance < 0x40) {
898+ c = '#';
899+ } else if (luminance < 0x80) {
900+ c = '+';
901+ } else if (luminance < 0xC0) {
902+ c = '.';
903+ } else {
904+ c = ' ';
905+ }
906+ oss << c;
907+ }
908+ oss << '\n';
909+ }
910+ delete [] row;
911+ return oss.str();
912+}
913+
914+
915+
916+}
917
918=== added file '3rdParty/zxing/LuminanceSource.h'
919--- 3rdParty/zxing/LuminanceSource.h 1970-01-01 00:00:00 +0000
920+++ 3rdParty/zxing/LuminanceSource.h 2014-05-10 17:38:08 +0000
921@@ -0,0 +1,52 @@
922+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
923+#ifndef __LUMINANCESOURCE_H__
924+#define __LUMINANCESOURCE_H__
925+/*
926+ * LuminanceSource.h
927+ * zxing
928+ *
929+ * Copyright 2010 ZXing authors All rights reserved.
930+ *
931+ * Licensed under the Apache License, Version 2.0 (the "License");
932+ * you may not use this file except in compliance with the License.
933+ * You may obtain a copy of the License at
934+ *
935+ * http://www.apache.org/licenses/LICENSE-2.0
936+ *
937+ * Unless required by applicable law or agreed to in writing, software
938+ * distributed under the License is distributed on an "AS IS" BASIS,
939+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
940+ * See the License for the specific language governing permissions and
941+ * limitations under the License.
942+ */
943+
944+#include <zxing/common/Counted.h>
945+#include <string.h>
946+
947+namespace zxing {
948+
949+class LuminanceSource : public Counted {
950+public:
951+ LuminanceSource();
952+ virtual ~LuminanceSource();
953+
954+ virtual int getWidth() const = 0;
955+ virtual int getHeight() const = 0;
956+
957+ // Callers take ownership of the returned memory and must call delete [] on it themselves.
958+ virtual unsigned char* getRow(int y, unsigned char* row) = 0;
959+ virtual unsigned char* getMatrix() = 0;
960+
961+ virtual bool isCropSupported() const;
962+ virtual Ref<LuminanceSource> crop(int left, int top, int width, int height);
963+
964+ virtual bool isRotateSupported() const;
965+ virtual Ref<LuminanceSource> rotateCounterClockwise();
966+
967+ operator std::string (); // should be const but don't want to make sure a
968+ // large breaking change right now
969+};
970+
971+}
972+
973+#endif /* LUMINANCESOURCE_H_ */
974
975=== added file '3rdParty/zxing/MultiFormatReader.cpp'
976--- 3rdParty/zxing/MultiFormatReader.cpp 1970-01-01 00:00:00 +0000
977+++ 3rdParty/zxing/MultiFormatReader.cpp 2014-05-10 17:38:08 +0000
978@@ -0,0 +1,106 @@
979+/*
980+ * MultiFormatBarcodeReader.cpp
981+ * ZXing
982+ *
983+ * Created by Lukasz Warchol on 10-01-26.
984+ * Modified by Luiz Silva on 09/02/2010.
985+ * Copyright 2010 ZXing authors All rights reserved.
986+ *
987+ * Licensed under the Apache License, Version 2.0 (the "License");
988+ * you may not use this file except in compliance with the License.
989+ * You may obtain a copy of the License at
990+ *
991+ * http://www.apache.org/licenses/LICENSE-2.0
992+ *
993+ * Unless required by applicable law or agreed to in writing, software
994+ * distributed under the License is distributed on an "AS IS" BASIS,
995+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
996+ * See the License for the specific language governing permissions and
997+ * limitations under the License.
998+ */
999+
1000+#include <zxing/MultiFormatReader.h>
1001+#include <zxing/qrcode/QRCodeReader.h>
1002+#include <zxing/datamatrix/DataMatrixReader.h>
1003+#include <zxing/aztec/AztecReader.h>
1004+#include <zxing/oned/MultiFormatUPCEANReader.h>
1005+#include <zxing/oned/MultiFormatOneDReader.h>
1006+#include <zxing/ReaderException.h>
1007+
1008+namespace zxing {
1009+ MultiFormatReader::MultiFormatReader() {
1010+
1011+ }
1012+
1013+ Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image) {
1014+ setHints(DecodeHints::DEFAULT_HINT);
1015+ return decodeInternal(image);
1016+ }
1017+
1018+ Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
1019+ setHints(hints);
1020+ return decodeInternal(image);
1021+ }
1022+
1023+ Ref<Result> MultiFormatReader::decodeWithState(Ref<BinaryBitmap> image) {
1024+ // Make sure to set up the default state so we don't crash
1025+ if (readers_.size() == 0) {
1026+ setHints(DecodeHints::DEFAULT_HINT);
1027+ }
1028+ return decodeInternal(image);
1029+ }
1030+
1031+ void MultiFormatReader::setHints(DecodeHints hints) {
1032+ hints_ = hints;
1033+ readers_.clear();
1034+ bool tryHarder = hints.getTryHarder();
1035+
1036+ bool addOneDReader = hints.containsFormat(BarcodeFormat_UPC_E) ||
1037+ hints.containsFormat(BarcodeFormat_UPC_A) ||
1038+ hints.containsFormat(BarcodeFormat_EAN_8) ||
1039+ hints.containsFormat(BarcodeFormat_EAN_13) ||
1040+ hints.containsFormat(BarcodeFormat_CODE_128) ||
1041+ hints.containsFormat(BarcodeFormat_CODE_39) ||
1042+ hints.containsFormat(BarcodeFormat_ITF);
1043+ if (addOneDReader && !tryHarder) {
1044+ readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
1045+ }
1046+ if (hints.containsFormat(BarcodeFormat_QR_CODE)) {
1047+ readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
1048+ }
1049+ if (hints.containsFormat(BarcodeFormat_DATA_MATRIX)) {
1050+ readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
1051+ }
1052+ if (hints.containsFormat(BarcodeFormat_AZTEC)) {
1053+ readers_.push_back(Ref<Reader>(new zxing::aztec::AztecReader()));
1054+ }
1055+ //TODO: add PDF417 here once PDF417 reader is implemented
1056+ if (addOneDReader && tryHarder) {
1057+ readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
1058+ }
1059+ if (readers_.size() == 0) {
1060+ if (!tryHarder) {
1061+ readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
1062+ }
1063+ readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
1064+ if (tryHarder) {
1065+ readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
1066+ }
1067+ }
1068+ }
1069+
1070+ Ref<Result> MultiFormatReader::decodeInternal(Ref<BinaryBitmap> image) {
1071+ for (unsigned int i = 0; i < readers_.size(); i++) {
1072+ try {
1073+ return readers_[i]->decode(image, hints_);
1074+ } catch (ReaderException const& re) {
1075+ // continue
1076+ }
1077+ }
1078+ throw ReaderException("No code detected");
1079+ }
1080+
1081+ MultiFormatReader::~MultiFormatReader() {
1082+
1083+ }
1084+}
1085
1086=== added file '3rdParty/zxing/MultiFormatReader.h'
1087--- 3rdParty/zxing/MultiFormatReader.h 1970-01-01 00:00:00 +0000
1088+++ 3rdParty/zxing/MultiFormatReader.h 2014-05-10 17:38:08 +0000
1089@@ -0,0 +1,49 @@
1090+#ifndef __MULTI_FORMAT_READER_H__
1091+#define __MULTI_FORMAT_READER_H__
1092+
1093+/*
1094+ * MultiFormatBarcodeReader.h
1095+ * ZXing
1096+ *
1097+ * Copyright 2010 ZXing authors All rights reserved.
1098+ *
1099+ * Licensed under the Apache License, Version 2.0 (the "License");
1100+ * you may not use this file except in compliance with the License.
1101+ * You may obtain a copy of the License at
1102+ *
1103+ * http://www.apache.org/licenses/LICENSE-2.0
1104+ *
1105+ * Unless required by applicable law or agreed to in writing, software
1106+ * distributed under the License is distributed on an "AS IS" BASIS,
1107+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1108+ * See the License for the specific language governing permissions and
1109+ * limitations under the License.
1110+ */
1111+
1112+
1113+#include <zxing/Reader.h>
1114+#include <zxing/common/BitArray.h>
1115+#include <zxing/Result.h>
1116+#include <zxing/DecodeHints.h>
1117+
1118+namespace zxing {
1119+ class MultiFormatReader : public Reader {
1120+
1121+ private:
1122+ Ref<Result> decodeInternal(Ref<BinaryBitmap> image);
1123+
1124+ std::vector<Ref<Reader> > readers_;
1125+ DecodeHints hints_;
1126+
1127+ public:
1128+ MultiFormatReader();
1129+
1130+ Ref<Result> decode(Ref<BinaryBitmap> image);
1131+ Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
1132+ Ref<Result> decodeWithState(Ref<BinaryBitmap> image);
1133+ void setHints(DecodeHints hints);
1134+ ~MultiFormatReader();
1135+ };
1136+}
1137+
1138+#endif
1139
1140=== added file '3rdParty/zxing/NotFoundException.cpp'
1141--- 3rdParty/zxing/NotFoundException.cpp 1970-01-01 00:00:00 +0000
1142+++ 3rdParty/zxing/NotFoundException.cpp 2014-05-10 17:38:08 +0000
1143@@ -0,0 +1,28 @@
1144+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1145+/*
1146+ * Copyright 20011 ZXing authors
1147+ *
1148+ * Licensed under the Apache License, Version 2.0 (the "License");
1149+ * you may not use this file except in compliance with the License.
1150+ * You may obtain a copy of the License at
1151+ *
1152+ * http://www.apache.org/licenses/LICENSE-2.0
1153+ *
1154+ * Unless required by applicable law or agreed to in writing, software
1155+ * distributed under the License is distributed on an "AS IS" BASIS,
1156+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1157+ * See the License for the specific language governing permissions and
1158+ * limitations under the License.
1159+ */
1160+
1161+#include <zxing/NotFoundException.h>
1162+
1163+namespace zxing {
1164+
1165+ NotFoundException::NotFoundException(const char *msg)
1166+ : ReaderException(msg) {}
1167+
1168+ NotFoundException::~NotFoundException() throw() {
1169+ }
1170+
1171+}
1172
1173=== added file '3rdParty/zxing/NotFoundException.h'
1174--- 3rdParty/zxing/NotFoundException.h 1970-01-01 00:00:00 +0000
1175+++ 3rdParty/zxing/NotFoundException.h 2014-05-10 17:38:08 +0000
1176@@ -0,0 +1,33 @@
1177+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1178+
1179+#ifndef __NOT_FOUND_EXCEPTION_H__
1180+#define __NOT_FOUND_EXCEPTION_H__
1181+
1182+/*
1183+ * Copyright 20011 ZXing authors
1184+ *
1185+ * Licensed under the Apache License, Version 2.0 (the "License");
1186+ * you may not use this file except in compliance with the License.
1187+ * You may obtain a copy of the License at
1188+ *
1189+ * http://www.apache.org/licenses/LICENSE-2.0
1190+ *
1191+ * Unless required by applicable law or agreed to in writing, software
1192+ * distributed under the License is distributed on an "AS IS" BASIS,
1193+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1194+ * See the License for the specific language governing permissions and
1195+ * limitations under the License.
1196+ */
1197+
1198+#include <zxing/ReaderException.h>
1199+
1200+namespace zxing {
1201+
1202+ class NotFoundException : public ReaderException {
1203+ public:
1204+ NotFoundException(const char *msg);
1205+ ~NotFoundException() throw();
1206+ };
1207+
1208+}
1209+#endif // __NOT_FOUND_EXCEPTION_H__
1210
1211=== added file '3rdParty/zxing/Reader.cpp'
1212--- 3rdParty/zxing/Reader.cpp 1970-01-01 00:00:00 +0000
1213+++ 3rdParty/zxing/Reader.cpp 2014-05-10 17:38:08 +0000
1214@@ -0,0 +1,31 @@
1215+/*
1216+ * Reader.cpp
1217+ * zxing
1218+ *
1219+ * Created by Christian Brunschen on 13/05/2008.
1220+ * Copyright 2008 ZXing authors All rights reserved.
1221+ *
1222+ * Licensed under the Apache License, Version 2.0 (the "License");
1223+ * you may not use this file except in compliance with the License.
1224+ * You may obtain a copy of the License at
1225+ *
1226+ * http://www.apache.org/licenses/LICENSE-2.0
1227+ *
1228+ * Unless required by applicable law or agreed to in writing, software
1229+ * distributed under the License is distributed on an "AS IS" BASIS,
1230+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1231+ * See the License for the specific language governing permissions and
1232+ * limitations under the License.
1233+ */
1234+
1235+#include <zxing/Reader.h>
1236+
1237+namespace zxing {
1238+
1239+Reader::~Reader() { }
1240+
1241+Ref<Result> Reader::decode(Ref<BinaryBitmap> image) {
1242+ return decode(image, DecodeHints::DEFAULT_HINT);
1243+}
1244+
1245+}
1246
1247=== added file '3rdParty/zxing/Reader.h'
1248--- 3rdParty/zxing/Reader.h 1970-01-01 00:00:00 +0000
1249+++ 3rdParty/zxing/Reader.h 2014-05-10 17:38:08 +0000
1250@@ -0,0 +1,40 @@
1251+#ifndef __READER_H__
1252+#define __READER_H__
1253+
1254+/*
1255+ * Reader.h
1256+ * zxing
1257+ *
1258+ * Copyright 2010 ZXing authors All rights reserved.
1259+ *
1260+ * Licensed under the Apache License, Version 2.0 (the "License");
1261+ * you may not use this file except in compliance with the License.
1262+ * You may obtain a copy of the License at
1263+ *
1264+ * http://www.apache.org/licenses/LICENSE-2.0
1265+ *
1266+ * Unless required by applicable law or agreed to in writing, software
1267+ * distributed under the License is distributed on an "AS IS" BASIS,
1268+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1269+ * See the License for the specific language governing permissions and
1270+ * limitations under the License.
1271+ */
1272+
1273+#include <zxing/BinaryBitmap.h>
1274+#include <zxing/Result.h>
1275+#include <zxing/DecodeHints.h>
1276+
1277+namespace zxing {
1278+
1279+ class Reader : public Counted {
1280+ protected:
1281+ Reader() {}
1282+ public:
1283+ virtual Ref<Result> decode(Ref<BinaryBitmap> image);
1284+ virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
1285+ virtual ~Reader();
1286+};
1287+
1288+}
1289+
1290+#endif // __READER_H__
1291
1292=== added file '3rdParty/zxing/ReaderException.cpp'
1293--- 3rdParty/zxing/ReaderException.cpp 1970-01-01 00:00:00 +0000
1294+++ 3rdParty/zxing/ReaderException.cpp 2014-05-10 17:38:08 +0000
1295@@ -0,0 +1,35 @@
1296+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1297+/*
1298+ * ReaderException.cpp
1299+ * zxing
1300+ *
1301+ * Created by Christian Brunschen on 13/05/2008.
1302+ * Copyright 2008-2011 ZXing authors All rights reserved.
1303+ *
1304+ * Licensed under the Apache License, Version 2.0 (the "License");
1305+ * you may not use this file except in compliance with the License.
1306+ * You may obtain a copy of the License at
1307+ *
1308+ * http://www.apache.org/licenses/LICENSE-2.0
1309+ *
1310+ * Unless required by applicable law or agreed to in writing, software
1311+ * distributed under the License is distributed on an "AS IS" BASIS,
1312+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313+ * See the License for the specific language governing permissions and
1314+ * limitations under the License.
1315+ */
1316+
1317+#include <zxing/ReaderException.h>
1318+
1319+namespace zxing {
1320+
1321+ReaderException::ReaderException() {}
1322+
1323+ReaderException::ReaderException(const char *msg) :
1324+ Exception(msg) {
1325+}
1326+
1327+ReaderException::~ReaderException() throw() {
1328+}
1329+
1330+}
1331
1332=== added file '3rdParty/zxing/ReaderException.h'
1333--- 3rdParty/zxing/ReaderException.h 1970-01-01 00:00:00 +0000
1334+++ 3rdParty/zxing/ReaderException.h 2014-05-10 17:38:08 +0000
1335@@ -0,0 +1,35 @@
1336+#ifndef __READER_EXCEPTION_H__
1337+#define __READER_EXCEPTION_H__
1338+
1339+/*
1340+ * ReaderException.h
1341+ * zxing
1342+ *
1343+ * Copyright 2010 ZXing authors All rights reserved.
1344+ *
1345+ * Licensed under the Apache License, Version 2.0 (the "License");
1346+ * you may not use this file except in compliance with the License.
1347+ * You may obtain a copy of the License at
1348+ *
1349+ * http://www.apache.org/licenses/LICENSE-2.0
1350+ *
1351+ * Unless required by applicable law or agreed to in writing, software
1352+ * distributed under the License is distributed on an "AS IS" BASIS,
1353+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1354+ * See the License for the specific language governing permissions and
1355+ * limitations under the License.
1356+ */
1357+
1358+#include <zxing/Exception.h>
1359+
1360+namespace zxing {
1361+
1362+class ReaderException : public Exception {
1363+public:
1364+ ReaderException();
1365+ ReaderException(const char *msg);
1366+ ~ReaderException() throw();
1367+};
1368+
1369+}
1370+#endif // __READER_EXCEPTION_H__
1371
1372=== added file '3rdParty/zxing/Result.cpp'
1373--- 3rdParty/zxing/Result.cpp 1970-01-01 00:00:00 +0000
1374+++ 3rdParty/zxing/Result.cpp 2014-05-10 17:38:08 +0000
1375@@ -0,0 +1,64 @@
1376+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1377+/*
1378+ * Result.cpp
1379+ * zxing
1380+ *
1381+ * Created by Christian Brunschen on 13/05/2008.
1382+ * Copyright 2008 ZXing authors All rights reserved.
1383+ *
1384+ * Licensed under the Apache License, Version 2.0 (the "License");
1385+ * you may not use this file except in compliance with the License.
1386+ * You may obtain a copy of the License at
1387+ *
1388+ * http://www.apache.org/licenses/LICENSE-2.0
1389+ *
1390+ * Unless required by applicable law or agreed to in writing, software
1391+ * distributed under the License is distributed on an "AS IS" BASIS,
1392+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1393+ * See the License for the specific language governing permissions and
1394+ * limitations under the License.
1395+ */
1396+
1397+#include <zxing/Result.h>
1398+
1399+namespace zxing {
1400+using namespace std;
1401+
1402+Result::Result(Ref<String> text, ArrayRef<unsigned char> rawBytes, std::vector<Ref<ResultPoint> > resultPoints,
1403+ BarcodeFormat format) :
1404+ text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format) {
1405+}
1406+
1407+Result::~Result() {
1408+}
1409+
1410+Ref<String> Result::getText() {
1411+ return text_;
1412+}
1413+
1414+ArrayRef<unsigned char> Result::getRawBytes() {
1415+ return rawBytes_;
1416+}
1417+
1418+const std::vector<Ref<ResultPoint> >& Result::getResultPoints() const {
1419+ return resultPoints_;
1420+}
1421+
1422+std::vector<Ref<ResultPoint> >& Result::getResultPoints() {
1423+ return resultPoints_;
1424+}
1425+
1426+BarcodeFormat Result::getBarcodeFormat() const {
1427+ return format_;
1428+}
1429+
1430+ostream& operator<<(ostream &out, Result& result) {
1431+ if (result.text_ != 0) {
1432+ out << result.text_->getText();
1433+ } else {
1434+ out << "[" << result.rawBytes_->size() << " bytes]";
1435+ }
1436+ return out;
1437+}
1438+
1439+}
1440
1441=== added file '3rdParty/zxing/Result.h'
1442--- 3rdParty/zxing/Result.h 1970-01-01 00:00:00 +0000
1443+++ 3rdParty/zxing/Result.h 2014-05-10 17:38:08 +0000
1444@@ -0,0 +1,54 @@
1445+#ifndef __RESULT_H__
1446+#define __RESULT_H__
1447+
1448+/*
1449+ * Result.h
1450+ * zxing
1451+ *
1452+ * Copyright 2010 ZXing authors All rights reserved.
1453+ *
1454+ * Licensed under the Apache License, Version 2.0 (the "License");
1455+ * you may not use this file except in compliance with the License.
1456+ * You may obtain a copy of the License at
1457+ *
1458+ * http://www.apache.org/licenses/LICENSE-2.0
1459+ *
1460+ * Unless required by applicable law or agreed to in writing, software
1461+ * distributed under the License is distributed on an "AS IS" BASIS,
1462+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1463+ * See the License for the specific language governing permissions and
1464+ * limitations under the License.
1465+ */
1466+
1467+#include <string>
1468+#include <vector>
1469+#include <zxing/common/Array.h>
1470+#include <zxing/common/Counted.h>
1471+#include <zxing/common/Str.h>
1472+#include <zxing/ResultPoint.h>
1473+#include <zxing/BarcodeFormat.h>
1474+
1475+namespace zxing {
1476+
1477+class Result : public Counted {
1478+private:
1479+ Ref<String> text_;
1480+ ArrayRef<unsigned char> rawBytes_;
1481+ std::vector<Ref<ResultPoint> > resultPoints_;
1482+ BarcodeFormat format_;
1483+
1484+public:
1485+ Result(Ref<String> text, ArrayRef<unsigned char> rawBytes, std::vector<Ref<ResultPoint> > resultPoints,
1486+ BarcodeFormat format);
1487+ ~Result();
1488+ Ref<String> getText();
1489+ ArrayRef<unsigned char> getRawBytes();
1490+ const std::vector<Ref<ResultPoint> >& getResultPoints() const;
1491+ std::vector<Ref<ResultPoint> >& getResultPoints();
1492+ BarcodeFormat getBarcodeFormat() const;
1493+
1494+ friend std::ostream& operator<<(std::ostream &out, Result& result);
1495+};
1496+
1497+}
1498+#endif // __RESULT_H__
1499
1500=== added file '3rdParty/zxing/ResultPoint.cpp'
1501--- 3rdParty/zxing/ResultPoint.cpp 1970-01-01 00:00:00 +0000
1502+++ 3rdParty/zxing/ResultPoint.cpp 2014-05-10 17:38:08 +0000
1503@@ -0,0 +1,100 @@
1504+/*
1505+ * ResultPoint.cpp
1506+ * zxing
1507+ *
1508+ * Created by Christian Brunschen on 13/05/2008.
1509+ * Copyright 2008 ZXing authors All rights reserved.
1510+ *
1511+ * Licensed under the Apache License, Version 2.0 (the "License");
1512+ * you may not use this file except in compliance with the License.
1513+ * You may obtain a copy of the License at
1514+ *
1515+ * http://www.apache.org/licenses/LICENSE-2.0
1516+ *
1517+ * Unless required by applicable law or agreed to in writing, software
1518+ * distributed under the License is distributed on an "AS IS" BASIS,
1519+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1520+ * See the License for the specific language governing permissions and
1521+ * limitations under the License.
1522+ */
1523+
1524+#include <zxing/ResultPoint.h>
1525+#include <math.h>
1526+
1527+namespace zxing {
1528+
1529+ResultPoint::ResultPoint() : posX_(0), posY_(0) {}
1530+
1531+ResultPoint::ResultPoint(float x, float y) : posX_(x), posY_(y) {}
1532+
1533+ResultPoint::~ResultPoint() {}
1534+
1535+float ResultPoint::getX() const {
1536+ return posX_;
1537+}
1538+
1539+float ResultPoint::getY() const {
1540+ return posY_;
1541+}
1542+
1543+bool ResultPoint::equals(Ref<ResultPoint> other) {
1544+ return posX_ == other->getX() && posY_ == other->getY();
1545+}
1546+
1547+/**
1548+ * <p>Orders an array of three ResultPoints in an order [A,B,C] such that AB < AC and
1549+ * BC < AC and the angle between BC and BA is less than 180 degrees.
1550+ */
1551+void ResultPoint::orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns) {
1552+ // Find distances between pattern centers
1553+ float zeroOneDistance = distance(patterns[0]->getX(), patterns[1]->getX(),patterns[0]->getY(), patterns[1]->getY());
1554+ float oneTwoDistance = distance(patterns[1]->getX(), patterns[2]->getX(),patterns[1]->getY(), patterns[2]->getY());
1555+ float zeroTwoDistance = distance(patterns[0]->getX(), patterns[2]->getX(),patterns[0]->getY(), patterns[2]->getY());
1556+
1557+ Ref<ResultPoint> pointA, pointB, pointC;
1558+ // Assume one closest to other two is B; A and C will just be guesses at first
1559+ if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
1560+ pointB = patterns[0];
1561+ pointA = patterns[1];
1562+ pointC = patterns[2];
1563+ } else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
1564+ pointB = patterns[1];
1565+ pointA = patterns[0];
1566+ pointC = patterns[2];
1567+ } else {
1568+ pointB = patterns[2];
1569+ pointA = patterns[0];
1570+ pointC = patterns[1];
1571+ }
1572+
1573+ // Use cross product to figure out whether A and C are correct or flipped.
1574+ // This asks whether BC x BA has a positive z component, which is the arrangement
1575+ // we want for A, B, C. If it's negative, then we've got it flipped around and
1576+ // should swap A and C.
1577+ if (crossProductZ(pointA, pointB, pointC) < 0.0f) {
1578+ Ref<ResultPoint> temp = pointA;
1579+ pointA = pointC;
1580+ pointC = temp;
1581+ }
1582+
1583+ patterns[0] = pointA;
1584+ patterns[1] = pointB;
1585+ patterns[2] = pointC;
1586+}
1587+
1588+float ResultPoint::distance(Ref<ResultPoint> point1, Ref<ResultPoint> point2) {
1589+ return distance(point1->getX(), point1->getY(), point2->getX(), point2->getY());
1590+}
1591+
1592+float ResultPoint::distance(float x1, float x2, float y1, float y2) {
1593+ float xDiff = x1 - x2;
1594+ float yDiff = y1 - y2;
1595+ return (float) sqrt((double) (xDiff * xDiff + yDiff * yDiff));
1596+}
1597+
1598+float ResultPoint::crossProductZ(Ref<ResultPoint> pointA, Ref<ResultPoint> pointB, Ref<ResultPoint> pointC) {
1599+ float bX = pointB->getX();
1600+ float bY = pointB->getY();
1601+ return ((pointC->getX() - bX) * (pointA->getY() - bY)) - ((pointC->getY() - bY) * (pointA->getX() - bX));
1602+}
1603+}
1604
1605=== added file '3rdParty/zxing/ResultPoint.h'
1606--- 3rdParty/zxing/ResultPoint.h 1970-01-01 00:00:00 +0000
1607+++ 3rdParty/zxing/ResultPoint.h 2014-05-10 17:38:08 +0000
1608@@ -0,0 +1,54 @@
1609+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1610+#ifndef __RESULT_POINT_H__
1611+#define __RESULT_POINT_H__
1612+
1613+/*
1614+ * ResultPoint.h
1615+ * zxing
1616+ *
1617+ * Copyright 2010 ZXing authors All rights reserved.
1618+ *
1619+ * Licensed under the Apache License, Version 2.0 (the "License");
1620+ * you may not use this file except in compliance with the License.
1621+ * You may obtain a copy of the License at
1622+ *
1623+ * http://www.apache.org/licenses/LICENSE-2.0
1624+ *
1625+ * Unless required by applicable law or agreed to in writing, software
1626+ * distributed under the License is distributed on an "AS IS" BASIS,
1627+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1628+ * See the License for the specific language governing permissions and
1629+ * limitations under the License.
1630+ */
1631+
1632+#include <zxing/common/Counted.h>
1633+#include <vector>
1634+
1635+namespace zxing {
1636+
1637+class ResultPoint : public Counted {
1638+protected:
1639+ float posX_;
1640+ float posY_;
1641+
1642+public:
1643+ ResultPoint();
1644+ ResultPoint(float x, float y);
1645+ virtual ~ResultPoint();
1646+
1647+ virtual float getX() const;
1648+ virtual float getY() const;
1649+
1650+ bool equals(Ref<ResultPoint> other);
1651+
1652+ static void orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns);
1653+ static float distance(Ref<ResultPoint> point1, Ref<ResultPoint> point2);
1654+ static float distance(float x1, float x2, float y1, float y2);
1655+
1656+private:
1657+ static float crossProductZ(Ref<ResultPoint> pointA, Ref<ResultPoint> pointB, Ref<ResultPoint> pointC);
1658+};
1659+
1660+}
1661+
1662+#endif // __RESULT_POINT_H__
1663
1664=== added file '3rdParty/zxing/ResultPointCallback.cpp'
1665--- 3rdParty/zxing/ResultPointCallback.cpp 1970-01-01 00:00:00 +0000
1666+++ 3rdParty/zxing/ResultPointCallback.cpp 2014-05-10 17:38:08 +0000
1667@@ -0,0 +1,26 @@
1668+/*
1669+ * ResultPointCallback.cpp
1670+ * zxing
1671+ *
1672+ * Copyright 2010 ZXing authors All rights reserved.
1673+ *
1674+ * Licensed under the Apache License, Version 2.0 (the "License");
1675+ * you may not use this file except in compliance with the License.
1676+ * You may obtain a copy of the License at
1677+ *
1678+ * http://www.apache.org/licenses/LICENSE-2.0
1679+ *
1680+ * Unless required by applicable law or agreed to in writing, software
1681+ * distributed under the License is distributed on an "AS IS" BASIS,
1682+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1683+ * See the License for the specific language governing permissions and
1684+ * limitations under the License.
1685+ */
1686+
1687+#include <zxing/ResultPointCallback.h>
1688+
1689+namespace zxing {
1690+
1691+ResultPointCallback::~ResultPointCallback() {}
1692+
1693+}
1694
1695=== added file '3rdParty/zxing/ResultPointCallback.h'
1696--- 3rdParty/zxing/ResultPointCallback.h 1970-01-01 00:00:00 +0000
1697+++ 3rdParty/zxing/ResultPointCallback.h 2014-05-10 17:38:08 +0000
1698@@ -0,0 +1,39 @@
1699+#ifndef __RESULT_POINT_CALLBACK_H__
1700+#define __RESULT_POINT_CALLBACK_H__
1701+
1702+/*
1703+ * ResultPointCallback.h
1704+ * zxing
1705+ *
1706+ * Copyright 2010 ZXing authors All rights reserved.
1707+ *
1708+ * Licensed under the Apache License, Version 2.0 (the "License");
1709+ * you may not use this file except in compliance with the License.
1710+ * You may obtain a copy of the License at
1711+ *
1712+ * http://www.apache.org/licenses/LICENSE-2.0
1713+ *
1714+ * Unless required by applicable law or agreed to in writing, software
1715+ * distributed under the License is distributed on an "AS IS" BASIS,
1716+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1717+ * See the License for the specific language governing permissions and
1718+ * limitations under the License.
1719+ */
1720+
1721+#include <zxing/common/Counted.h>
1722+
1723+namespace zxing {
1724+
1725+class ResultPoint;
1726+
1727+class ResultPointCallback : public Counted {
1728+protected:
1729+ ResultPointCallback() {}
1730+public:
1731+ virtual void foundPossibleResultPoint(ResultPoint const& point) = 0;
1732+ virtual ~ResultPointCallback();
1733+};
1734+
1735+}
1736+
1737+#endif // __RESULT_POINT_CALLBACK_H__
1738
1739=== added directory '3rdParty/zxing/aztec'
1740=== added file '3rdParty/zxing/aztec/AztecDetectorResult.cpp'
1741--- 3rdParty/zxing/aztec/AztecDetectorResult.cpp 1970-01-01 00:00:00 +0000
1742+++ 3rdParty/zxing/aztec/AztecDetectorResult.cpp 2014-05-10 17:38:08 +0000
1743@@ -0,0 +1,45 @@
1744+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1745+/*
1746+ * AtztecDetecorResult.cpp
1747+ * zxing
1748+ *
1749+ * Created by Lukas Stabe on 08/02/2012.
1750+ * Copyright 2012 ZXing authors All rights reserved.
1751+ *
1752+ * Licensed under the Apache License, Version 2.0 (the "License");
1753+ * you may not use this file except in compliance with the License.
1754+ * You may obtain a copy of the License at
1755+ *
1756+ * http://www.apache.org/licenses/LICENSE-2.0
1757+ *
1758+ * Unless required by applicable law or agreed to in writing, software
1759+ * distributed under the License is distributed on an "AS IS" BASIS,
1760+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1761+ * See the License for the specific language governing permissions and
1762+ * limitations under the License.
1763+ */
1764+
1765+#include <zxing/aztec/AztecDetectorResult.h>
1766+
1767+namespace zxing {
1768+ namespace aztec {
1769+ AztecDetectorResult::AztecDetectorResult(Ref<BitMatrix> bits, std::vector<Ref<ResultPoint> > points, bool compact, int nbDatablocks, int nbLayers)
1770+ : DetectorResult(bits, points),
1771+ compact_(compact),
1772+ nbDatablocks_(nbDatablocks),
1773+ nbLayers_(nbLayers) {
1774+ }
1775+
1776+ bool AztecDetectorResult::isCompact() {
1777+ return compact_;
1778+ }
1779+
1780+ int AztecDetectorResult::getNBDatablocks() {
1781+ return nbDatablocks_;
1782+ }
1783+
1784+ int AztecDetectorResult::getNBLayers() {
1785+ return nbLayers_;
1786+ }
1787+ }
1788+}
1789
1790=== added file '3rdParty/zxing/aztec/AztecDetectorResult.h'
1791--- 3rdParty/zxing/aztec/AztecDetectorResult.h 1970-01-01 00:00:00 +0000
1792+++ 3rdParty/zxing/aztec/AztecDetectorResult.h 2014-05-10 17:38:08 +0000
1793@@ -0,0 +1,42 @@
1794+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1795+/*
1796+ * AtztecDetecorResult.h
1797+ * zxing
1798+ *
1799+ * Created by Lukas Stabe on 08/02/2012.
1800+ * Copyright 2012 ZXing authors All rights reserved.
1801+ *
1802+ * Licensed under the Apache License, Version 2.0 (the "License");
1803+ * you may not use this file except in compliance with the License.
1804+ * You may obtain a copy of the License at
1805+ *
1806+ * http://www.apache.org/licenses/LICENSE-2.0
1807+ *
1808+ * Unless required by applicable law or agreed to in writing, software
1809+ * distributed under the License is distributed on an "AS IS" BASIS,
1810+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1811+ * See the License for the specific language governing permissions and
1812+ * limitations under the License.
1813+ */
1814+
1815+#include <zxing/common/DetectorResult.h>
1816+
1817+#ifndef ZXingWidget_AtztecDetecorResult_h
1818+#define ZXingWidget_AtztecDetecorResult_h
1819+
1820+namespace zxing {
1821+ namespace aztec {
1822+ class AztecDetectorResult : public DetectorResult {
1823+ private:
1824+ bool compact_;
1825+ int nbDatablocks_, nbLayers_;
1826+ public:
1827+ AztecDetectorResult(Ref<BitMatrix> bits, std::vector<Ref<ResultPoint> > points, bool compact, int nbDatablocks, int nbLayers);
1828+ bool isCompact();
1829+ int getNBDatablocks();
1830+ int getNBLayers();
1831+ };
1832+ }
1833+}
1834+
1835+#endif
1836
1837=== added file '3rdParty/zxing/aztec/AztecReader.cpp'
1838--- 3rdParty/zxing/aztec/AztecReader.cpp 1970-01-01 00:00:00 +0000
1839+++ 3rdParty/zxing/aztec/AztecReader.cpp 2014-05-10 17:38:08 +0000
1840@@ -0,0 +1,64 @@
1841+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1842+/*
1843+ * AztecReader.cpp
1844+ * zxing
1845+ *
1846+ * Created by Lukas Stabe on 08/02/2012.
1847+ * Copyright 2012 ZXing authors All rights reserved.
1848+ *
1849+ * Licensed under the Apache License, Version 2.0 (the "License");
1850+ * you may not use this file except in compliance with the License.
1851+ * You may obtain a copy of the License at
1852+ *
1853+ * http://www.apache.org/licenses/LICENSE-2.0
1854+ *
1855+ * Unless required by applicable law or agreed to in writing, software
1856+ * distributed under the License is distributed on an "AS IS" BASIS,
1857+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1858+ * See the License for the specific language governing permissions and
1859+ * limitations under the License.
1860+ */
1861+
1862+#include <zxing/aztec/AztecReader.h>
1863+#include <zxing/aztec/detector/Detector.h>
1864+#include <iostream>
1865+
1866+namespace zxing {
1867+ namespace aztec {
1868+
1869+ AztecReader::AztecReader() : decoder_() {
1870+ // nothing
1871+ }
1872+
1873+ Ref<Result> AztecReader::decode(Ref<zxing::BinaryBitmap> image) {
1874+ Detector detector(image->getBlackMatrix());
1875+
1876+ Ref<AztecDetectorResult> detectorResult(detector.detect());
1877+
1878+ std::vector<Ref<ResultPoint> > points(detectorResult->getPoints());
1879+
1880+ Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult));
1881+
1882+ Ref<Result> result(new Result(decoderResult->getText(),
1883+ decoderResult->getRawBytes(),
1884+ points,
1885+ BarcodeFormat_AZTEC));
1886+
1887+ return result;
1888+ }
1889+
1890+ Ref<Result> AztecReader::decode(Ref<BinaryBitmap> image, DecodeHints) {
1891+ //cout << "decoding with hints not supported for aztec" << "\n" << flush;
1892+ return this->decode(image);
1893+ }
1894+
1895+ AztecReader::~AztecReader() {
1896+ // nothing
1897+ }
1898+
1899+ Decoder& AztecReader::getDecoder() {
1900+ return decoder_;
1901+ }
1902+
1903+ }
1904+}
1905
1906=== added file '3rdParty/zxing/aztec/AztecReader.h'
1907--- 3rdParty/zxing/aztec/AztecReader.h 1970-01-01 00:00:00 +0000
1908+++ 3rdParty/zxing/aztec/AztecReader.h 2014-05-10 17:38:08 +0000
1909@@ -0,0 +1,49 @@
1910+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1911+/*
1912+ * AztecReader.h
1913+ * zxing
1914+ *
1915+ * Created by Lukas Stabe on 08/02/2012.
1916+ * Copyright 2012 ZXing authors All rights reserved.
1917+ *
1918+ * Licensed under the Apache License, Version 2.0 (the "License");
1919+ * you may not use this file except in compliance with the License.
1920+ * You may obtain a copy of the License at
1921+ *
1922+ * http://www.apache.org/licenses/LICENSE-2.0
1923+ *
1924+ * Unless required by applicable law or agreed to in writing, software
1925+ * distributed under the License is distributed on an "AS IS" BASIS,
1926+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1927+ * See the License for the specific language governing permissions and
1928+ * limitations under the License.
1929+ */
1930+
1931+#include <zxing/Reader.h>
1932+#include <zxing/aztec/decoder/Decoder.h>
1933+#include <zxing/DecodeHints.h>
1934+
1935+#ifndef ZXingWidget_AztecReader_h
1936+#define ZXingWidget_AztecReader_h
1937+
1938+namespace zxing {
1939+ namespace aztec {
1940+
1941+ class AztecReader : public Reader {
1942+ private:
1943+ Decoder decoder_;
1944+
1945+ protected:
1946+ Decoder &getDecoder();
1947+
1948+ public:
1949+ AztecReader();
1950+ virtual Ref<Result> decode(Ref<BinaryBitmap> image);
1951+ virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
1952+ virtual ~AztecReader();
1953+ };
1954+
1955+ }
1956+}
1957+
1958+#endif
1959
1960=== added directory '3rdParty/zxing/aztec/decoder'
1961=== added file '3rdParty/zxing/aztec/decoder/AztecDecoder.cpp'
1962--- 3rdParty/zxing/aztec/decoder/AztecDecoder.cpp 1970-01-01 00:00:00 +0000
1963+++ 3rdParty/zxing/aztec/decoder/AztecDecoder.cpp 2014-05-10 17:38:08 +0000
1964@@ -0,0 +1,496 @@
1965+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
1966+/*
1967+ * Decoder.cpp
1968+ * zxing
1969+ *
1970+ * Created by Lukas Stabe on 08/02/2012.
1971+ * Copyright 2012 ZXing authors All rights reserved.
1972+ *
1973+ * Licensed under the Apache License, Version 2.0 (the "License");
1974+ * you may not use this file except in compliance with the License.
1975+ * You may obtain a copy of the License at
1976+ *
1977+ * http://www.apache.org/licenses/LICENSE-2.0
1978+ *
1979+ * Unless required by applicable law or agreed to in writing, software
1980+ * distributed under the License is distributed on an "AS IS" BASIS,
1981+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1982+ * See the License for the specific language governing permissions and
1983+ * limitations under the License.
1984+ */
1985+
1986+#include <zxing/aztec/decoder/Decoder.h>
1987+#ifndef NO_ICONV
1988+#include <iconv.h>
1989+#endif
1990+#include <iostream>
1991+#include <zxing/FormatException.h>
1992+#include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
1993+#include <zxing/common/reedsolomon/ReedSolomonException.h>
1994+#include <zxing/common/reedsolomon/GenericGF.h>
1995+#include <zxing/common/IllegalArgumentException.h>
1996+
1997+#include <qglobal.h>
1998+
1999+using zxing::aztec::Decoder;
2000+using zxing::DecoderResult;
2001+using zxing::String;
2002+using zxing::BitArray;
2003+using zxing::BitMatrix;
2004+using zxing::Ref;
2005+
2006+using std::string;
2007+
2008+namespace {
2009+ void add(string& result, unsigned char character) {
2010+#ifndef NO_ICONV
2011+ char s[] = { character & 0xff };
2012+ char* ss = s;
2013+ size_t sl = sizeof(s);
2014+ char d[4];
2015+ char* ds = d;
2016+ size_t dl = sizeof(d);
2017+ iconv_t ic = iconv_open("UTF-8", "ISO-8859-1");
2018+
2019+
2020+#if defined(Q_OS_SYMBIAN)
2021+ iconv(ic, (const char**)&ss, &sl, &ds, &dl); // for Symbian and Mingw
2022+#else
2023+ iconv(ic, (char**)&ss, &sl, &ds, &dl); // for Harmattan
2024+#endif
2025+ iconv_close(ic);
2026+ d[sizeof(d)-dl] = 0;
2027+ result.append(d);
2028+#else
2029+ result.push_back(character);
2030+#endif
2031+ }
2032+
2033+ const int NB_BITS_COMPACT[] = {
2034+ 0, 104, 240, 408, 608
2035+ };
2036+
2037+ const int NB_BITS[] = {
2038+ 0, 128, 288, 480, 704, 960, 1248, 1568, 1920, 2304, 2720, 3168, 3648, 4160, 4704, 5280, 5888, 6528,
2039+ 7200, 7904, 8640, 9408, 10208, 11040, 11904, 12800, 13728, 14688, 15680, 16704, 17760, 18848, 19968
2040+ };
2041+
2042+ const int NB_DATABLOCK_COMPACT[] = {
2043+ 0, 17, 40, 51, 76
2044+ };
2045+
2046+ const int NB_DATABLOCK[] = {
2047+ 0, 21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790, 864,
2048+ 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664
2049+ };
2050+
2051+ const char* UPPER_TABLE[] = {
2052+ "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
2053+ "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS"
2054+ };
2055+
2056+ const char* LOWER_TABLE[] = {
2057+ "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
2058+ "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS"
2059+ };
2060+
2061+ const char* MIXED_TABLE[] = {
2062+ "CTRL_PS", " ", "\1", "\2", "\3", "\4", "\5", "\6", "\7", "\b", "\t", "\n",
2063+ "\13", "\f", "\r", "\33", "\34", "\35", "\36", "\37", "@", "\\", "^", "_",
2064+ "`", "|", "~", "\177", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS"
2065+ };
2066+
2067+ const char* PUNCT_TABLE[] = {
2068+ "", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")",
2069+ "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL"
2070+ };
2071+
2072+ const char* DIGIT_TABLE[] = {
2073+ "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US"
2074+ };
2075+}
2076+
2077+Decoder::Table Decoder::getTable(char t) {
2078+ switch (t) {
2079+ case 'L':
2080+ return LOWER;
2081+ case 'P':
2082+ return PUNCT;
2083+ case 'M':
2084+ return MIXED;
2085+ case 'D':
2086+ return DIGIT;
2087+ case 'B':
2088+ return BINARY;
2089+ case 'U':
2090+ default:
2091+ return UPPER;
2092+ }
2093+}
2094+
2095+const char* Decoder::getCharacter(zxing::aztec::Decoder::Table table, int code) {
2096+ switch (table) {
2097+ case UPPER:
2098+ return UPPER_TABLE[code];
2099+ case LOWER:
2100+ return LOWER_TABLE[code];
2101+ case MIXED:
2102+ return MIXED_TABLE[code];
2103+ case PUNCT:
2104+ return PUNCT_TABLE[code];
2105+ case DIGIT:
2106+ return DIGIT_TABLE[code];
2107+ default:
2108+ return "";
2109+ }
2110+}
2111+
2112+Decoder::Decoder() {
2113+ // nothing
2114+}
2115+
2116+Ref<DecoderResult> Decoder::decode(Ref<zxing::aztec::AztecDetectorResult> detectorResult) {
2117+ ddata_ = detectorResult;
2118+
2119+ // std::printf("getting bits\n");
2120+
2121+ Ref<BitMatrix> matrix = detectorResult->getBits();
2122+
2123+ if (!ddata_->isCompact()) {
2124+ // std::printf("removing lines\n");
2125+ matrix = removeDashedLines(ddata_->getBits());
2126+ }
2127+
2128+ // std::printf("extracting bits\n");
2129+ Ref<BitArray> rawbits = extractBits(matrix);
2130+
2131+ // std::printf("correcting bits\n");
2132+ Ref<BitArray> aCorrectedBits = correctBits(rawbits);
2133+
2134+ // std::printf("decoding bits\n");
2135+ Ref<String> result = getEncodedData(aCorrectedBits);
2136+
2137+ // std::printf("constructing array\n");
2138+ ArrayRef<unsigned char> arrayOut(aCorrectedBits->getSize());
2139+ for (int i = 0; i < aCorrectedBits->count(); i++) {
2140+ arrayOut[i] = (unsigned char)aCorrectedBits->get(i);
2141+ }
2142+
2143+ // std::printf("returning\n");
2144+
2145+ return Ref<DecoderResult>(new DecoderResult(arrayOut, result));
2146+}
2147+
2148+Ref<String> Decoder::getEncodedData(Ref<zxing::BitArray> correctedBits) {
2149+ int endIndex = codewordSize_ * ddata_->getNBDatablocks() - invertedBitCount_;
2150+ if (endIndex > (int)correctedBits->getSize()) {
2151+ // std::printf("invalid input\n");
2152+ throw FormatException("invalid input data");
2153+ }
2154+
2155+ Table lastTable = UPPER;
2156+ Table table = UPPER;
2157+ int startIndex = 0;
2158+ std::string result;
2159+ bool end = false;
2160+ bool shift = false;
2161+ bool switchShift = false;
2162+ bool binaryShift = false;
2163+
2164+ while (!end) {
2165+ // std::printf("decoooooding\n");
2166+
2167+ if (shift) {
2168+ switchShift = true;
2169+ } else {
2170+ lastTable = table;
2171+ }
2172+
2173+ int code;
2174+ if (binaryShift) {
2175+ if (endIndex - startIndex < 5) {
2176+ break;
2177+ }
2178+
2179+ int length = readCode(correctedBits, startIndex, 5);
2180+ startIndex += 5;
2181+ if (length == 0) {
2182+ if (endIndex - startIndex < 11) {
2183+ break;
2184+ }
2185+
2186+ length = readCode(correctedBits, startIndex, 11) + 31;
2187+ startIndex += 11;
2188+ }
2189+ for (int charCount = 0; charCount < length; charCount++) {
2190+ if (endIndex - startIndex < 8) {
2191+ end = true;
2192+ break;
2193+ }
2194+
2195+ code = readCode(correctedBits, startIndex, 8);
2196+ add(result, code);
2197+ startIndex += 8;
2198+ }
2199+ binaryShift = false;
2200+ } else {
2201+ if (table == BINARY) {
2202+ if (endIndex - startIndex < 8) {
2203+ end = true;
2204+ break;
2205+ }
2206+ code = readCode(correctedBits, startIndex, 8);
2207+ startIndex += 8;
2208+
2209+ add(result, code);
2210+ } else {
2211+ int size = 5;
2212+
2213+ if (table == DIGIT) {
2214+ size = 4;
2215+ }
2216+
2217+ if (endIndex - startIndex < size) {
2218+ end = true;
2219+ break;
2220+ }
2221+
2222+ code = readCode(correctedBits, startIndex, size);
2223+ startIndex += size;
2224+
2225+ const char *str = getCharacter(table, code);
2226+ std::string string(str);
2227+ if ((int)string.find("CTRL_") != -1) {
2228+ table = getTable(str[5]);
2229+
2230+ if (str[6] == 'S') {
2231+ shift = true;
2232+ if (str[5] == 'B') {
2233+ binaryShift = true;
2234+ }
2235+ }
2236+ } else {
2237+ result.append(string);
2238+ }
2239+
2240+ }
2241+ }
2242+
2243+ if (switchShift) {
2244+ table = lastTable;
2245+ shift = false;
2246+ switchShift = false;
2247+ }
2248+
2249+
2250+ }
2251+
2252+ return Ref<String>(new String(result));
2253+
2254+}
2255+
2256+Ref<zxing::BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits) {
2257+ //return rawbits;
2258+ // std::printf("decoding stuff:%d datablocks in %d layers\n", ddata_->getNBDatablocks(), ddata_->getNBLayers());
2259+
2260+ Ref<GenericGF> gf = GenericGF::AZTEC_DATA_6;
2261+
2262+ if (ddata_->getNBLayers() <= 2) {
2263+ codewordSize_ = 6;
2264+ gf = GenericGF::AZTEC_DATA_6;
2265+ } else if (ddata_->getNBLayers() <= 8) {
2266+ codewordSize_ = 8;
2267+ gf = GenericGF::AZTEC_DATA_8;
2268+ } else if (ddata_->getNBLayers() <= 22) {
2269+ codewordSize_ = 10;
2270+ gf = GenericGF::AZTEC_DATA_10;
2271+ } else {
2272+ codewordSize_ = 12;
2273+ gf = GenericGF::AZTEC_DATA_12;
2274+ }
2275+
2276+ int numDataCodewords = ddata_->getNBDatablocks();
2277+ int numECCodewords;
2278+ int offset;
2279+
2280+ if (ddata_->isCompact()) {
2281+ offset = NB_BITS_COMPACT[ddata_->getNBLayers()] - numCodewords_ * codewordSize_;
2282+ numECCodewords = NB_DATABLOCK_COMPACT[ddata_->getNBLayers()] - numDataCodewords;
2283+ } else {
2284+ offset = NB_BITS[ddata_->getNBLayers()] - numCodewords_ * codewordSize_;
2285+ numECCodewords = NB_DATABLOCK[ddata_->getNBLayers()] - numDataCodewords;
2286+ }
2287+
2288+ ArrayRef<int> dataWords(numCodewords_);
2289+
2290+ for (int i = 0; i < numCodewords_; i++) {
2291+ int flag = 1;
2292+ for (int j = 1; j <= codewordSize_; j++) {
2293+ if (rawbits->get(codewordSize_ * i + codewordSize_ - j + offset)) {
2294+ dataWords[i] += flag;
2295+ }
2296+ flag <<= 1;
2297+ }
2298+
2299+ //
2300+ //
2301+ //
2302+ }
2303+
2304+ try {
2305+ // std::printf("trying reed solomon, numECCodewords:%d\n", numECCodewords);
2306+ ReedSolomonDecoder rsDecoder(gf);
2307+ rsDecoder.decode(dataWords, numECCodewords);
2308+ } catch (ReedSolomonException& rse) {
2309+ // std::printf("got reed solomon exception:%s, throwing formatexception\n", rse.what());
2310+ throw FormatException("rs decoding failed");
2311+ } catch (IllegalArgumentException& iae) {
2312+ // std::printf("illegal argument exception: %s", iae.what());
2313+ }
2314+
2315+ offset = 0;
2316+ invertedBitCount_ = 0;
2317+
2318+ Ref<BitArray> correctedBits(new BitArray(numDataCodewords * codewordSize_));
2319+ for (int i = 0; i < numDataCodewords; i++) {
2320+
2321+ bool seriesColor = false;
2322+ int seriesCount = 0;
2323+ int flag = 1 << (codewordSize_ - 1);
2324+
2325+ for (int j = 0; j < codewordSize_; j++) {
2326+
2327+ bool color = (dataWords[i] & flag) == flag;
2328+
2329+ if (seriesCount == codewordSize_ - 1) {
2330+
2331+ if (color == seriesColor) {
2332+ throw FormatException("bit was not inverted");
2333+ }
2334+
2335+ seriesColor = false;
2336+ seriesCount = 0;
2337+ offset++;
2338+ invertedBitCount_++;
2339+
2340+ } else {
2341+
2342+ if (seriesColor == color) {
2343+ seriesCount++;
2344+ } else {
2345+ seriesCount = 1;
2346+ seriesColor = color;
2347+ }
2348+
2349+ if (color) correctedBits->set(i * codewordSize_ + j - offset);
2350+
2351+ }
2352+
2353+ flag = (unsigned int)flag >> 1;
2354+
2355+ }
2356+ }
2357+
2358+ return correctedBits;
2359+}
2360+
2361+Ref<BitArray> Decoder::extractBits(Ref<zxing::BitMatrix> matrix) {
2362+ std::vector<bool> rawbits;
2363+
2364+ if (ddata_->isCompact()) {
2365+ if (ddata_->getNBLayers() > 5) { //NB_BITS_COMPACT length
2366+ throw FormatException("data is too long");
2367+ }
2368+ rawbits = std::vector<bool>(NB_BITS_COMPACT[ddata_->getNBLayers()]);
2369+ numCodewords_ = NB_DATABLOCK_COMPACT[ddata_->getNBLayers()];
2370+ } else {
2371+ if (ddata_->getNBLayers() > 33) { //NB_BITS length
2372+ throw FormatException("data is too long");
2373+ }
2374+ rawbits = std::vector<bool>(NB_BITS[ddata_->getNBLayers()]);
2375+ numCodewords_ = NB_DATABLOCK[ddata_->getNBLayers()];
2376+ }
2377+
2378+ int layer = ddata_->getNBLayers();
2379+ int size = matrix->getHeight();
2380+ int rawbitsOffset = 0;
2381+ int matrixOffset = 0;
2382+
2383+
2384+ while (layer != 0) {
2385+
2386+ int flip = 0;
2387+ for (int i = 0; i < 2 * size - 4; i++) {
2388+ rawbits[rawbitsOffset + i] = matrix->get(matrixOffset + flip, matrixOffset + i / 2);
2389+ rawbits[rawbitsOffset + 2 * size - 4 + i] = matrix->get(matrixOffset + i / 2, matrixOffset + size - 1 - flip);
2390+ flip = (flip + 1) % 2;
2391+ }
2392+
2393+ flip = 0;
2394+ for (int i = 2 * size + 1; i > 5; i--) {
2395+ rawbits[rawbitsOffset + 4 * size - 8 + (2 * size - i) + 1] =
2396+ matrix->get(matrixOffset + size - 1 - flip, matrixOffset + i / 2 - 1);
2397+ rawbits[rawbitsOffset + 6 * size - 12 + (2 * size - i) + 1] =
2398+ matrix->get(matrixOffset + i / 2 - 1, matrixOffset + flip);
2399+ flip = (flip + 1) % 2;
2400+ }
2401+
2402+ matrixOffset += 2;
2403+ rawbitsOffset += 8 * size - 16;
2404+ layer--;
2405+ size -= 4;
2406+
2407+ }
2408+
2409+ Ref<BitArray> returnValue(new BitArray(rawbits.size()));
2410+ for (int i = 0; i < (int)rawbits.size(); i++) {
2411+ if (rawbits[i]) returnValue->set(i);
2412+ }
2413+
2414+ return returnValue;
2415+
2416+}
2417+
2418+Ref<BitMatrix> Decoder::removeDashedLines(Ref<zxing::BitMatrix> matrix) {
2419+ int nbDashed = 1 + 2 * ((matrix->getWidth() - 1) / 2 / 16);
2420+ Ref<BitMatrix> newMatrix(new BitMatrix(matrix->getWidth() - nbDashed, matrix->getHeight() - nbDashed));
2421+
2422+ int nx = 0;
2423+
2424+ for (int x = 0; x < (int)matrix->getWidth(); x++) {
2425+
2426+ if ((matrix->getWidth() / 2 - x) % 16 == 0) {
2427+ continue;
2428+ }
2429+
2430+ int ny = 0;
2431+ for (int y = 0; y < (int)matrix->getHeight(); y++) {
2432+
2433+ if ((matrix->getWidth() / 2 - y) % 16 == 0) {
2434+ continue;
2435+ }
2436+
2437+ if (matrix->get(x, y)) {
2438+ newMatrix->set(nx, ny);
2439+ }
2440+ ny++;
2441+
2442+ }
2443+ nx++;
2444+
2445+ }
2446+ return newMatrix;
2447+}
2448+
2449+int Decoder::readCode(Ref<zxing::BitArray> rawbits, int startIndex, int length) {
2450+ int res = 0;
2451+
2452+ for (int i = startIndex; i < startIndex + length; i++) {
2453+ res <<= 1;
2454+ if (rawbits->get(i)) {
2455+ res ++;
2456+ }
2457+ }
2458+
2459+ return res;
2460+}
2461
2462=== added file '3rdParty/zxing/aztec/decoder/Decoder.h'
2463--- 3rdParty/zxing/aztec/decoder/Decoder.h 1970-01-01 00:00:00 +0000
2464+++ 3rdParty/zxing/aztec/decoder/Decoder.h 2014-05-10 17:38:08 +0000
2465@@ -0,0 +1,63 @@
2466+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
2467+/*
2468+ * Decoder.h
2469+ * zxing
2470+ *
2471+ * Created by Lukas Stabe on 08/02/2012.
2472+ * Copyright 2012 ZXing authors All rights reserved.
2473+ *
2474+ * Licensed under the Apache License, Version 2.0 (the "License");
2475+ * you may not use this file except in compliance with the License.
2476+ * You may obtain a copy of the License at
2477+ *
2478+ * http://www.apache.org/licenses/LICENSE-2.0
2479+ *
2480+ * Unless required by applicable law or agreed to in writing, software
2481+ * distributed under the License is distributed on an "AS IS" BASIS,
2482+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2483+ * See the License for the specific language governing permissions and
2484+ * limitations under the License.
2485+ */
2486+
2487+#include <zxing/common/DecoderResult.h>
2488+#include <zxing/common/BitMatrix.h>
2489+#include <zxing/common/Str.h>
2490+#include <zxing/aztec/AztecDetectorResult.h>
2491+
2492+namespace zxing {
2493+ namespace aztec {
2494+
2495+ class Decoder : public Counted {
2496+ private:
2497+ enum Table {
2498+ UPPER,
2499+ LOWER,
2500+ MIXED,
2501+ DIGIT,
2502+ PUNCT,
2503+ BINARY
2504+ };
2505+
2506+ static Table getTable(char t);
2507+ static const char* getCharacter(Table table, int code);
2508+
2509+ int numCodewords_;
2510+ int codewordSize_;
2511+ Ref<AztecDetectorResult> ddata_;
2512+ int invertedBitCount_;
2513+
2514+ Ref<String> getEncodedData(Ref<BitArray> correctedBits);
2515+ Ref<BitArray> correctBits(Ref<BitArray> rawbits);
2516+ Ref<BitArray> extractBits(Ref<BitMatrix> matrix);
2517+ static Ref<BitMatrix> removeDashedLines(Ref<BitMatrix> matrix);
2518+ static int readCode(Ref<BitArray> rawbits, int startIndex, int length);
2519+
2520+
2521+ public:
2522+ Decoder();
2523+ Ref<DecoderResult> decode(Ref<AztecDetectorResult> detectorResult);
2524+ };
2525+
2526+ }
2527+}
2528+
2529
2530=== added directory '3rdParty/zxing/aztec/detector'
2531=== added file '3rdParty/zxing/aztec/detector/AztecDetector.cpp'
2532--- 3rdParty/zxing/aztec/detector/AztecDetector.cpp 1970-01-01 00:00:00 +0000
2533+++ 3rdParty/zxing/aztec/detector/AztecDetector.cpp 2014-05-10 17:38:08 +0000
2534@@ -0,0 +1,541 @@
2535+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
2536+/*
2537+ * Detector.cpp
2538+ * zxing
2539+ *
2540+ * Created by Lukas Stabe on 08/02/2012.
2541+ * Copyright 2012 ZXing authors All rights reserved.
2542+ *
2543+ * Licensed under the Apache License, Version 2.0 (the "License");
2544+ * you may not use this file except in compliance with the License.
2545+ * You may obtain a copy of the License at
2546+ *
2547+ * http://www.apache.org/licenses/LICENSE-2.0
2548+ *
2549+ * Unless required by applicable law or agreed to in writing, software
2550+ * distributed under the License is distributed on an "AS IS" BASIS,
2551+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2552+ * See the License for the specific language governing permissions and
2553+ * limitations under the License.
2554+ */
2555+
2556+#include <zxing/aztec/detector/Detector.h>
2557+#include <zxing/common/GridSampler.h>
2558+#include <zxing/common/detector/WhiteRectangleDetector.h>
2559+#include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
2560+#include <zxing/common/reedsolomon/ReedSolomonException.h>
2561+#include <zxing/common/reedsolomon/GenericGF.h>
2562+#include <iostream>
2563+#include <cmath>
2564+#include <zxing/NotFoundException.h>
2565+
2566+using zxing::aztec::Detector;
2567+using zxing::aztec::Point;
2568+using zxing::aztec::AztecDetectorResult;
2569+using zxing::Ref;
2570+using zxing::ResultPoint;
2571+using zxing::BitArray;
2572+using zxing::BitMatrix;
2573+
2574+Detector::Detector(Ref<BitMatrix> image):
2575+ image_(image),
2576+ nbLayers_(0),
2577+ nbDataBlocks_(0),
2578+ nbCenterLayers_(0) {
2579+
2580+}
2581+
2582+// using namespace std;
2583+
2584+Ref<AztecDetectorResult> Detector::detect() {
2585+ Ref<Point> pCenter = getMatrixCenter();
2586+
2587+ std::vector<Ref<Point> > bullEyeCornerPoints = getBullEyeCornerPoints(pCenter);
2588+
2589+ extractParameters(bullEyeCornerPoints);
2590+
2591+ std::vector<Ref<ResultPoint> > corners = getMatrixCornerPoints(bullEyeCornerPoints);
2592+
2593+ Ref<BitMatrix> bits = sampleGrid(image_, corners[shift_%4], corners[(shift_+3)%4], corners[(shift_+2)%4], corners[(shift_+1)%4]);
2594+
2595+ // std::printf("------------\ndetected: compact:%s, nbDataBlocks:%d, nbLayers:%d\n------------\n",compact_?"YES":"NO", nbDataBlocks_, nbLayers_);
2596+
2597+ return Ref<AztecDetectorResult>(new AztecDetectorResult(bits, corners, compact_, nbDataBlocks_, nbLayers_));
2598+}
2599+
2600+void Detector::extractParameters(std::vector<Ref<Point> > bullEyeCornerPoints) {
2601+ // get the bits around the bull's eye
2602+ Ref<BitArray> resab = sampleLine(bullEyeCornerPoints[0], bullEyeCornerPoints[1], 2*nbCenterLayers_+1);
2603+ Ref<BitArray> resbc = sampleLine(bullEyeCornerPoints[1], bullEyeCornerPoints[2], 2*nbCenterLayers_+1);
2604+ Ref<BitArray> rescd = sampleLine(bullEyeCornerPoints[2], bullEyeCornerPoints[3], 2*nbCenterLayers_+1);
2605+ Ref<BitArray> resda = sampleLine(bullEyeCornerPoints[3], bullEyeCornerPoints[0], 2*nbCenterLayers_+1);
2606+
2607+ // determin the orientation of the matrix
2608+ if (resab->get(0) && resab->get(2 * nbCenterLayers_)) {
2609+ shift_ = 0;
2610+ } else if (resbc->get(0) && resbc->get(2 * nbCenterLayers_)) {
2611+ shift_ = 1;
2612+ } else if (rescd->get(0) && rescd->get(2 * nbCenterLayers_)) {
2613+ shift_ = 2;
2614+ } else if (resda->get(0) && resda->get(2 * nbCenterLayers_)) {
2615+ shift_ = 3;
2616+ } else {
2617+ // std::printf("could not detemine orientation\n");
2618+ throw ReaderException("could not determine orientation");
2619+ }
2620+
2621+ //d a
2622+ //
2623+ //c b
2624+
2625+ //flatten the bits in a single array
2626+ Ref<BitArray> parameterData(new BitArray(compact_?28:40));
2627+ Ref<BitArray> shiftedParameterData(new BitArray(compact_?28:40));
2628+
2629+ if (compact_) {
2630+ for (int i = 0; i < 7; i++) {
2631+ if (resab->get(2+i)) shiftedParameterData->set(i);
2632+ if (resbc->get(2+i)) shiftedParameterData->set(i+7);
2633+ if (rescd->get(2+i)) shiftedParameterData->set(i+14);
2634+ if (resda->get(2+i)) shiftedParameterData->set(i+21);
2635+ }
2636+ for (int i = 0; i < 28; i++) {
2637+ if (shiftedParameterData->get((i+shift_*7)%28)) parameterData->set(i);
2638+ }
2639+
2640+ } else {
2641+ for (int i = 0; i < 11; i++) {
2642+ if (i < 5) {
2643+ if (resab->get(2+i)) shiftedParameterData->set(i);
2644+ if (resbc->get(2+i)) shiftedParameterData->set(i+10);
2645+ if (rescd->get(2+i)) shiftedParameterData->set(i+20);
2646+ if (resda->get(2+i)) shiftedParameterData->set(i+30);
2647+ }
2648+ if (i > 5) {
2649+ if (resab->get(2+i)) shiftedParameterData->set(i-1);
2650+ if (resbc->get(2+i)) shiftedParameterData->set(i+10-1);
2651+ if (rescd->get(2+i)) shiftedParameterData->set(i+20-1);
2652+ if (resda->get(2+i)) shiftedParameterData->set(i+30-1);
2653+ }
2654+ }
2655+ for (int i = 0; i < 40; i++) {
2656+ if (shiftedParameterData->get((i+shift_*10)%40)) parameterData->set(i);
2657+ }
2658+ }
2659+
2660+ correctParameterData(parameterData, compact_);
2661+
2662+ getParameters(parameterData);
2663+}
2664+
2665+std::vector<Ref<ResultPoint> > Detector::getMatrixCornerPoints(std::vector<Ref<Point> > bullEyeCornerPoints) {
2666+ float ratio = (2 * nbLayers_ + (nbLayers_ > 4 ? 1 : 0) + (nbLayers_ - 4) / 8) / (2.0f * nbCenterLayers_);
2667+
2668+ int dx = bullEyeCornerPoints[0]->x - bullEyeCornerPoints[2]->x;
2669+ dx += dx > 0 ? 1 : -1;
2670+ int dy = bullEyeCornerPoints[0]->y - bullEyeCornerPoints[2]->y;
2671+ dy += dy > 0 ? 1 : -1;
2672+
2673+ int targetcx = ROUND(bullEyeCornerPoints[2]->x - ratio * dx);
2674+ int targetcy = ROUND(bullEyeCornerPoints[2]->y - ratio * dy);
2675+
2676+ int targetax = ROUND(bullEyeCornerPoints[0]->x + ratio * dx);
2677+ int targetay = ROUND(bullEyeCornerPoints[0]->y + ratio * dy);
2678+
2679+ dx = bullEyeCornerPoints[1]->x - bullEyeCornerPoints[3]->x;
2680+ dx += dx > 0 ? 1 : -1;
2681+ dy = bullEyeCornerPoints[1]->y - bullEyeCornerPoints[3]->y;
2682+ dy += dy > 0 ? 1 : -1;
2683+
2684+ int targetdx = ROUND(bullEyeCornerPoints[3]->x - ratio * dx);
2685+ int targetdy = ROUND(bullEyeCornerPoints[3]->y - ratio * dy);
2686+ int targetbx = ROUND(bullEyeCornerPoints[1]->x + ratio * dx);
2687+ int targetby = ROUND(bullEyeCornerPoints[1]->y + ratio * dy);
2688+
2689+ if (!isValid(targetax, targetay) ||
2690+ !isValid(targetbx, targetby) ||
2691+ !isValid(targetcx, targetcy) ||
2692+ !isValid(targetdx, targetdy)) {
2693+ throw ReaderException("matrix extends over image bounds");
2694+ }
2695+ std::vector<Ref<ResultPoint> > returnValue;
2696+ returnValue.push_back(Ref<ResultPoint>(new ResultPoint(targetax, targetay)));
2697+ returnValue.push_back(Ref<ResultPoint>(new ResultPoint(targetbx, targetby)));
2698+ returnValue.push_back(Ref<ResultPoint>(new ResultPoint(targetcx, targetcy)));
2699+ returnValue.push_back(Ref<ResultPoint>(new ResultPoint(targetdx, targetdy)));
2700+
2701+ return returnValue;
2702+
2703+}
2704+
2705+void Detector::correctParameterData(Ref<zxing::BitArray> parameterData, bool compact) {
2706+ int numCodewords;
2707+ int numDataCodewords;
2708+
2709+ if (compact) {
2710+ numCodewords = 7;
2711+ numDataCodewords = 2;
2712+ } else {
2713+ numCodewords = 10;
2714+ numDataCodewords = 4;
2715+ }
2716+
2717+ int numECCodewords = numCodewords - numDataCodewords;
2718+
2719+ ArrayRef<int> parameterWords(new Array<int>(numCodewords));
2720+
2721+ int codewordSize = 4;
2722+ for (int i = 0; i < numCodewords; i++) {
2723+ int flag = 1;
2724+ for (int j = 1; j <= codewordSize; j++) {
2725+ if (parameterData->get(codewordSize*i + codewordSize - j)) {
2726+ parameterWords[i] += flag;
2727+ }
2728+ flag <<= 1;
2729+ }
2730+ }
2731+
2732+ try {
2733+ // std::printf("parameter data reed solomon\n");
2734+ ReedSolomonDecoder rsDecoder(GenericGF::AZTEC_PARAM);
2735+ rsDecoder.decode(parameterWords, numECCodewords);
2736+ } catch (ReedSolomonException& e) {
2737+ // std::printf("reed solomon decoding failed\n");
2738+ throw ReaderException("failed to decode parameter data");
2739+ }
2740+
2741+ parameterData->clear();
2742+ for (int i = 0; i < numDataCodewords; i++) {
2743+ int flag = 1;
2744+ for (int j = 1; j <= codewordSize; j++) {
2745+ if ((parameterWords[i] & flag) == flag) {
2746+ parameterData->set(i*codewordSize+codewordSize-j);
2747+ }
2748+ flag <<= 1;
2749+ }
2750+ }
2751+}
2752+
2753+std::vector<Ref<Point> > Detector::getBullEyeCornerPoints(Ref<zxing::aztec::Point> pCenter) {
2754+ Ref<Point> pina = pCenter;
2755+ Ref<Point> pinb = pCenter;
2756+ Ref<Point> pinc = pCenter;
2757+ Ref<Point> pind = pCenter;
2758+
2759+ bool color = true;
2760+
2761+ for (nbCenterLayers_ = 1; nbCenterLayers_ < 9; nbCenterLayers_++) {
2762+ Ref<Point> pouta = getFirstDifferent(pina, color, 1, -1);
2763+ Ref<Point> poutb = getFirstDifferent(pinb, color, 1, 1);
2764+ Ref<Point> poutc = getFirstDifferent(pinc, color, -1, 1);
2765+ Ref<Point> poutd = getFirstDifferent(pind, color, -1, -1);
2766+
2767+ //d a
2768+ //
2769+ //c b
2770+
2771+ if (nbCenterLayers_ > 2) {
2772+ float q = distance(poutd, pouta) * nbCenterLayers_ / (distance(pind, pina) * (nbCenterLayers_ + 2));
2773+ if (q < 0.75 || q > 1.25 || !isWhiteOrBlackRectangle(pouta, poutb, poutc, poutd)) {
2774+ break;
2775+ }
2776+ }
2777+
2778+ pina = pouta;
2779+ pinb = poutb;
2780+ pinc = poutc;
2781+ pind = poutd;
2782+
2783+ color = !color;
2784+ }
2785+
2786+ if (nbCenterLayers_ != 5 && nbCenterLayers_ != 7) {
2787+ throw ReaderException("encountered wrong bullseye ring count");
2788+ }
2789+
2790+ compact_ = nbCenterLayers_ == 5;
2791+
2792+
2793+
2794+ float ratio = 0.75f*2 / (2*nbCenterLayers_-3);
2795+
2796+ int dx = pina->x - pind->x;
2797+ int dy = pina->y - pinc->y;
2798+
2799+ int targetcx = ROUND(pinc->x - ratio * dx);
2800+ int targetcy = ROUND(pinc->y - ratio * dy);
2801+ int targetax = ROUND(pina->x + ratio * dx);
2802+ int targetay = ROUND(pina->y + ratio * dy);
2803+
2804+ dx = pinb->x - pind->x;
2805+ dy = pinb->y - pind->y;
2806+
2807+ int targetdx = ROUND(pind->x - ratio * dx);
2808+ int targetdy = ROUND(pind->y - ratio * dy);
2809+ int targetbx = ROUND(pinb->x + ratio * dx);
2810+ int targetby = ROUND(pinb->y + ratio * dy);
2811+
2812+ if (!isValid(targetax, targetay) ||
2813+ !isValid(targetbx, targetby) ||
2814+ !isValid(targetcx, targetcy) ||
2815+ !isValid(targetdx, targetdy)) {
2816+ throw ReaderException("bullseye extends over image bounds");
2817+ }
2818+
2819+ std::vector<Ref<Point> > returnValue;
2820+ returnValue.push_back(Ref<Point>(new Point(targetax, targetay)));
2821+ returnValue.push_back(Ref<Point>(new Point(targetbx, targetby)));
2822+ returnValue.push_back(Ref<Point>(new Point(targetcx, targetcy)));
2823+ returnValue.push_back(Ref<Point>(new Point(targetdx, targetdy)));
2824+
2825+ return returnValue;
2826+
2827+}
2828+
2829+Ref<Point> Detector::getMatrixCenter() {
2830+ Ref<ResultPoint> pointA, pointB, pointC, pointD;
2831+ try {
2832+
2833+ std::vector<Ref<ResultPoint> > cornerPoints = WhiteRectangleDetector(image_).detect();
2834+ pointA = cornerPoints[0];
2835+ pointB = cornerPoints[1];
2836+ pointC = cornerPoints[2];
2837+ pointD = cornerPoints[3];
2838+
2839+ } catch (NotFoundException& e) {
2840+
2841+ int cx = image_->getWidth() / 2;
2842+ int cy = image_->getHeight() / 2;
2843+
2844+ pointA = getFirstDifferent(Ref<Point>(new Point(cx+15/2, cy-15/2)), false, 1, -1)->toResultPoint();
2845+ pointB = getFirstDifferent(Ref<Point>(new Point(cx+15/2, cy+15/2)), false, 1, 1)->toResultPoint();
2846+ pointC = getFirstDifferent(Ref<Point>(new Point(cx-15/2, cy+15/2)), false, -1, -1)->toResultPoint();
2847+ pointD = getFirstDifferent(Ref<Point>(new Point(cx-15/2, cy-15/2)), false, -1, -1)->toResultPoint();
2848+
2849+ }
2850+
2851+ int cx = ROUND((pointA->getX() + pointD->getX() + pointB->getX() + pointC->getX()) / 4);
2852+ int cy = ROUND((pointA->getY() + pointD->getY() + pointB->getY() + pointC->getY()) / 4);
2853+
2854+ try {
2855+
2856+ std::vector<Ref<ResultPoint> > cornerPoints = WhiteRectangleDetector(image_, 15, cx, cy).detect();
2857+ pointA = cornerPoints[0];
2858+ pointB = cornerPoints[1];
2859+ pointC = cornerPoints[2];
2860+ pointD = cornerPoints[3];
2861+
2862+ } catch (NotFoundException& e) {
2863+
2864+ pointA = getFirstDifferent(Ref<Point>(new Point(cx+15/2, cy-15/2)), false, 1, -1)->toResultPoint();
2865+ pointB = getFirstDifferent(Ref<Point>(new Point(cx+15/2, cy+15/2)), false, 1, 1)->toResultPoint();
2866+ pointC = getFirstDifferent(Ref<Point>(new Point(cx-15/2, cy+15/2)), false, -1, -1)->toResultPoint();
2867+ pointD = getFirstDifferent(Ref<Point>(new Point(cx-15/2, cy-15/2)), false, -1, -1)->toResultPoint();
2868+
2869+ }
2870+
2871+ cx = ROUND((pointA->getX() + pointD->getX() + pointB->getX() + pointC->getX()) / 4);
2872+ cy = ROUND((pointA->getY() + pointD->getY() + pointB->getY() + pointC->getY()) / 4);
2873+
2874+ return Ref<Point>(new Point(cx, cy));
2875+
2876+}
2877+
2878+Ref<BitMatrix> Detector::sampleGrid(Ref<zxing::BitMatrix> image,
2879+ Ref<zxing::ResultPoint> topLeft,
2880+ Ref<zxing::ResultPoint> bottomLeft,
2881+ Ref<zxing::ResultPoint> bottomRight,
2882+ Ref<zxing::ResultPoint> topRight) {
2883+ int dimension;
2884+ if (compact_) {
2885+ dimension = 4 * nbLayers_+11;
2886+ } else {
2887+ if (nbLayers_ <= 4) {
2888+ dimension = 4 * nbLayers_ + 15;
2889+ } else {
2890+ dimension = 4 * nbLayers_ + 2 * ((nbLayers_-4)/8 + 1) + 15;
2891+ }
2892+ }
2893+
2894+ GridSampler sampler = GridSampler::getInstance();
2895+
2896+ return sampler.sampleGrid(image,
2897+ dimension,
2898+ 0.5f,
2899+ 0.5f,
2900+ dimension - 0.5f,
2901+ 0.5f,
2902+ dimension - 0.5f,
2903+ dimension - 0.5f,
2904+ 0.5f,
2905+ dimension - 0.5f,
2906+ topLeft->getX(),
2907+ topLeft->getY(),
2908+ topRight->getX(),
2909+ topRight->getY(),
2910+ bottomRight->getX(),
2911+ bottomRight->getY(),
2912+ bottomLeft->getX(),
2913+ bottomLeft->getY());
2914+}
2915+
2916+void Detector::getParameters(Ref<zxing::BitArray> parameterData) {
2917+ nbLayers_ = 0;
2918+ nbDataBlocks_ = 0;
2919+
2920+ int nbBitsForNbLayers;
2921+ int nbBitsForNbDatablocks;
2922+
2923+ if (compact_) {
2924+ nbBitsForNbLayers = 2;
2925+ nbBitsForNbDatablocks = 6;
2926+ } else {
2927+ nbBitsForNbLayers = 5;
2928+ nbBitsForNbDatablocks = 11;
2929+ }
2930+
2931+ for (int i = 0; i < nbBitsForNbLayers; i++) {
2932+ nbLayers_ <<= 1;
2933+ if (parameterData->get(i)) {
2934+ nbLayers_ += 1;
2935+ }
2936+ }
2937+
2938+ for (int i = nbBitsForNbLayers; i < nbBitsForNbLayers + nbBitsForNbDatablocks; i++) {
2939+ nbDataBlocks_ <<= 1;
2940+ if (parameterData->get(i)) {
2941+ nbDataBlocks_ += 1;
2942+ }
2943+ }
2944+
2945+ nbLayers_ ++;
2946+ nbDataBlocks_ ++;
2947+}
2948+
2949+Ref<BitArray> Detector::sampleLine(Ref<zxing::aztec::Point> p1, Ref<zxing::aztec::Point> p2, int size) {
2950+ Ref<BitArray> res(new BitArray(size));
2951+
2952+ float d = distance(p1, p2);
2953+ float moduleSize = d / (size-1);
2954+ float dx = moduleSize * (p2->x - p1->x)/d;
2955+ float dy = moduleSize * (p2->y - p1->y)/d;
2956+
2957+ float px = p1->x;
2958+ float py = p1->y;
2959+
2960+ for (int i = 0; i < size; i++) {
2961+ if (image_->get(ROUND(px), ROUND(py))) res->set(i);
2962+ px += dx;
2963+ py += dy;
2964+ }
2965+
2966+ return res;
2967+}
2968+
2969+bool Detector::isWhiteOrBlackRectangle(Ref<zxing::aztec::Point> p1,
2970+ Ref<zxing::aztec::Point> p2,
2971+ Ref<zxing::aztec::Point> p3,
2972+ Ref<zxing::aztec::Point> p4) {
2973+ int corr = 3;
2974+
2975+ p1 = new Point(p1->x - corr, p1->y + corr);
2976+ p2 = new Point(p2->x - corr, p2->y - corr);
2977+ p3 = new Point(p3->x + corr, p3->y - corr);
2978+ p4 = new Point(p4->x + corr, p4->y + corr);
2979+
2980+ int cInit = getColor(p4, p1);
2981+
2982+ if (cInit == 0) {
2983+ return false;
2984+ }
2985+
2986+ int c = getColor(p1, p2);
2987+
2988+ if (c != cInit) {
2989+ return false;
2990+ }
2991+
2992+ c = getColor(p2, p3);
2993+
2994+ if (c != cInit) {
2995+ return false;
2996+ }
2997+
2998+ c = getColor(p3, p4);
2999+
3000+ if (c != cInit) {
3001+ return false;
3002+ }
3003+
3004+ return true;
3005+}
3006+
3007+int Detector::getColor(Ref<zxing::aztec::Point> p1, Ref<zxing::aztec::Point> p2) {
3008+ float d = distance(p1, p2);
3009+
3010+ float dx = (p2->x - p1->x) / d;
3011+ float dy = (p2->y - p1->y) / d;
3012+
3013+ int error = 0;
3014+
3015+ float px = p1->x;
3016+ float py = p1->y;
3017+
3018+ bool colorModel = image_->get(p1->x, p1->y);
3019+
3020+ for (int i = 0; i < d; i++) {
3021+ px += dx;
3022+ py += dy;
3023+ if (image_->get(ROUND(px), ROUND(py)) != colorModel) {
3024+ error ++;
3025+ }
3026+ }
3027+
3028+ float errRatio = (float)error/d;
3029+
3030+
3031+ if (errRatio > 0.1 && errRatio < 0.9) {
3032+ return 0;
3033+ }
3034+
3035+ if (errRatio <= 0.1) {
3036+ return colorModel?1:-1;
3037+ } else {
3038+ return colorModel?-1:1;
3039+ }
3040+}
3041+
3042+Ref<Point> Detector::getFirstDifferent(Ref<zxing::aztec::Point> init, bool color, int dx, int dy) {
3043+ int x = init->x + dx;
3044+ int y = init->y + dy;
3045+
3046+ while (isValid(x, y) && image_->get(x, y) == color) {
3047+ x += dx;
3048+ y += dy;
3049+ }
3050+
3051+ x -= dx;
3052+ y -= dy;
3053+
3054+ while (isValid(x, y) && image_->get(x, y) == color) {
3055+ x += dx;
3056+ }
3057+
3058+ x -= dx;
3059+
3060+ while (isValid(x, y) && image_->get(x, y) == color) {
3061+ y += dy;
3062+ }
3063+
3064+ y -= dy;
3065+
3066+ return Ref<Point>(new Point(x, y));
3067+}
3068+
3069+bool Detector::isValid(int x, int y) {
3070+ return x >= 0 && x < (int)image_->getWidth() && y > 0 && y < (int)image_->getHeight();
3071+}
3072+
3073+float Detector::distance(Ref<zxing::aztec::Point> a, Ref<zxing::aztec::Point> b) {
3074+ return sqrtf((float)((a->x - b->x) * (a->x - b->x) + (a->y - b->y) * (a->y - b->y)));
3075+}
3076
3077=== added file '3rdParty/zxing/aztec/detector/Detector.h'
3078--- 3rdParty/zxing/aztec/detector/Detector.h 1970-01-01 00:00:00 +0000
3079+++ 3rdParty/zxing/aztec/detector/Detector.h 2014-05-10 17:38:08 +0000
3080@@ -0,0 +1,87 @@
3081+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3082+/*
3083+ * Detector.h
3084+ * zxing
3085+ *
3086+ * Created by Lukas Stabe on 08/02/2012.
3087+ * Copyright 2012 ZXing authors All rights reserved.
3088+ *
3089+ * Licensed under the Apache License, Version 2.0 (the "License");
3090+ * you may not use this file except in compliance with the License.
3091+ * You may obtain a copy of the License at
3092+ *
3093+ * http://www.apache.org/licenses/LICENSE-2.0
3094+ *
3095+ * Unless required by applicable law or agreed to in writing, software
3096+ * distributed under the License is distributed on an "AS IS" BASIS,
3097+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3098+ * See the License for the specific language governing permissions and
3099+ * limitations under the License.
3100+ */
3101+
3102+
3103+#include <vector>
3104+
3105+#include <zxing/common/BitArray.h>
3106+#include <zxing/ResultPoint.h>
3107+#include <zxing/common/BitMatrix.h>
3108+#include <zxing/DecodeHints.h>
3109+#include <zxing/aztec/AztecDetectorResult.h>
3110+
3111+#define ROUND(a) ((int)(a + 0.5f))
3112+
3113+namespace zxing {
3114+ namespace aztec {
3115+
3116+ class Point : public Counted {
3117+ public:
3118+ int x;
3119+ int y;
3120+
3121+ Ref<ResultPoint> toResultPoint() {
3122+ return Ref<ResultPoint>(new ResultPoint(x, y));
3123+ }
3124+
3125+ Point(int ax, int ay):x(ax),y(ay) {};
3126+
3127+ };
3128+
3129+ class Detector : public Counted {
3130+
3131+ private:
3132+ Ref<BitMatrix> image_;
3133+
3134+ bool compact_;
3135+ int nbLayers_;
3136+ int nbDataBlocks_;
3137+ int nbCenterLayers_;
3138+ int shift_;
3139+
3140+ void extractParameters(std::vector<Ref<Point> > bullEyeCornerPoints);
3141+ std::vector<Ref<ResultPoint> > getMatrixCornerPoints(std::vector<Ref<Point> > bullEyeCornerPoints);
3142+ static void correctParameterData(Ref<BitArray> parameterData, bool compact);
3143+ std::vector<Ref<Point> > getBullEyeCornerPoints(Ref<Point> pCenter);
3144+ Ref<Point> getMatrixCenter();
3145+ Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image,
3146+ Ref<ResultPoint> topLeft,
3147+ Ref<ResultPoint> bottomLeft,
3148+ Ref<ResultPoint> bottomRight,
3149+ Ref<ResultPoint> topRight);
3150+ void getParameters(Ref<BitArray> parameterData);
3151+ Ref<BitArray> sampleLine(Ref<Point> p1, Ref<Point> p2, int size);
3152+ bool isWhiteOrBlackRectangle(Ref<Point> p1,
3153+ Ref<Point> p2,
3154+ Ref<Point> p3,
3155+ Ref<Point> p4);
3156+ int getColor(Ref<Point> p1, Ref<Point> p2);
3157+ Ref<Point> getFirstDifferent(Ref<Point> init, bool color, int dx, int dy);
3158+ bool isValid(int x, int y);
3159+ static float distance(Ref<Point> a, Ref<Point> b);
3160+
3161+ public:
3162+ Detector(Ref<BitMatrix> image);
3163+ Ref<AztecDetectorResult> detect();
3164+ };
3165+
3166+ }
3167+}
3168
3169=== added directory '3rdParty/zxing/common'
3170=== added file '3rdParty/zxing/common/Array.cpp'
3171--- 3rdParty/zxing/common/Array.cpp 1970-01-01 00:00:00 +0000
3172+++ 3rdParty/zxing/common/Array.cpp 2014-05-10 17:38:08 +0000
3173@@ -0,0 +1,22 @@
3174+/*
3175+ * Array.cpp
3176+ * zxing
3177+ *
3178+ * Created by Christian Brunschen on 07/05/2008.
3179+ * Copyright 2008 Google UK. All rights reserved.
3180+ *
3181+ * Licensed under the Apache License, Version 2.0 (the "License");
3182+ * you may not use this file except in compliance with the License.
3183+ * You may obtain a copy of the License at
3184+ *
3185+ * http://www.apache.org/licenses/LICENSE-2.0
3186+ *
3187+ * Unless required by applicable law or agreed to in writing, software
3188+ * distributed under the License is distributed on an "AS IS" BASIS,
3189+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3190+ * See the License for the specific language governing permissions and
3191+ * limitations under the License.
3192+ */
3193+
3194+#include <zxing/common/Array.h>
3195+
3196
3197=== added file '3rdParty/zxing/common/Array.h'
3198--- 3rdParty/zxing/common/Array.h 1970-01-01 00:00:00 +0000
3199+++ 3rdParty/zxing/common/Array.h 2014-05-10 17:38:08 +0000
3200@@ -0,0 +1,208 @@
3201+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3202+#ifndef __ARRAY_H__
3203+#define __ARRAY_H__
3204+
3205+/*
3206+ * Array.h
3207+ * zxing
3208+ *
3209+ * Copyright 2010 ZXing authors All rights reserved.
3210+ *
3211+ * Licensed under the Apache License, Version 2.0 (the "License");
3212+ * you may not use this file except in compliance with the License.
3213+ * You may obtain a copy of the License at
3214+ *
3215+ * http://www.apache.org/licenses/LICENSE-2.0
3216+ *
3217+ * Unless required by applicable law or agreed to in writing, software
3218+ * distributed under the License is distributed on an "AS IS" BASIS,
3219+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3220+ * See the License for the specific language governing permissions and
3221+ * limitations under the License.
3222+ */
3223+
3224+#include <vector>
3225+
3226+#ifdef DEBUG_COUNTING
3227+#include <iostream>
3228+#include <typeinfo>
3229+#endif
3230+
3231+#include <zxing/common/Counted.h>
3232+
3233+
3234+namespace zxing {
3235+
3236+template<typename T> class Array : public Counted {
3237+protected:
3238+public:
3239+ std::vector<T> values_;
3240+ Array(size_t n) :
3241+ Counted(), values_(n, T()) {
3242+ }
3243+ Array(T *ts, size_t n) :
3244+ Counted(), values_(ts, ts+n) {
3245+ }
3246+ Array(T v, size_t n) :
3247+ Counted(), values_(n, v) {
3248+ }
3249+ Array(std::vector<T> &v) :
3250+ Counted(), values_(v) {
3251+ }
3252+ Array(Array<T> &other) :
3253+ Counted(), values_(other.values_) {
3254+ }
3255+ Array(Array<T> *other) :
3256+ Counted(), values_(other->values_) {
3257+ }
3258+ virtual ~Array() {
3259+ }
3260+ Array<T>& operator=(const Array<T> &other) {
3261+#ifdef DEBUG_COUNTING
3262+ cout << "assigning values from Array " << &other << " to this Array " << this << ", ";
3263+#endif
3264+ values_ = other.values_;
3265+#ifdef DEBUG_COUNTING
3266+ cout << "new size = " << values_.size() << "\n";
3267+#endif
3268+ return *this;
3269+ }
3270+ Array<T>& operator=(const std::vector<T> &array) {
3271+#ifdef DEBUG_COUNTING
3272+ cout << "assigning values from Array " << &array << " to this Array " << this << ", ";
3273+#endif
3274+ values_ = array;
3275+#ifdef DEBUG_COUNTING
3276+ cout << "new size = " << values_.size() << "\n";
3277+#endif
3278+ return *this;
3279+ }
3280+ T operator[](size_t i) const {
3281+ return values_[i];
3282+ }
3283+ T& operator[](size_t i) {
3284+ return values_[i];
3285+ }
3286+ size_t size() const {
3287+ return values_.size();
3288+ }
3289+ std::vector<T> values() const {
3290+ return values_;
3291+ }
3292+ std::vector<T>& values() {
3293+ return values_;
3294+ }
3295+};
3296+
3297+template<typename T> class ArrayRef : public Counted {
3298+private:
3299+public:
3300+ Array<T> *array_;
3301+ ArrayRef() :
3302+ array_(0) {
3303+#ifdef DEBUG_COUNTING
3304+ cout << "instantiating empty ArrayRef " << this << "\n";
3305+#endif
3306+ }
3307+ ArrayRef(size_t n) :
3308+ array_(0) {
3309+#ifdef DEBUG_COUNTING
3310+ cout << "instantiating ArrayRef " << this << "with size " << n << "\n";
3311+#endif
3312+ reset(new Array<T> (n));
3313+ }
3314+ ArrayRef(T *ts, size_t n) :
3315+ array_(0) {
3316+#ifdef DEBUG_COUNTING
3317+ cout << "instantiating ArrayRef " << this << "with " << n << " elements at " << (void *)ts << "\n";
3318+#endif
3319+ reset(new Array<T> (ts, n));
3320+ }
3321+ ArrayRef(Array<T> *a) :
3322+ array_(0) {
3323+#ifdef DEBUG_COUNTING
3324+ cout << "instantiating ArrayRef " << this << " from pointer:\n";
3325+#endif
3326+ reset(a);
3327+ }
3328+ ArrayRef(const Array<T> &a) :
3329+ array_(0) {
3330+#ifdef DEBUG_COUNTING
3331+ cout << "instantiating ArrayRef " << this << " from reference to Array " << (void *)&a << ":\n";
3332+#endif
3333+ reset(const_cast<Array<T> *>(&a));
3334+ }
3335+ ArrayRef(const ArrayRef &other) :
3336+ Counted(), array_(0) {
3337+#ifdef DEBUG_COUNTING
3338+ cout << "instantiating ArrayRef " << this << " from ArrayRef " << &other << ":\n";
3339+#endif
3340+ reset(other.array_);
3341+ }
3342+
3343+ template<class Y>
3344+ ArrayRef(const ArrayRef<Y> &other) :
3345+ array_(0) {
3346+#ifdef DEBUG_COUNTING
3347+ cout << "instantiating ArrayRef " << this << " from ArrayRef " << &other << ":\n";
3348+#endif
3349+ reset(static_cast<const Array<T> *>(other.array_));
3350+ }
3351+
3352+ ~ArrayRef() {
3353+#ifdef DEBUG_COUNTING
3354+ cout << "destroying ArrayRef " << this << " with " << (array_ ? typeid(*array_).name() : "NULL") << " "
3355+ << array_ << "\n";
3356+#endif
3357+ if (array_) {
3358+ array_->release();
3359+ }
3360+ array_ = 0;
3361+ }
3362+
3363+ T operator[](size_t i) const {
3364+ return (*array_)[i];
3365+ }
3366+ T& operator[](size_t i) {
3367+ return (*array_)[i];
3368+ }
3369+ size_t size() const {
3370+ return array_->size();
3371+ }
3372+
3373+ void reset(Array<T> *a) {
3374+#ifdef DEBUG_COUNTING
3375+ cout << "resetting ArrayRef " << this << " from " << (array_ ? typeid(*array_).name() : "NULL") << " "
3376+ << array_ << " to " << (a ? typeid(*a).name() : "NULL") << " " << a << "\n";
3377+#endif
3378+ if (a) {
3379+ a->retain();
3380+ }
3381+ if (array_) {
3382+ array_->release();
3383+ }
3384+ array_ = a;
3385+ }
3386+ void reset(const ArrayRef<T> &other) {
3387+ reset(other.array_);
3388+ }
3389+ ArrayRef<T>& operator=(const ArrayRef<T> &other) {
3390+ reset(other);
3391+ return *this;
3392+ }
3393+ ArrayRef<T>& operator=(Array<T> *a) {
3394+ reset(a);
3395+ return *this;
3396+ }
3397+
3398+ Array<T>& operator*() {
3399+ return *array_;
3400+ }
3401+ Array<T>* operator->() {
3402+ return array_;
3403+ }
3404+};
3405+
3406+} // namespace zxing
3407+
3408+#endif // __ARRAY_H__
3409
3410=== added file '3rdParty/zxing/common/BitArray.cpp'
3411--- 3rdParty/zxing/common/BitArray.cpp 1970-01-01 00:00:00 +0000
3412+++ 3rdParty/zxing/common/BitArray.cpp 2014-05-10 17:38:08 +0000
3413@@ -0,0 +1,127 @@
3414+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3415+/*
3416+ * Copyright 2010 ZXing authors. All rights reserved.
3417+ *
3418+ * Licensed under the Apache License, Version 2.0 (the "License");
3419+ * you may not use this file except in compliance with the License.
3420+ * You may obtain a copy of the License at
3421+ *
3422+ * http://www.apache.org/licenses/LICENSE-2.0
3423+ *
3424+ * Unless required by applicable law or agreed to in writing, software
3425+ * distributed under the License is distributed on an "AS IS" BASIS,
3426+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3427+ * See the License for the specific language governing permissions and
3428+ * limitations under the License.
3429+ */
3430+
3431+#include <zxing/common/BitArray.h>
3432+
3433+using namespace std;
3434+
3435+namespace zxing {
3436+
3437+
3438+size_t BitArray::wordsForBits(size_t bits) {
3439+ int arraySize = (bits + bitsPerWord_ - 1) >> logBits_;
3440+ return arraySize;
3441+}
3442+
3443+BitArray::BitArray(size_t size) :
3444+ size_(size), bits_(wordsForBits(size), (const unsigned int)0) {
3445+}
3446+
3447+BitArray::~BitArray() {
3448+}
3449+
3450+size_t BitArray::getSize() {
3451+ return size_;
3452+}
3453+
3454+void BitArray::setBulk(size_t i, unsigned int newBits) {
3455+ bits_[i >> logBits_] = newBits;
3456+}
3457+
3458+void BitArray::setRange(int start, int end) {
3459+ if (end < start) {
3460+ throw IllegalArgumentException("invalid call to BitArray::setRange");
3461+ }
3462+ if (end == start) {
3463+ return;
3464+ }
3465+ end--; // will be easier to treat this as the last actually set bit -- inclusive
3466+ int firstInt = start >> 5;
3467+ int lastInt = end >> 5;
3468+ for (int i = firstInt; i <= lastInt; i++) {
3469+ int firstBit = i > firstInt ? 0 : start & 0x1F;
3470+ int lastBit = i < lastInt ? 31 : end & 0x1F;
3471+ int mask;
3472+ if (firstBit == 0 && lastBit == 31) {
3473+ mask = -1;
3474+ } else {
3475+ mask = 0;
3476+ for (int j = firstBit; j <= lastBit; j++) {
3477+ mask |= 1 << j;
3478+ }
3479+ }
3480+ bits_[i] |= mask;
3481+ }
3482+}
3483+
3484+void BitArray::clear() {
3485+ size_t max = bits_.size();
3486+ for (size_t i = 0; i < max; i++) {
3487+ bits_[i] = 0;
3488+ }
3489+}
3490+
3491+bool BitArray::isRange(size_t start, size_t end, bool value) {
3492+ if (end < start) {
3493+ throw IllegalArgumentException("end must be after start");
3494+ }
3495+ if (end == start) {
3496+ return true;
3497+ }
3498+ // treat the 'end' as inclusive, rather than exclusive
3499+ end--;
3500+ size_t firstWord = start >> logBits_;
3501+ size_t lastWord = end >> logBits_;
3502+ for (size_t i = firstWord; i <= lastWord; i++) {
3503+ size_t firstBit = i > firstWord ? 0 : start & bitsMask_;
3504+ size_t lastBit = i < lastWord ? bitsPerWord_ - 1: end & bitsMask_;
3505+ unsigned int mask;
3506+ if (firstBit == 0 && lastBit == bitsPerWord_ - 1) {
3507+ mask = numeric_limits<unsigned int>::max();
3508+ } else {
3509+ mask = 0;
3510+ for (size_t j = firstBit; j <= lastBit; j++) {
3511+ mask |= 1 << j;
3512+ }
3513+ }
3514+ if (value) {
3515+ if ((bits_[i] & mask) != mask) {
3516+ return false;
3517+ }
3518+ } else {
3519+ if ((bits_[i] & mask) != 0) {
3520+ return false;
3521+ }
3522+ }
3523+ }
3524+ return true;
3525+}
3526+
3527+vector<unsigned int>& BitArray::getBitArray() {
3528+ return bits_;
3529+}
3530+
3531+void BitArray::reverse() {
3532+ std::vector<unsigned int> newBits(bits_.size(),(const unsigned int) 0);
3533+ for (size_t i = 0; i < size_; i++) {
3534+ if (get(size_ - i - 1)) {
3535+ newBits[i >> logBits_] |= 1<< (i & bitsMask_);
3536+ }
3537+ }
3538+ bits_ = newBits;
3539+}
3540+}
3541
3542=== added file '3rdParty/zxing/common/BitArray.h'
3543--- 3rdParty/zxing/common/BitArray.h 1970-01-01 00:00:00 +0000
3544+++ 3rdParty/zxing/common/BitArray.h 2014-05-10 17:38:08 +0000
3545@@ -0,0 +1,70 @@
3546+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3547+#ifndef __BIT_ARRAY_H__
3548+#define __BIT_ARRAY_H__
3549+
3550+/*
3551+ * Copyright 2010 ZXing authors. All rights reserved.
3552+ *
3553+ * Licensed under the Apache License, Version 2.0 (the "License");
3554+ * you may not use this file except in compliance with the License.
3555+ * You may obtain a copy of the License at
3556+ *
3557+ * http://www.apache.org/licenses/LICENSE-2.0
3558+ *
3559+ * Unless required by applicable law or agreed to in writing, software
3560+ * distributed under the License is distributed on an "AS IS" BASIS,
3561+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3562+ * See the License for the specific language governing permissions and
3563+ * limitations under the License.
3564+ */
3565+
3566+#include <zxing/common/Counted.h>
3567+#include <zxing/common/IllegalArgumentException.h>
3568+#include <vector>
3569+#include <limits>
3570+
3571+namespace zxing {
3572+
3573+#define ZX_LOG_DIGITS(digits) \
3574+ ((digits == 8) ? 3 : \
3575+ ((digits == 16) ? 4 : \
3576+ ((digits == 32) ? 5 : \
3577+ ((digits == 64) ? 6 : \
3578+ ((digits == 128) ? 7 : \
3579+ (-1))))))
3580+
3581+class BitArray : public Counted {
3582+private:
3583+ size_t size_;
3584+ std::vector<unsigned int> bits_;
3585+ static const unsigned int bitsPerWord_ =
3586+ std::numeric_limits<unsigned int>::digits;
3587+ static const unsigned int logBits_ = ZX_LOG_DIGITS(bitsPerWord_);
3588+ static const unsigned int bitsMask_ = (1 << logBits_) - 1;
3589+ static size_t wordsForBits(size_t bits);
3590+ explicit BitArray();
3591+
3592+public:
3593+ BitArray(size_t size);
3594+ ~BitArray();
3595+ size_t getSize();
3596+
3597+ bool get(size_t i) {
3598+ return (bits_[i >> logBits_] & (1 << (i & bitsMask_))) != 0;
3599+ }
3600+
3601+ void set(size_t i) {
3602+ bits_[i >> logBits_] |= 1 << (i & bitsMask_);
3603+ }
3604+
3605+ void setBulk(size_t i, unsigned int newBits);
3606+ void setRange(int start, int end);
3607+ void clear();
3608+ bool isRange(size_t start, size_t end, bool value);
3609+ std::vector<unsigned int>& getBitArray();
3610+ void reverse();
3611+};
3612+
3613+}
3614+
3615+#endif // __BIT_ARRAY_H__
3616
3617=== added file '3rdParty/zxing/common/BitMatrix.cpp'
3618--- 3rdParty/zxing/common/BitMatrix.cpp 1970-01-01 00:00:00 +0000
3619+++ 3rdParty/zxing/common/BitMatrix.cpp 2014-05-10 17:38:08 +0000
3620@@ -0,0 +1,157 @@
3621+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3622+/*
3623+ * Copyright 2010 ZXing authors. All rights reserved.
3624+ *
3625+ * Licensed under the Apache License, Version 2.0 (the "License");
3626+ * you may not use this file except in compliance with the License.
3627+ * You may obtain a copy of the License at
3628+ *
3629+ * http://www.apache.org/licenses/LICENSE-2.0
3630+ *
3631+ * Unless required by applicable law or agreed to in writing, software
3632+ * distributed under the License is distributed on an "AS IS" BASIS,
3633+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3634+ * See the License for the specific language governing permissions and
3635+ * limitations under the License.
3636+ */
3637+
3638+#include <zxing/common/BitMatrix.h>
3639+#include <zxing/common/IllegalArgumentException.h>
3640+
3641+#include <iostream>
3642+#include <sstream>
3643+#include <string>
3644+
3645+using std::ostream;
3646+using std::ostringstream;
3647+
3648+using zxing::BitMatrix;
3649+using zxing::BitArray;
3650+using zxing::Ref;
3651+
3652+namespace {
3653+ size_t wordsForSize(size_t width,
3654+ size_t height,
3655+ unsigned int bitsPerWord,
3656+ unsigned int logBits) {
3657+ size_t bits = width * height;
3658+ int arraySize = (bits + bitsPerWord - 1) >> logBits;
3659+ return arraySize;
3660+ }
3661+}
3662+
3663+BitMatrix::BitMatrix(size_t dimension) :
3664+ width_(dimension), height_(dimension), words_(0), bits_(NULL) {
3665+ words_ = wordsForSize(width_, height_, bitsPerWord, logBits);
3666+ bits_ = new unsigned int[words_];
3667+ clear();
3668+}
3669+
3670+BitMatrix::BitMatrix(size_t width, size_t height) :
3671+ width_(width), height_(height), words_(0), bits_(NULL) {
3672+ words_ = wordsForSize(width_, height_, bitsPerWord, logBits);
3673+ bits_ = new unsigned int[words_];
3674+ clear();
3675+}
3676+
3677+BitMatrix::~BitMatrix() {
3678+ delete[] bits_;
3679+}
3680+
3681+
3682+void BitMatrix::flip(size_t x, size_t y) {
3683+ size_t offset = x + width_ * y;
3684+ bits_[offset >> logBits] ^= 1 << (offset & bitsMask);
3685+}
3686+
3687+void BitMatrix::clear() {
3688+ std::fill(bits_, bits_+words_, 0);
3689+}
3690+
3691+void BitMatrix::setRegion(size_t left, size_t top, size_t width, size_t height) {
3692+ if ((long)top < 0 || (long)left < 0) {
3693+ throw IllegalArgumentException("topI and leftJ must be nonnegative");
3694+ }
3695+ if (height < 1 || width < 1) {
3696+ throw IllegalArgumentException("height and width must be at least 1");
3697+ }
3698+ size_t right = left + width;
3699+ size_t bottom = top + height;
3700+ if (right > width_ || bottom > height_) {
3701+ throw IllegalArgumentException("top + height and left + width must be <= matrix dimension");
3702+ }
3703+ for (size_t y = top; y < bottom; y++) {
3704+ int yOffset = width_ * y;
3705+ for (size_t x = left; x < right; x++) {
3706+ size_t offset = x + yOffset;
3707+ bits_[offset >> logBits] |= 1 << (offset & bitsMask);
3708+ }
3709+ }
3710+}
3711+
3712+Ref<BitArray> BitMatrix::getRow(int y, Ref<BitArray> row) {
3713+ if (row.empty() || row->getSize() < width_) {
3714+ row = new BitArray(width_);
3715+ } else {
3716+ row->clear();
3717+ }
3718+ size_t start = y * width_;
3719+ size_t end = start + width_ - 1; // end is inclusive
3720+ size_t firstWord = start >> logBits;
3721+ size_t lastWord = end >> logBits;
3722+ size_t bitOffset = start & bitsMask;
3723+ for (size_t i = firstWord; i <= lastWord; i++) {
3724+ size_t firstBit = i > firstWord ? 0 : start & bitsMask;
3725+ size_t lastBit = i < lastWord ? bitsPerWord - 1 : end & bitsMask;
3726+ unsigned int mask;
3727+ if (firstBit == 0 && lastBit == logBits) {
3728+ mask = std::numeric_limits<unsigned int>::max();
3729+ } else {
3730+ mask = 0;
3731+ for (size_t j = firstBit; j <= lastBit; j++) {
3732+ mask |= 1 << j;
3733+ }
3734+ }
3735+ row->setBulk((i - firstWord) << logBits, (bits_[i] & mask) >> bitOffset);
3736+ if (firstBit == 0 && bitOffset != 0) {
3737+ unsigned int prevBulk = row->getBitArray()[i - firstWord - 1];
3738+ prevBulk |= (bits_[i] & mask) << (bitsPerWord - bitOffset);
3739+ row->setBulk((i - firstWord - 1) << logBits, prevBulk);
3740+ }
3741+ }
3742+ return row;
3743+}
3744+
3745+size_t BitMatrix::getWidth() const {
3746+ return width_;
3747+}
3748+
3749+size_t BitMatrix::getHeight() const {
3750+ return height_;
3751+}
3752+
3753+size_t BitMatrix::getDimension() const {
3754+ return width_;
3755+}
3756+
3757+unsigned int* BitMatrix::getBits() const {
3758+ return bits_;
3759+}
3760+
3761+namespace zxing {
3762+ ostream& operator<<(ostream &out, const BitMatrix &bm) {
3763+ for (size_t y = 0; y < bm.height_; y++) {
3764+ for (size_t x = 0; x < bm.width_; x++) {
3765+ out << (bm.get(x, y) ? "X " : " ");
3766+ }
3767+ out << "\n";
3768+ }
3769+ return out;
3770+ }
3771+}
3772+
3773+const char* BitMatrix::description() {
3774+ ostringstream out;
3775+ out << *this;
3776+ return out.str().c_str();
3777+}
3778
3779=== added file '3rdParty/zxing/common/BitMatrix.h'
3780--- 3rdParty/zxing/common/BitMatrix.h 1970-01-01 00:00:00 +0000
3781+++ 3rdParty/zxing/common/BitMatrix.h 2014-05-10 17:38:08 +0000
3782@@ -0,0 +1,87 @@
3783+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3784+#ifndef __BIT_MATRIX_H__
3785+#define __BIT_MATRIX_H__
3786+
3787+/*
3788+ * BitMatrix.h
3789+ * zxing
3790+ *
3791+ * Copyright 2010 ZXing authors All rights reserved.
3792+ *
3793+ * Licensed under the Apache License, Version 2.0 (the "License");
3794+ * you may not use this file except in compliance with the License.
3795+ * You may obtain a copy of the License at
3796+ *
3797+ * http://www.apache.org/licenses/LICENSE-2.0
3798+ *
3799+ * Unless required by applicable law or agreed to in writing, software
3800+ * distributed under the License is distributed on an "AS IS" BASIS,
3801+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3802+ * See the License for the specific language governing permissions and
3803+ * limitations under the License.
3804+ */
3805+
3806+#include <zxing/common/Counted.h>
3807+#include <zxing/common/BitArray.h>
3808+#include <limits>
3809+
3810+namespace zxing {
3811+
3812+class BitMatrix : public Counted {
3813+private:
3814+ size_t width_;
3815+ size_t height_;
3816+ size_t words_;
3817+ unsigned int* bits_;
3818+
3819+#define ZX_LOG_DIGITS(digits) \
3820+ ((digits == 8) ? 3 : \
3821+ ((digits == 16) ? 4 : \
3822+ ((digits == 32) ? 5 : \
3823+ ((digits == 64) ? 6 : \
3824+ ((digits == 128) ? 7 : \
3825+ (-1))))))
3826+
3827+ static const unsigned int bitsPerWord =
3828+ std::numeric_limits<unsigned int>::digits;
3829+ static const unsigned int logBits = ZX_LOG_DIGITS(bitsPerWord);
3830+ static const unsigned int bitsMask = (1 << logBits) - 1;
3831+
3832+public:
3833+ BitMatrix(size_t dimension);
3834+ BitMatrix(size_t width, size_t height);
3835+
3836+ ~BitMatrix();
3837+
3838+ bool get(size_t x, size_t y) const {
3839+ size_t offset = x + width_ * y;
3840+ return ((bits_[offset >> logBits] >> (offset & bitsMask)) & 0x01) != 0;
3841+ }
3842+
3843+ void set(size_t x, size_t y) {
3844+ size_t offset = x + width_ * y;
3845+ bits_[offset >> logBits] |= 1 << (offset & bitsMask);
3846+ }
3847+
3848+ void flip(size_t x, size_t y);
3849+ void clear();
3850+ void setRegion(size_t left, size_t top, size_t width, size_t height);
3851+ Ref<BitArray> getRow(int y, Ref<BitArray> row);
3852+
3853+ size_t getDimension() const;
3854+ size_t getWidth() const;
3855+ size_t getHeight() const;
3856+
3857+ unsigned int* getBits() const;
3858+
3859+ friend std::ostream& operator<<(std::ostream &out, const BitMatrix &bm);
3860+ const char *description();
3861+
3862+private:
3863+ BitMatrix(const BitMatrix&);
3864+ BitMatrix& operator =(const BitMatrix&);
3865+};
3866+
3867+}
3868+
3869+#endif // __BIT_MATRIX_H__
3870
3871=== added file '3rdParty/zxing/common/BitSource.cpp'
3872--- 3rdParty/zxing/common/BitSource.cpp 1970-01-01 00:00:00 +0000
3873+++ 3rdParty/zxing/common/BitSource.cpp 2014-05-10 17:38:08 +0000
3874@@ -0,0 +1,74 @@
3875+/*
3876+ * BitSource.cpp
3877+ * zxing
3878+ *
3879+ * Created by Christian Brunschen on 09/05/2008.
3880+ * Copyright 2008 Google UK. All rights reserved.
3881+ *
3882+ * Licensed under the Apache License, Version 2.0 (the "License");
3883+ * you may not use this file except in compliance with the License.
3884+ * You may obtain a copy of the License at
3885+ *
3886+ * http://www.apache.org/licenses/LICENSE-2.0
3887+ *
3888+ * Unless required by applicable law or agreed to in writing, software
3889+ * distributed under the License is distributed on an "AS IS" BASIS,
3890+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3891+ * See the License for the specific language governing permissions and
3892+ * limitations under the License.
3893+ */
3894+
3895+#include <zxing/common/BitSource.h>
3896+#include <zxing/common/IllegalArgumentException.h>
3897+
3898+namespace zxing {
3899+
3900+int BitSource::readBits(int numBits) {
3901+ if (numBits < 0 || numBits > 32) {
3902+ throw IllegalArgumentException("cannot read <1 or >32 bits");
3903+ } else if (numBits > available()) {
3904+ throw IllegalArgumentException("reading more bits than are available");
3905+ }
3906+
3907+ int result = 0;
3908+
3909+ // First, read remainder from current byte
3910+ if (bitOffset_ > 0) {
3911+ int bitsLeft = 8 - bitOffset_;
3912+ int toRead = numBits < bitsLeft ? numBits : bitsLeft;
3913+ int bitsToNotRead = bitsLeft - toRead;
3914+ int mask = (0xFF >> (8 - toRead)) << bitsToNotRead;
3915+ result = (bytes_[byteOffset_] & mask) >> bitsToNotRead;
3916+ numBits -= toRead;
3917+ bitOffset_ += toRead;
3918+ if (bitOffset_ == 8) {
3919+ bitOffset_ = 0;
3920+ byteOffset_++;
3921+ }
3922+ }
3923+
3924+ // Next read whole bytes
3925+ if (numBits > 0) {
3926+ while (numBits >= 8) {
3927+ result = (result << 8) | (bytes_[byteOffset_] & 0xFF);
3928+ byteOffset_++;
3929+ numBits -= 8;
3930+ }
3931+
3932+
3933+ // Finally read a partial byte
3934+ if (numBits > 0) {
3935+ int bitsToNotRead = 8 - numBits;
3936+ int mask = (0xFF >> bitsToNotRead) << bitsToNotRead;
3937+ result = (result << numBits) | ((bytes_[byteOffset_] & mask) >> bitsToNotRead);
3938+ bitOffset_ += numBits;
3939+ }
3940+ }
3941+
3942+ return result;
3943+}
3944+
3945+int BitSource::available() {
3946+ return 8 * (bytes_.size() - byteOffset_) - bitOffset_;
3947+}
3948+}
3949
3950=== added file '3rdParty/zxing/common/BitSource.h'
3951--- 3rdParty/zxing/common/BitSource.h 1970-01-01 00:00:00 +0000
3952+++ 3rdParty/zxing/common/BitSource.h 2014-05-10 17:38:08 +0000
3953@@ -0,0 +1,70 @@
3954+#ifndef __BIT_SOURCE_H__
3955+#define __BIT_SOURCE_H__
3956+
3957+/*
3958+ * BitSource.h
3959+ * zxing
3960+ *
3961+ * Copyright 2010 ZXing authors All rights reserved.
3962+ *
3963+ * Licensed under the Apache License, Version 2.0 (the "License");
3964+ * you may not use this file except in compliance with the License.
3965+ * You may obtain a copy of the License at
3966+ *
3967+ * http://www.apache.org/licenses/LICENSE-2.0
3968+ *
3969+ * Unless required by applicable law or agreed to in writing, software
3970+ * distributed under the License is distributed on an "AS IS" BASIS,
3971+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3972+ * See the License for the specific language governing permissions and
3973+ * limitations under the License.
3974+ */
3975+
3976+#include <zxing/common/Array.h>
3977+
3978+namespace zxing {
3979+/**
3980+ * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
3981+ * number of bits read is not often a multiple of 8.</p>
3982+ *
3983+ * <p>This class is not thread-safe.</p>
3984+ *
3985+ * @author srowen@google.com (Sean Owen)
3986+ * @author christian.brunschen@gmail.com (Christian Brunschen)
3987+ */
3988+class BitSource : public Counted {
3989+ typedef unsigned char byte;
3990+private:
3991+ ArrayRef<byte> bytes_;
3992+ int byteOffset_;
3993+ int bitOffset_;
3994+public:
3995+ /**
3996+ * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
3997+ * Bits are read within a byte from most-significant to least-significant bit.
3998+ */
3999+ BitSource(ArrayRef<byte> &bytes) :
4000+ bytes_(bytes), byteOffset_(0), bitOffset_(0) {
4001+ }
4002+
4003+ int getByteOffset() {
4004+ return byteOffset_;
4005+ }
4006+
4007+ /**
4008+ * @param numBits number of bits to read
4009+ * @return int representing the bits read. The bits will appear as the least-significant
4010+ * bits of the int
4011+ * @throws IllegalArgumentException if numBits isn't in [1,32]
4012+ */
4013+ int readBits(int numBits);
4014+
4015+ /**
4016+ * @return number of bits that can be read successfully
4017+ */
4018+ int available();
4019+};
4020+
4021+}
4022+
4023+#endif // __BIT_SOURCE_H__
4024
4025=== added file '3rdParty/zxing/common/CharacterSetECI.cpp'
4026--- 3rdParty/zxing/common/CharacterSetECI.cpp 1970-01-01 00:00:00 +0000
4027+++ 3rdParty/zxing/common/CharacterSetECI.cpp 2014-05-10 17:38:08 +0000
4028@@ -0,0 +1,104 @@
4029+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
4030+/*
4031+ * Copyright 2008-2011 ZXing authors
4032+ *
4033+ * Licensed under the Apache License, Version 2.0 (the "License");
4034+ * you may not use this file except in compliance with the License.
4035+ * You may obtain a copy of the License at
4036+ *
4037+ * http://www.apache.org/licenses/LICENSE-2.0
4038+ *
4039+ * Unless required by applicable law or agreed to in writing, software
4040+ * distributed under the License is distributed on an "AS IS" BASIS,
4041+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4042+ * See the License for the specific language governing permissions and
4043+ * limitations under the License.
4044+ */
4045+
4046+#include <zxing/common/CharacterSetECI.h>
4047+#include <zxing/common/IllegalArgumentException.h>
4048+#include <zxing/FormatException.h>
4049+
4050+using std::string;
4051+
4052+using zxing::common::CharacterSetECI;
4053+using zxing::IllegalArgumentException;
4054+
4055+std::map<int, CharacterSetECI*> CharacterSetECI::VALUE_TO_ECI;
4056+std::map<std::string, CharacterSetECI*> CharacterSetECI::NAME_TO_ECI;
4057+
4058+const bool CharacterSetECI::inited = CharacterSetECI::init_tables();
4059+
4060+#define ADD_CHARACTER_SET(VALUES, STRINGS) \
4061+ { static int values[] = {VALUES, -1}; \
4062+ static char const* strings[] = {STRINGS, 0}; \
4063+ addCharacterSet(values, strings); }
4064+
4065+#define XC ,
4066+
4067+bool CharacterSetECI::init_tables() {
4068+ ADD_CHARACTER_SET(0 XC 2, "Cp437");
4069+ ADD_CHARACTER_SET(1 XC 3, "ISO8859_1" XC "ISO-8859-1");
4070+ ADD_CHARACTER_SET(4, "ISO8859_2" XC "ISO-8859-2");
4071+ ADD_CHARACTER_SET(5, "ISO8859_3" XC "ISO-8859-3");
4072+ ADD_CHARACTER_SET(6, "ISO8859_4" XC "ISO-8859-4");
4073+ ADD_CHARACTER_SET(7, "ISO8859_5" XC "ISO-8859-5");
4074+ ADD_CHARACTER_SET(8, "ISO8859_6" XC "ISO-8859-6");
4075+ ADD_CHARACTER_SET(9, "ISO8859_7" XC "ISO-8859-7");
4076+ ADD_CHARACTER_SET(10, "ISO8859_8" XC "ISO-8859-8");
4077+ ADD_CHARACTER_SET(11, "ISO8859_9" XC "ISO-8859-9");
4078+ ADD_CHARACTER_SET(12, "ISO8859_10" XC "ISO-8859-10");
4079+ ADD_CHARACTER_SET(13, "ISO8859_11" XC "ISO-8859-11");
4080+ ADD_CHARACTER_SET(15, "ISO8859_13" XC "ISO-8859-13");
4081+ ADD_CHARACTER_SET(16, "ISO8859_14" XC "ISO-8859-14");
4082+ ADD_CHARACTER_SET(17, "ISO8859_15" XC "ISO-8859-15");
4083+ ADD_CHARACTER_SET(18, "ISO8859_16" XC "ISO-8859-16");
4084+ ADD_CHARACTER_SET(20, "SJIS" XC "Shift_JIS");
4085+ ADD_CHARACTER_SET(21, "Cp1250" XC "windows-1250");
4086+ ADD_CHARACTER_SET(22, "Cp1251" XC "windows-1251");
4087+ ADD_CHARACTER_SET(23, "Cp1252" XC "windows-1252");
4088+ ADD_CHARACTER_SET(24, "Cp1256" XC "windows-1256");
4089+ ADD_CHARACTER_SET(25, "UnicodeBigUnmarked" XC "UTF-16BE" XC "UnicodeBig");
4090+ ADD_CHARACTER_SET(26, "UTF8" XC "UTF-8");
4091+ ADD_CHARACTER_SET(27 XC 170, "ASCII" XC "US-ASCII");
4092+ ADD_CHARACTER_SET(28, "Big5");
4093+ ADD_CHARACTER_SET(29, "GB18030" XC "GB2312" XC "EUC_CN" XC "GBK");
4094+ ADD_CHARACTER_SET(30, "EUC_KR" XC "EUC-KR");
4095+ return true;
4096+}
4097+
4098+#undef XC
4099+
4100+CharacterSetECI::CharacterSetECI(int const* values,
4101+ char const* const* names)
4102+ : values_(values), names_(names) {
4103+ for(int const* values = values_; *values != -1; values++) {
4104+ VALUE_TO_ECI[*values] = this;
4105+ }
4106+ for(char const* const* names = names_; *names; names++) {
4107+ NAME_TO_ECI[string(*names)] = this;
4108+ }
4109+}
4110+
4111+char const* CharacterSetECI::name() const {
4112+ return names_[0];
4113+}
4114+
4115+int CharacterSetECI::getValue() const {
4116+ return values_[0];
4117+}
4118+
4119+void CharacterSetECI::addCharacterSet(int const* values, char const* const* names) {
4120+ new CharacterSetECI(values, names);
4121+}
4122+
4123+CharacterSetECI* CharacterSetECI::getCharacterSetECIByValue(int value) {
4124+ if (value < 0 || value >= 900) {
4125+ throw FormatException();
4126+ }
4127+ return VALUE_TO_ECI[value];
4128+}
4129+
4130+CharacterSetECI* CharacterSetECI::getCharacterSetECIByName(string const& name) {
4131+ return NAME_TO_ECI[name];
4132+}
4133
4134=== added file '3rdParty/zxing/common/CharacterSetECI.h'
4135--- 3rdParty/zxing/common/CharacterSetECI.h 1970-01-01 00:00:00 +0000
4136+++ 3rdParty/zxing/common/CharacterSetECI.h 2014-05-10 17:38:08 +0000
4137@@ -0,0 +1,53 @@
4138+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
4139+
4140+#ifndef __CHARACTERSET_ECI__
4141+#define __CHARACTERSET_ECI__
4142+
4143+/*
4144+ * Copyright 2008-2011 ZXing authors
4145+ *
4146+ * Licensed under the Apache License, Version 2.0 (the "License");
4147+ * you may not use this file except in compliance with the License.
4148+ * You may obtain a copy of the License at
4149+ *
4150+ * http://www.apache.org/licenses/LICENSE-2.0
4151+ *
4152+ * Unless required by applicable law or agreed to in writing, software
4153+ * distributed under the License is distributed on an "AS IS" BASIS,
4154+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4155+ * See the License for the specific language governing permissions and
4156+ * limitations under the License.
4157+ */
4158+
4159+#include <map>
4160+#include <zxing/DecodeHints.h>
4161+
4162+namespace zxing {
4163+ namespace common {
4164+ class CharacterSetECI;
4165+ }
4166+}
4167+
4168+class zxing::common::CharacterSetECI {
4169+private:
4170+ static std::map<int, CharacterSetECI*> VALUE_TO_ECI;
4171+ static std::map<std::string, CharacterSetECI*> NAME_TO_ECI;
4172+ static const bool inited;
4173+ static bool init_tables();
4174+
4175+ int const* const values_;
4176+ char const* const* const names_;
4177+
4178+ CharacterSetECI(int const* values, char const* const* names);
4179+
4180+ static void addCharacterSet(int const* value, char const* const* encodingNames);
4181+
4182+public:
4183+ char const* name() const;
4184+ int getValue() const;
4185+
4186+ static CharacterSetECI* getCharacterSetECIByValue(int value);
4187+ static CharacterSetECI* getCharacterSetECIByName(std::string const& name);
4188+};
4189+
4190+#endif
4191
4192=== added file '3rdParty/zxing/common/Counted.cpp'
4193--- 3rdParty/zxing/common/Counted.cpp 1970-01-01 00:00:00 +0000
4194+++ 3rdParty/zxing/common/Counted.cpp 2014-05-10 17:38:08 +0000
4195@@ -0,0 +1,32 @@
4196+/*
4197+ * Counted.cpp
4198+ * zxing
4199+ *
4200+ * Created by Christian Brunschen on 07/05/2008.
4201+ * Copyright 2008 Google UK. All rights reserved.
4202+ *
4203+ * Licensed under the Apache License, Version 2.0 (the "License");
4204+ * you may not use this file except in compliance with the License.
4205+ * You may obtain a copy of the License at
4206+ *
4207+ * http://www.apache.org/licenses/LICENSE-2.0
4208+ *
4209+ * Unless required by applicable law or agreed to in writing, software
4210+ * distributed under the License is distributed on an "AS IS" BASIS,
4211+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4212+ * See the License for the specific language governing permissions and
4213+ * limitations under the License.
4214+ */
4215+
4216+#include <zxing/common/Counted.h>
4217+
4218+namespace zxing {
4219+
4220+using namespace std;
4221+
4222+template<class T>
4223+ostream& operator<<(ostream &out, Ref<T>& ref) {
4224+ out << "Ref(" << (ref.object_ ? (*ref.object_) : "NULL") << ")";
4225+ return out;
4226+}
4227+}
4228
4229=== added file '3rdParty/zxing/common/Counted.h'
4230--- 3rdParty/zxing/common/Counted.h 1970-01-01 00:00:00 +0000
4231+++ 3rdParty/zxing/common/Counted.h 2014-05-10 17:38:08 +0000
4232@@ -0,0 +1,202 @@
4233+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
4234+#ifndef __COUNTED_H__
4235+#define __COUNTED_H__
4236+
4237+/*
4238+ * Copyright 2010 ZXing authors All rights reserved.
4239+ *
4240+ * Licensed under the Apache License, Version 2.0 (the "License");
4241+ * you may not use this file except in compliance with the License.
4242+ * You may obtain a copy of the License at
4243+ *
4244+ * http://www.apache.org/licenses/LICENSE-2.0
4245+ *
4246+ * Unless required by applicable law or agreed to in writing, software
4247+ * distributed under the License is distributed on an "AS IS" BASIS,
4248+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4249+ * See the License for the specific language governing permissions and
4250+ * limitations under the License.
4251+ */
4252+
4253+//#define DEBUG_COUNTING
4254+
4255+#include <iostream>
4256+
4257+#ifdef DEBUG_COUNTING
4258+#include <typeinfo>
4259+#endif
4260+
4261+namespace zxing {
4262+
4263+/* base class for reference-counted objects */
4264+class Counted {
4265+private:
4266+ unsigned int count_;
4267+public:
4268+ Counted() :
4269+ count_(0) {
4270+#ifdef DEBUG_COUNTING
4271+ cout << "instantiating " << typeid(*this).name() << " " << this <<
4272+ " @ " << count_ << "\n";
4273+#endif
4274+ }
4275+ virtual ~Counted() {
4276+ }
4277+ Counted *retain() {
4278+#ifdef DEBUG_COUNTING
4279+ cout << "retaining " << typeid(*this).name() << " " << this <<
4280+ " @ " << count_;
4281+#endif
4282+ count_++;
4283+#ifdef DEBUG_COUNTING
4284+ cout << "->" << count_ << "\n";
4285+#endif
4286+ return this;
4287+ }
4288+ void release() {
4289+#ifdef DEBUG_COUNTING
4290+ cout << "releasing " << typeid(*this).name() << " " << this <<
4291+ " @ " << count_;
4292+#endif
4293+ if (count_ == 0 || count_ == 54321) {
4294+#ifdef DEBUG_COUNTING
4295+ cout << "\nOverreleasing already-deleted object " << this << "!!!\n";
4296+#endif
4297+ throw 4711;
4298+ }
4299+ count_--;
4300+#ifdef DEBUG_COUNTING
4301+ cout << "->" << count_ << "\n";
4302+#endif
4303+ if (count_ == 0) {
4304+#ifdef DEBUG_COUNTING
4305+ cout << "deleting " << typeid(*this).name() << " " << this << "\n";
4306+#endif
4307+ count_ = 0xDEADF001;
4308+ delete this;
4309+ }
4310+ }
4311+
4312+
4313+ /* return the current count for denugging purposes or similar */
4314+ int count() const {
4315+ return count_;
4316+ }
4317+};
4318+
4319+/* counting reference to reference-counted objects */
4320+template<typename T> class Ref {
4321+private:
4322+public:
4323+ T *object_;
4324+ explicit Ref(T *o = 0) :
4325+ object_(0) {
4326+#ifdef DEBUG_COUNTING
4327+ cout << "instantiating Ref " << this << " from pointer" << o << "\n";
4328+#endif
4329+ reset(o);
4330+ }
4331+
4332+ explicit Ref(const T &o) :
4333+ object_(0) {
4334+#ifdef DEBUG_COUNTING
4335+ cout << "instantiating Ref " << this << " from reference\n";
4336+#endif
4337+ reset(const_cast<T *>(&o));
4338+ }
4339+
4340+ Ref(const Ref &other) :
4341+ object_(0) {
4342+#ifdef DEBUG_COUNTING
4343+ cout << "instantiating Ref " << this << " from Ref " << &other << "\n";
4344+#endif
4345+ reset(other.object_);
4346+ }
4347+
4348+ template<class Y>
4349+ Ref(const Ref<Y> &other) :
4350+ object_(0) {
4351+#ifdef DEBUG_COUNTING
4352+ cout << "instantiating Ref " << this << " from reference\n";
4353+#endif
4354+ reset(other.object_);
4355+ }
4356+
4357+ ~Ref() {
4358+#ifdef DEBUG_COUNTING
4359+ cout << "destroying Ref " << this << " with " <<
4360+ (object_ ? typeid(*object_).name() : "NULL") << " " << object_ << "\n";
4361+#endif
4362+ if (object_) {
4363+ object_->release();
4364+ }
4365+ }
4366+
4367+ void reset(T *o) {
4368+#ifdef DEBUG_COUNTING
4369+ cout << "resetting Ref " << this << " from " <<
4370+ (object_ ? typeid(*object_).name() : "NULL") << " " << object_ <<
4371+ " to " << (o ? typeid(*o).name() : "NULL") << " " << o << "\n";
4372+#endif
4373+ if (o) {
4374+ o->retain();
4375+ }
4376+ if (object_ != 0) {
4377+ object_->release();
4378+ }
4379+ object_ = o;
4380+ }
4381+ Ref& operator=(const Ref &other) {
4382+ reset(other.object_);
4383+ return *this;
4384+ }
4385+ template<class Y>
4386+ Ref& operator=(const Ref<Y> &other) {
4387+ reset(other.object_);
4388+ return *this;
4389+ }
4390+ Ref& operator=(T* o) {
4391+ reset(o);
4392+ return *this;
4393+ }
4394+ template<class Y>
4395+ Ref& operator=(Y* o) {
4396+ reset(o);
4397+ return *this;
4398+ }
4399+
4400+ T& operator*() {
4401+ return *object_;
4402+ }
4403+ T* operator->() const {
4404+ return object_;
4405+ }
4406+ operator T*() const {
4407+ return object_;
4408+ }
4409+
4410+ bool operator==(const T* that) {
4411+ return object_ == that;
4412+ }
4413+ bool operator==(const Ref &other) const {
4414+ return object_ == other.object_ || *object_ == *(other.object_);
4415+ }
4416+ template<class Y>
4417+ bool operator==(const Ref<Y> &other) const {
4418+ return object_ == other.object_ || *object_ == *(other.object_);
4419+ }
4420+
4421+ bool operator!=(const T* that) {
4422+ return !(*this == that);
4423+ }
4424+
4425+ bool empty() const {
4426+ return object_ == 0;
4427+ }
4428+
4429+ template<class Y>
4430+ friend std::ostream& operator<<(std::ostream &out, Ref<Y>& ref);
4431+};
4432+}
4433+
4434+#endif // __COUNTED_H__
4435
4436=== added file '3rdParty/zxing/common/DecoderResult.cpp'
4437--- 3rdParty/zxing/common/DecoderResult.cpp 1970-01-01 00:00:00 +0000
4438+++ 3rdParty/zxing/common/DecoderResult.cpp 2014-05-10 17:38:08 +0000
4439@@ -0,0 +1,46 @@
4440+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
4441+/*
4442+ * DecoderResult.cpp
4443+ * zxing
4444+ *
4445+ * Created by Christian Brunschen on 20/05/2008.
4446+ * Copyright 2008-2011 ZXing authors All rights reserved.
4447+ *
4448+ * Licensed under the Apache License, Version 2.0 (the "License");
4449+ * you may not use this file except in compliance with the License.
4450+ * You may obtain a copy of the License at
4451+ *
4452+ * http://www.apache.org/licenses/LICENSE-2.0
4453+ *
4454+ * Unless required by applicable law or agreed to in writing, software
4455+ * distributed under the License is distributed on an "AS IS" BASIS,
4456+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4457+ * See the License for the specific language governing permissions and
4458+ * limitations under the License.
4459+ */
4460+
4461+#include <zxing/common/DecoderResult.h>
4462+
4463+using namespace std;
4464+using namespace zxing;
4465+
4466+DecoderResult::DecoderResult(ArrayRef<unsigned char> rawBytes,
4467+ Ref<String> text,
4468+ ArrayRef< ArrayRef<unsigned char> >& byteSegments,
4469+ string const& ecLevel) :
4470+ rawBytes_(rawBytes),
4471+ text_(text),
4472+ byteSegments_(byteSegments),
4473+ ecLevel_(ecLevel) {}
4474+
4475+DecoderResult::DecoderResult(ArrayRef<unsigned char> rawBytes,
4476+ Ref<String> text)
4477+ : rawBytes_(rawBytes), text_(text) {}
4478+
4479+ArrayRef<unsigned char> DecoderResult::getRawBytes() {
4480+ return rawBytes_;
4481+}
4482+
4483+Ref<String> DecoderResult::getText() {
4484+ return text_;
4485+}
4486
4487=== added file '3rdParty/zxing/common/DecoderResult.h'
4488--- 3rdParty/zxing/common/DecoderResult.h 1970-01-01 00:00:00 +0000
4489+++ 3rdParty/zxing/common/DecoderResult.h 2014-05-10 17:38:08 +0000
4490@@ -0,0 +1,51 @@
4491+#ifndef __DECODER_RESULT_H__
4492+#define __DECODER_RESULT_H__
4493+
4494+/*
4495+ * DecoderResult.h
4496+ * zxing
4497+ *
4498+ * Copyright 2010 ZXing authors All rights reserved.
4499+ *
4500+ * Licensed under the Apache License, Version 2.0 (the "License");
4501+ * you may not use this file except in compliance with the License.
4502+ * You may obtain a copy of the License at
4503+ *
4504+ * http://www.apache.org/licenses/LICENSE-2.0
4505+ *
4506+ * Unless required by applicable law or agreed to in writing, software
4507+ * distributed under the License is distributed on an "AS IS" BASIS,
4508+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4509+ * See the License for the specific language governing permissions and
4510+ * limitations under the License.
4511+ */
4512+
4513+#include <zxing/common/Counted.h>
4514+#include <zxing/common/Array.h>
4515+#include <string>
4516+#include <zxing/common/Str.h>
4517+
4518+namespace zxing {
4519+
4520+class DecoderResult : public Counted {
4521+private:
4522+ ArrayRef<unsigned char> rawBytes_;
4523+ Ref<String> text_;
4524+ ArrayRef< ArrayRef<unsigned char> > byteSegments_;
4525+ std::string ecLevel_;
4526+
4527+public:
4528+ DecoderResult(ArrayRef<unsigned char> rawBytes,
4529+ Ref<String> text,
4530+ ArrayRef< ArrayRef<unsigned char> >& byteSegments,
4531+ std::string const& ecLevel);
4532+
4533+ DecoderResult(ArrayRef<unsigned char> rawBytes, Ref<String> text);
4534+
4535+ ArrayRef<unsigned char> getRawBytes();
4536+ Ref<String> getText();
4537+};
4538+
4539+}
4540+
4541+#endif // __DECODER_RESULT_H__
4542
4543=== added file '3rdParty/zxing/common/DetectorResult.cpp'
4544--- 3rdParty/zxing/common/DetectorResult.cpp 1970-01-01 00:00:00 +0000
4545+++ 3rdParty/zxing/common/DetectorResult.cpp 2014-05-10 17:38:08 +0000
4546@@ -0,0 +1,38 @@
4547+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
4548+/*
4549+ * DetectorResult.cpp
4550+ * zxing
4551+ *
4552+ * Created by Christian Brunschen on 14/05/2008.
4553+ * Copyright 2008 ZXing authors All rights reserved.
4554+ *
4555+ * Licensed under the Apache License, Version 2.0 (the "License");
4556+ * you may not use this file except in compliance with the License.
4557+ * You may obtain a copy of the License at
4558+ *
4559+ * http://www.apache.org/licenses/LICENSE-2.0
4560+ *
4561+ * Unless required by applicable law or agreed to in writing, software
4562+ * distributed under the License is distributed on an "AS IS" BASIS,
4563+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4564+ * See the License for the specific language governing permissions and
4565+ * limitations under the License.
4566+ */
4567+
4568+#include <zxing/common/DetectorResult.h>
4569+
4570+namespace zxing {
4571+
4572+DetectorResult::DetectorResult(Ref<BitMatrix> bits, std::vector<Ref<ResultPoint> > points) :
4573+ bits_(bits), points_(points) {
4574+}
4575+
4576+Ref<BitMatrix> DetectorResult::getBits() {
4577+ return bits_;
4578+}
4579+
4580+std::vector<Ref<ResultPoint> > DetectorResult::getPoints() {
4581+ return points_;
4582+}
4583+
4584+}
4585
4586=== added file '3rdParty/zxing/common/DetectorResult.h'
4587--- 3rdParty/zxing/common/DetectorResult.h 1970-01-01 00:00:00 +0000
4588+++ 3rdParty/zxing/common/DetectorResult.h 2014-05-10 17:38:08 +0000
4589@@ -0,0 +1,43 @@
4590+#ifndef __DETECTOR_RESULT_H__
4591+#define __DETECTOR_RESULT_H__
4592+
4593+/*
4594+ * DetectorResult.h
4595+ * zxing
4596+ *
4597+ * Copyright 2010 ZXing authors All rights reserved.
4598+ *
4599+ * Licensed under the Apache License, Version 2.0 (the "License");
4600+ * you may not use this file except in compliance with the License.
4601+ * You may obtain a copy of the License at
4602+ *
4603+ * http://www.apache.org/licenses/LICENSE-2.0
4604+ *
4605+ * Unless required by applicable law or agreed to in writing, software
4606+ * distributed under the License is distributed on an "AS IS" BASIS,
4607+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4608+ * See the License for the specific language governing permissions and
4609+ * limitations under the License.
4610+ */
4611+
4612+#include <vector>
4613+#include <zxing/common/Counted.h>
4614+#include <zxing/common/Array.h>
4615+#include <zxing/common/BitMatrix.h>
4616+#include <zxing/ResultPoint.h>
4617+
4618+namespace zxing {
4619+
4620+class DetectorResult : public Counted {
4621+private:
4622+ Ref<BitMatrix> bits_;
4623+ std::vector<Ref<ResultPoint> > points_;
4624+
4625+public:
4626+ DetectorResult(Ref<BitMatrix> bits, std::vector<Ref<ResultPoint> > points);
4627+ Ref<BitMatrix> getBits();
4628+ std::vector<Ref<ResultPoint> > getPoints();
4629+};
4630+}
4631+
4632+#endif // __DETECTOR_RESULT_H__
4633
4634=== added file '3rdParty/zxing/common/EdgeDetector.cpp'
4635--- 3rdParty/zxing/common/EdgeDetector.cpp 1970-01-01 00:00:00 +0000
4636+++ 3rdParty/zxing/common/EdgeDetector.cpp 2014-05-10 17:38:08 +0000
4637@@ -0,0 +1,191 @@
4638+/*
4639+ * EdgeDetector.cpp
4640+ * zxing
4641+ *
4642+ * Created by Ralf Kistner on 7/12/2009.
4643+ * Copyright 2008 ZXing authors All rights reserved.
4644+ *
4645+ * Licensed under the Apache License, Version 2.0 (the "License");
4646+ * you may not use this file except in compliance with the License.
4647+ * You may obtain a copy of the License at
4648+ *
4649+ * http://www.apache.org/licenses/LICENSE-2.0
4650+ *
4651+ * Unless required by applicable law or agreed to in writing, software
4652+ * distributed under the License is distributed on an "AS IS" BASIS,
4653+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4654+ * See the License for the specific language governing permissions and
4655+ * limitations under the License.
4656+ */
4657+
4658+#include <zxing/common/EdgeDetector.h>
4659+#include <algorithm>
4660+#include <cmath>
4661+
4662+using namespace std;
4663+
4664+namespace zxing {
4665+namespace EdgeDetector {
4666+
4667+void findEdgePoints(std::vector<Point>& points, const BitMatrix& image, Point start, Point end, bool invert, int skip, float deviation) {
4668+ float xdist = end.x - start.x;
4669+ float ydist = end.y - start.y;
4670+ float length = sqrt(xdist * xdist + ydist * ydist);
4671+
4672+
4673+ int var;
4674+
4675+ if (abs(xdist) > abs(ydist)) {
4676+ // Horizontal
4677+ if (xdist < 0)
4678+ skip = -skip;
4679+
4680+ var = int(abs(deviation * length / xdist));
4681+
4682+ float dy = ydist / xdist * skip;
4683+ bool left = (skip < 0) ^ invert;
4684+ int x = int(start.x);
4685+
4686+ int steps = int(xdist / skip);
4687+ for (int i = 0; i < steps; i++) {
4688+ x += skip;
4689+ if (x < 0 || x >= (int)image.getWidth())
4690+ continue; // In case we start off the edge
4691+ int my = int(start.y + dy * i);
4692+ int ey = min(my + var + 1, (int)image.getHeight() - 1);
4693+ int sy = max(my - var, 0);
4694+ for (int y = sy + 1; y < ey; y++) {
4695+ if (left) {
4696+ if (image.get(x, y) && !image.get(x, y + 1)) {
4697+ points.push_back(Point(x, y + 0.5f));
4698+ }
4699+ } else {
4700+ if (!image.get(x, y) && image.get(x, y + 1)) {
4701+ points.push_back(Point(x, y + 0.5f));
4702+ }
4703+ }
4704+ }
4705+ }
4706+ } else {
4707+ // Vertical
4708+ if (ydist < 0)
4709+ skip = -skip;
4710+
4711+ var = int(abs(deviation * length / ydist));
4712+
4713+ float dx = xdist / ydist * skip;
4714+ bool down = (skip > 0) ^ invert;
4715+ int y = int(start.y);
4716+
4717+ int steps = int(ydist / skip);
4718+ for (int i = 0; i < steps; i++) {
4719+ y += skip;
4720+ if (y < 0 || y >= (int)image.getHeight())
4721+ continue; // In case we start off the edge
4722+ int mx = int(start.x + dx * i);
4723+ int ex = min(mx + var + 1, (int)image.getWidth() - 1);
4724+ int sx = max(mx - var, 0);
4725+ for (int x = sx + 1; x < ex; x++) {
4726+ if (down) {
4727+ if (image.get(x, y) && !image.get(x + 1, y)) {
4728+ points.push_back(Point(x + 0.5f, y));
4729+ }
4730+
4731+ } else {
4732+ if (!image.get(x, y) && image.get(x + 1, y)) {
4733+ points.push_back(Point(x + 0.5f, y));
4734+ }
4735+ }
4736+
4737+ }
4738+ }
4739+
4740+ }
4741+}
4742+
4743+Line findLine(const BitMatrix& image, Line estimate, bool invert, int deviation, float threshold, int skip) {
4744+ float t = threshold * threshold;
4745+
4746+ Point start = estimate.start;
4747+ Point end = estimate.end;
4748+
4749+ vector<Point> edges;
4750+ edges.clear();
4751+ findEdgePoints(edges, image, start, end, invert, skip, deviation);
4752+
4753+ int n = edges.size();
4754+
4755+ float xdist = end.x - start.x;
4756+ float ydist = end.y - start.y;
4757+
4758+ bool horizontal = abs(xdist) > abs(ydist);
4759+
4760+ float max = 0;
4761+ Line bestLine(start, end); // prepopulate with the given line, in case we can't find any line for some reason
4762+
4763+ for (int i = -deviation; i < deviation; i++) {
4764+ float x1, y1;
4765+ if (horizontal) {
4766+ y1 = start.y + i;
4767+ x1 = start.x - i * ydist / xdist;
4768+ } else {
4769+ y1 = start.y - i * xdist / ydist;
4770+ x1 = start.x + i;
4771+ }
4772+
4773+ for (int j = -deviation; j < deviation; j++) {
4774+ float x2, y2;
4775+ if (horizontal) {
4776+ y2 = end.y + j;
4777+ x2 = end.x - j * ydist / xdist;
4778+ } else {
4779+ y2 = end.y - j * xdist / ydist;
4780+ x2 = end.x + j;
4781+ }
4782+
4783+ float dx = x1 - x2;
4784+ float dy = y1 - y2;
4785+ float length = sqrt(dx * dx + dy * dy);
4786+
4787+ float score = 0;
4788+
4789+ for(int k = 0; k < n; k++) {
4790+ const Point& edge = edges[k];
4791+ float dist = ((x1 - edge.x) * dy - (y1 - edge.y) * dx) / length;
4792+ // Similar to least squares method
4793+ float s = t - dist * dist;
4794+ if (s > 0)
4795+ score += s;
4796+ }
4797+
4798+ if (score > max) {
4799+ max = score;
4800+ bestLine.start = Point(x1, y1);
4801+ bestLine.end = Point(x2, y2);
4802+ }
4803+ }
4804+ }
4805+
4806+ return bestLine;
4807+}
4808+
4809+Point intersection(Line a, Line b) {
4810+ float dxa = a.start.x - a.end.x;
4811+ float dxb = b.start.x - b.end.x;
4812+ float dya = a.start.y - a.end.y;
4813+ float dyb = b.start.y - b.end.y;
4814+
4815+ float p = a.start.x * a.end.y - a.start.y * a.end.x;
4816+ float q = b.start.x * b.end.y - b.start.y * b.end.x;
4817+ float denom = dxa * dyb - dya * dxb;
4818+ if(denom == 0) // Lines don't intersect
4819+ return Point(INFINITY, INFINITY);
4820+
4821+ float x = (p * dxb - dxa * q) / denom;
4822+ float y = (p * dyb - dya * q) / denom;
4823+
4824+ return Point(x, y);
4825+}
4826+
4827+} // namespace EdgeDetector
4828+} // namespace zxing
4829
4830=== added file '3rdParty/zxing/common/EdgeDetector.h'
4831--- 3rdParty/zxing/common/EdgeDetector.h 1970-01-01 00:00:00 +0000
4832+++ 3rdParty/zxing/common/EdgeDetector.h 2014-05-10 17:38:08 +0000
4833@@ -0,0 +1,38 @@
4834+#ifndef __EDGEDETECTOR_H__
4835+#define __EDGEDETECTOR_H__
4836+/*
4837+ * EdgeDetector.h
4838+ * zxing
4839+ *
4840+ * Copyright 2010 ZXing authors All rights reserved.
4841+ *
4842+ * Licensed under the Apache License, Version 2.0 (the "License");
4843+ * you may not use this file except in compliance with the License.
4844+ * You may obtain a copy of the License at
4845+ *
4846+ * http://www.apache.org/licenses/LICENSE-2.0
4847+ *
4848+ * Unless required by applicable law or agreed to in writing, software
4849+ * distributed under the License is distributed on an "AS IS" BASIS,
4850+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4851+ * See the License for the specific language governing permissions and
4852+ * limitations under the License.
4853+ */
4854+
4855+
4856+
4857+#include <vector>
4858+#include <zxing/common/BitMatrix.h>
4859+#include <zxing/common/Point.h>
4860+
4861+namespace zxing {
4862+namespace EdgeDetector {
4863+
4864+void findEdgePoints(std::vector<Point>& points, const BitMatrix& image, Point start, Point end, bool invert, int skip, float deviation);
4865+Line findLine(const BitMatrix& image, Line estimate, bool invert, int deviation, float threshold, int skip);
4866+
4867+Point intersection(Line a, Line b);
4868+
4869+}
4870+}
4871+#endif /* EDGEDETECTOR_H_ */
4872
4873=== added file '3rdParty/zxing/common/GlobalHistogramBinarizer.cpp'
4874--- 3rdParty/zxing/common/GlobalHistogramBinarizer.cpp 1970-01-01 00:00:00 +0000
4875+++ 3rdParty/zxing/common/GlobalHistogramBinarizer.cpp 2014-05-10 17:38:08 +0000
4876@@ -0,0 +1,209 @@
4877+// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
4878+/*
4879+ * GlobalHistogramBinarizer.cpp
4880+ * zxing
4881+ *
4882+ * Copyright 2010 ZXing authors. All rights reserved.
4883+ *
4884+ * Licensed under the Apache License, Version 2.0 (the "License");
4885+ * you may not use this file except in compliance with the License.
4886+ * You may obtain a copy of the License at
4887+ *
4888+ * http://www.apache.org/licenses/LICENSE-2.0
4889+ *
4890+ * Unless required by applicable law or agreed to in writing, software
4891+ * distributed under the License is distributed on an "AS IS" BASIS,
4892+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4893+ * See the License for the specific language governing permissions and
4894+ * limitations under the License.
4895+ */
4896+
4897+#include <zxing/common/GlobalHistogramBinarizer.h>
4898+#include <zxing/common/IllegalArgumentException.h>
4899+#include <zxing/common/Array.h>
4900+
4901+namespace zxing {
4902+using namespace std;
4903+
4904+const int LUMINANCE_BITS = 5;
4905+const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
4906+const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
4907+
4908+GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref<LuminanceSource> source) :
4909+ Binarizer(source), cached_matrix_(NULL), cached_row_(NULL), cached_row_num_(-1) {
4910+
4911+}
4912+
4913+GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {
4914+}
4915+
4916+
4917+Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
4918+ if (y == cached_row_num_) {
4919+ if (cached_row_ != NULL) {
4920+ return cached_row_;
4921+ } else {
4922+ throw IllegalArgumentException("Too little dynamic range in luminance");
4923+ }
4924+ }
4925+
4926+ vector<int> histogram(LUMINANCE_BUCKETS, 0);
4927+ LuminanceSource& source = *getLuminanceSource();
4928+ int width = source.getWidth();
4929+ if (row == NULL || static_cast<int>(row->getSize()) < width) {
4930+ row = new BitArray(width);
4931+ } else {
4932+ row->clear();
4933+ }
4934+
4935+ //TODO(flyashi): cache this instead of allocating and deleting per row
4936+ unsigned char* row_pixels = NULL;
4937+ try {
4938+ row_pixels = new unsigned char[width];
4939+ row_pixels = source.getRow(y, row_pixels);
4940+ for (int x = 0; x < width; x++) {
4941+ histogram[row_pixels[x] >> LUMINANCE_SHIFT]++;
4942+ }
4943+ int blackPoint = estimate(histogram);
4944+
4945+ BitArray& array = *row;
4946+ int left = row_pixels[0];
4947+ int center = row_pixels[1];
4948+ for (int x = 1; x < width - 1; x++) {
4949+ int right = row_pixels[x + 1];
4950+ // A simple -1 4 -1 box filter with a weight of 2.
4951+ int luminance = ((center << 2) - left - right) >> 1;
4952+ if (luminance < blackPoint) {
4953+ array.set(x);
4954+ }
4955+ left = center;
4956+ center = right;
4957+ }
4958+
4959+ cached_row_ = row;
4960+ cached_row_num_ = y;
4961+ delete [] row_pixels;
4962+ return row;
4963+ } catch (IllegalArgumentException const& iae) {
4964+ // Cache the fact that this row failed.
4965+ cached_row_ = NULL;
4966+ cached_row_num_ = y;
4967+ delete [] row_pixels;
4968+ throw iae;
4969+ }
4970+}
4971+
4972+Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
4973+ if (cached_matrix_ != NULL) {
4974+ return cached_matrix_;
4975+ }
4976+
4977+ // Faster than working with the reference
4978+ LuminanceSource& source = *getLuminanceSource();
4979+ int width = source.getWidth();
4980+ int height = source.getHeight();
4981+ vector<int> histogram(LUMINANCE_BUCKETS, 0);
4982+
4983+ // Quickly calculates the histogram by sampling four rows from the image.
4984+ // This proved to be more robust on the blackbox tests than sampling a
4985+ // diagonal as we used to do.
4986+ ArrayRef<unsigned char> ref (width);
4987+ unsigned char* row = &ref[0];
4988+ for (int y = 1; y < 5; y++) {
4989+ int rownum = height * y / 5;
4990+ int right = (width << 2) / 5;
4991+ row = source.getRow(rownum, row);
4992+ for (int x = width / 5; x < right; x++) {
4993+ histogram[row[x] >> LUMINANCE_SHIFT]++;
4994+ }
4995+ }
4996+
4997+ int blackPoint = estimate(histogram);
4998+
4999+ Ref<BitMatrix> matrix_ref(new BitMatrix(width, height));
5000+ BitMatrix& matrix = *matrix_ref;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches