#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // file: zxing/Exception.h #ifndef __EXCEPTION_H__ // #define __EXCEPTION_H__ /* * Exception.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { class Exception : public std::exception { private: std::string message; public: Exception(); Exception(const char *msg); virtual const char* what() const throw(); virtual ~Exception() throw(); }; } #endif // __EXCEPTION_H__ // file: zxing/common/IllegalArgumentException.h #ifndef __ILLEGAL_ARGUMENT_EXCEPTION_H__ // #define __ILLEGAL_ARGUMENT_EXCEPTION_H__ /* * IllegalArgumentException.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class IllegalArgumentException : public zxing::Exception { public: IllegalArgumentException(const char *msg); ~IllegalArgumentException() throw(); }; } #endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__ // file: zxing/common/Counted.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __COUNTED_H__ // #define __COUNTED_H__ /* * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //#define DEBUG_COUNTING // #include #ifdef DEBUG_COUNTING // #include #endif namespace zxing { /* base class for reference-counted objects */ class Counted { private: unsigned int count_; public: Counted() : count_(0) { #ifdef DEBUG_COUNTING cout << "instantiating " << typeid(*this).name() << " " << this << " @ " << count_ << "\n"; #endif } virtual ~Counted() { } Counted *retain() { #ifdef DEBUG_COUNTING cout << "retaining " << typeid(*this).name() << " " << this << " @ " << count_; #endif count_++; #ifdef DEBUG_COUNTING cout << "->" << count_ << "\n"; #endif return this; } void release() { #ifdef DEBUG_COUNTING cout << "releasing " << typeid(*this).name() << " " << this << " @ " << count_; #endif if (count_ == 0 || count_ == 54321) { #ifdef DEBUG_COUNTING cout << "\nOverreleasing already-deleted object " << this << "!!!\n"; #endif throw 4711; } count_--; #ifdef DEBUG_COUNTING cout << "->" << count_ << "\n"; #endif if (count_ == 0) { #ifdef DEBUG_COUNTING cout << "deleting " << typeid(*this).name() << " " << this << "\n"; #endif count_ = 0xDEADF001; delete this; } } /* return the current count for denugging purposes or similar */ int count() const { return count_; } }; /* counting reference to reference-counted objects */ template class Ref { private: public: T *object_; explicit Ref(T *o = 0) : object_(0) { #ifdef DEBUG_COUNTING cout << "instantiating Ref " << this << " from pointer" << o << "\n"; #endif reset(o); } explicit Ref(const T &o) : object_(0) { #ifdef DEBUG_COUNTING cout << "instantiating Ref " << this << " from reference\n"; #endif reset(const_cast(&o)); } Ref(const Ref &other) : object_(0) { #ifdef DEBUG_COUNTING cout << "instantiating Ref " << this << " from Ref " << &other << "\n"; #endif reset(other.object_); } template Ref(const Ref &other) : object_(0) { #ifdef DEBUG_COUNTING cout << "instantiating Ref " << this << " from reference\n"; #endif reset(other.object_); } ~Ref() { #ifdef DEBUG_COUNTING cout << "destroying Ref " << this << " with " << (object_ ? typeid(*object_).name() : "NULL") << " " << object_ << "\n"; #endif if (object_) { object_->release(); } } void reset(T *o) { #ifdef DEBUG_COUNTING cout << "resetting Ref " << this << " from " << (object_ ? typeid(*object_).name() : "NULL") << " " << object_ << " to " << (o ? typeid(*o).name() : "NULL") << " " << o << "\n"; #endif if (o) { o->retain(); } if (object_ != 0) { object_->release(); } object_ = o; } Ref& operator=(const Ref &other) { reset(other.object_); return *this; } template Ref& operator=(const Ref &other) { reset(other.object_); return *this; } Ref& operator=(T* o) { reset(o); return *this; } template Ref& operator=(Y* o) { reset(o); return *this; } T& operator*() { return *object_; } T* operator->() const { return object_; } operator T*() const { return object_; } bool operator==(const T* that) { return object_ == that; } bool operator==(const Ref &other) const { return object_ == other.object_ || *object_ == *(other.object_); } template bool operator==(const Ref &other) const { return object_ == other.object_ || *object_ == *(other.object_); } bool operator!=(const T* that) { return !(*this == that); } bool empty() const { return object_ == 0; } template friend std::ostream& operator<<(std::ostream &out, Ref& ref); }; } #endif // __COUNTED_H__ // file: zxing/common/BitArray.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __BIT_ARRAY_H__ // #define __BIT_ARRAY_H__ /* * Copyright 2010 ZXing authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { #define ZX_LOG_DIGITS(digits) \ ((digits == 8) ? 3 : \ ((digits == 16) ? 4 : \ ((digits == 32) ? 5 : \ ((digits == 64) ? 6 : \ ((digits == 128) ? 7 : \ (-1)))))) class BitArray : public Counted { private: size_t size_; std::vector bits_; static const unsigned int bitsPerWord_ = std::numeric_limits::digits; static const unsigned int logBits_ = ZX_LOG_DIGITS(bitsPerWord_); static const unsigned int bitsMask_ = (1 << logBits_) - 1; static size_t wordsForBits(size_t bits); explicit BitArray(); public: BitArray(size_t size); ~BitArray(); size_t getSize(); bool get(size_t i) { return (bits_[i >> logBits_] & (1 << (i & bitsMask_))) != 0; } void set(size_t i) { bits_[i >> logBits_] |= 1 << (i & bitsMask_); } void setBulk(size_t i, unsigned int newBits); void setRange(int start, int end); void clear(); bool isRange(size_t start, size_t end, bool value); std::vector& getBitArray(); void reverse(); }; } #endif // __BIT_ARRAY_H__ // file: zxing/common/BitMatrix.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __BIT_MATRIX_H__ // #define __BIT_MATRIX_H__ /* * BitMatrix.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { class BitMatrix : public Counted { private: size_t width_; size_t height_; size_t words_; unsigned int* bits_; #define ZX_LOG_DIGITS(digits) \ ((digits == 8) ? 3 : \ ((digits == 16) ? 4 : \ ((digits == 32) ? 5 : \ ((digits == 64) ? 6 : \ ((digits == 128) ? 7 : \ (-1)))))) static const unsigned int bitsPerWord = std::numeric_limits::digits; static const unsigned int logBits = ZX_LOG_DIGITS(bitsPerWord); static const unsigned int bitsMask = (1 << logBits) - 1; public: BitMatrix(size_t dimension); BitMatrix(size_t width, size_t height); ~BitMatrix(); bool get(size_t x, size_t y) const { size_t offset = x + width_ * y; return ((bits_[offset >> logBits] >> (offset & bitsMask)) & 0x01) != 0; } void set(size_t x, size_t y) { size_t offset = x + width_ * y; bits_[offset >> logBits] |= 1 << (offset & bitsMask); } void flip(size_t x, size_t y); void clear(); void setRegion(size_t left, size_t top, size_t width, size_t height); Ref getRow(int y, Ref row); size_t getDimension() const; size_t getWidth() const; size_t getHeight() const; unsigned int* getBits() const; friend std::ostream& operator<<(std::ostream &out, const BitMatrix &bm); const char *description(); private: BitMatrix(const BitMatrix&); BitMatrix& operator =(const BitMatrix&); }; } #endif // __BIT_MATRIX_H__ // file: zxing/common/Array.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __ARRAY_H__ // #define __ARRAY_H__ /* * Array.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include #ifdef DEBUG_COUNTING // #include // #include #endif // #include namespace zxing { template class Array : public Counted { protected: public: std::vector values_; Array(size_t n) : Counted(), values_(n, T()) { } Array(T *ts, size_t n) : Counted(), values_(ts, ts+n) { } Array(T v, size_t n) : Counted(), values_(n, v) { } Array(std::vector &v) : Counted(), values_(v) { } Array(Array &other) : Counted(), values_(other.values_) { } Array(Array *other) : Counted(), values_(other->values_) { } virtual ~Array() { } Array& operator=(const Array &other) { #ifdef DEBUG_COUNTING cout << "assigning values from Array " << &other << " to this Array " << this << ", "; #endif values_ = other.values_; #ifdef DEBUG_COUNTING cout << "new size = " << values_.size() << "\n"; #endif return *this; } Array& operator=(const std::vector &array) { #ifdef DEBUG_COUNTING cout << "assigning values from Array " << &array << " to this Array " << this << ", "; #endif values_ = array; #ifdef DEBUG_COUNTING cout << "new size = " << values_.size() << "\n"; #endif return *this; } T operator[](size_t i) const { return values_[i]; } T& operator[](size_t i) { return values_[i]; } size_t size() const { return values_.size(); } std::vector values() const { return values_; } std::vector& values() { return values_; } }; template class ArrayRef : public Counted { private: public: Array *array_; ArrayRef() : array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating empty ArrayRef " << this << "\n"; #endif } ArrayRef(size_t n) : array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating ArrayRef " << this << "with size " << n << "\n"; #endif reset(new Array (n)); } ArrayRef(T *ts, size_t n) : array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating ArrayRef " << this << "with " << n << " elements at " << (void *)ts << "\n"; #endif reset(new Array (ts, n)); } ArrayRef(Array *a) : array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating ArrayRef " << this << " from pointer:\n"; #endif reset(a); } ArrayRef(const Array &a) : array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating ArrayRef " << this << " from reference to Array " << (void *)&a << ":\n"; #endif reset(const_cast *>(&a)); } ArrayRef(const ArrayRef &other) : Counted(), array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating ArrayRef " << this << " from ArrayRef " << &other << ":\n"; #endif reset(other.array_); } template ArrayRef(const ArrayRef &other) : array_(0) { #ifdef DEBUG_COUNTING cout << "instantiating ArrayRef " << this << " from ArrayRef " << &other << ":\n"; #endif reset(static_cast *>(other.array_)); } ~ArrayRef() { #ifdef DEBUG_COUNTING cout << "destroying ArrayRef " << this << " with " << (array_ ? typeid(*array_).name() : "NULL") << " " << array_ << "\n"; #endif if (array_) { array_->release(); } array_ = 0; } T operator[](size_t i) const { return (*array_)[i]; } T& operator[](size_t i) { return (*array_)[i]; } size_t size() const { return array_->size(); } void reset(Array *a) { #ifdef DEBUG_COUNTING cout << "resetting ArrayRef " << this << " from " << (array_ ? typeid(*array_).name() : "NULL") << " " << array_ << " to " << (a ? typeid(*a).name() : "NULL") << " " << a << "\n"; #endif if (a) { a->retain(); } if (array_) { array_->release(); } array_ = a; } void reset(const ArrayRef &other) { reset(other.array_); } ArrayRef& operator=(const ArrayRef &other) { reset(other); return *this; } ArrayRef& operator=(Array *a) { reset(a); return *this; } Array& operator*() { return *array_; } Array* operator->() { return array_; } }; } // namespace zxing #endif // __ARRAY_H__ // file: zxing/common/Str.h #ifndef __STR_H__ // #define __STR_H__ /* * Str.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { class String : public Counted { private: std::string text_; public: String(const std::string &text); const std::string &getText() const; friend std::ostream &operator<<(std::ostream &out, const String &s); }; } #endif // __COMMON__STRING_H__ // file: zxing/common/BitSource.h #ifndef __BIT_SOURCE_H__ // #define __BIT_SOURCE_H__ /* * BitSource.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { /** *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the * number of bits read is not often a multiple of 8.

* *

This class is not thread-safe.

* * @author srowen@google.com (Sean Owen) * @author christian.brunschen@gmail.com (Christian Brunschen) */ class BitSource : public Counted { typedef unsigned char byte; private: ArrayRef bytes_; int byteOffset_; int bitOffset_; public: /** * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. * Bits are read within a byte from most-significant to least-significant bit. */ BitSource(ArrayRef &bytes) : bytes_(bytes), byteOffset_(0), bitOffset_(0) { } int getByteOffset() { return byteOffset_; } /** * @param numBits number of bits to read * @return int representing the bits read. The bits will appear as the least-significant * bits of the int * @throws IllegalArgumentException if numBits isn't in [1,32] */ int readBits(int numBits); /** * @return number of bits that can be read successfully */ int available(); }; } #endif // __BIT_SOURCE_H__ // file: zxing/common/DecoderResult.h #ifndef __DECODER_RESULT_H__ // #define __DECODER_RESULT_H__ /* * DecoderResult.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { class DecoderResult : public Counted { private: ArrayRef rawBytes_; Ref text_; ArrayRef< ArrayRef > byteSegments_; std::string ecLevel_; public: DecoderResult(ArrayRef rawBytes, Ref text, ArrayRef< ArrayRef >& byteSegments, std::string const& ecLevel); DecoderResult(ArrayRef rawBytes, Ref text); ArrayRef getRawBytes(); Ref getText(); }; } #endif // __DECODER_RESULT_H__ // file: zxing/common/PerspectiveTransform.h #ifndef __PERSPECTIVE_TANSFORM_H__ // #define __PERSPECTIVE_TANSFORM_H__ /* * PerspectiveTransform.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { class PerspectiveTransform : public Counted { private: float a11, a12, a13, a21, a22, a23, a31, a32, a33; PerspectiveTransform(float a11, float a21, float a31, float a12, float a22, float a32, float a13, float a23, float a33); public: static Ref quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float x0p, float y0p, float x1p, float y1p, float x2p, float y2p, float x3p, float y3p); static Ref squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); static Ref quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); Ref buildAdjoint(); Ref times(Ref other); void transformPoints(std::vector &points); friend std::ostream& operator<<(std::ostream& out, const PerspectiveTransform &pt); }; } #endif // __PERSPECTIVE_TANSFORM_H__ // file: zxing/ResultPoint.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __RESULT_POINT_H__ // #define __RESULT_POINT_H__ /* * ResultPoint.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { class ResultPoint : public Counted { protected: float posX_; float posY_; public: ResultPoint(); ResultPoint(float x, float y); virtual ~ResultPoint(); virtual float getX() const; virtual float getY() const; bool equals(Ref other); static void orderBestPatterns(std::vector > &patterns); static float distance(Ref point1, Ref point2); static float distance(float x1, float x2, float y1, float y2); private: static float crossProductZ(Ref pointA, Ref pointB, Ref pointC); }; } #endif // __RESULT_POINT_H__ // file: zxing/common/DetectorResult.h #ifndef __DETECTOR_RESULT_H__ // #define __DETECTOR_RESULT_H__ /* * DetectorResult.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { class DetectorResult : public Counted { private: Ref bits_; std::vector > points_; Ref transform_; public: DetectorResult(Ref bits, std::vector > points, Ref transform); Ref getBits(); std::vector > getPoints(); Ref getTransform(); }; } #endif // __DETECTOR_RESULT_H__ // file: zxing/common/Point.h #ifndef __POINT_H__ // #define __POINT_H__ /* * Point.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace zxing { class PointI { public: int x; int y; }; class Point { public: Point() : x(0.0f), y(0.0f) {}; Point(float x_, float y_) : x(x_), y(y_) {}; float x; float y; }; class Line { public: Line(Point start_, Point end_) : start(start_), end(end_) {}; Point start; Point end; }; } #endif // POINT_H_ // file: zxing/common/EdgeDetector.h #ifndef __EDGEDETECTOR_H__ // #define __EDGEDETECTOR_H__ /* * EdgeDetector.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace EdgeDetector { void findEdgePoints(std::vector& points, const BitMatrix& image, Point start, Point end, bool invert, int skip, float deviation); Line findLine(const BitMatrix& image, Line estimate, bool invert, int deviation, float threshold, int skip); Point intersection(Line a, Line b); } } #endif /* EDGEDETECTOR_H_ */ // file: zxing/LuminanceSource.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __LUMINANCESOURCE_H__ // #define __LUMINANCESOURCE_H__ /* * LuminanceSource.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { class LuminanceSource : public Counted { public: LuminanceSource(); virtual ~LuminanceSource(); virtual int getWidth() const = 0; virtual int getHeight() const = 0; // Callers take ownership of the returned memory and must call delete [] on it themselves. virtual unsigned char* getRow(int y, unsigned char* row) = 0; virtual unsigned char* getMatrix() = 0; virtual bool isCropSupported() const; virtual Ref crop(int left, int top, int width, int height); virtual bool isRotateSupported() const; virtual Ref rotateCounterClockwise(); operator std::string (); // should be const but don't want to make sure a // large breaking change right now }; } #endif /* LUMINANCESOURCE_H_ */ // file: zxing/Binarizer.h #ifndef BINARIZER_H_ #define BINARIZER_H_ /* * Binarizer.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { class Binarizer : public Counted { private: Ref source_; public: Binarizer(Ref source); virtual ~Binarizer(); virtual Ref getBlackRow(int y, Ref row) = 0; virtual Ref getBlackMatrix() = 0; Ref getLuminanceSource() const ; virtual Ref createBinarizer(Ref source) = 0; }; } #endif /* BINARIZER_H_ */ // file: zxing/common/GlobalHistogramBinarizer.h #ifndef __GLOBALHISTOGRAMBINARIZER_H__ // #define __GLOBALHISTOGRAMBINARIZER_H__ /* * GlobalHistogramBinarizer.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { class GlobalHistogramBinarizer : public Binarizer { private: Ref cached_matrix_; Ref cached_row_; int cached_row_num_; public: GlobalHistogramBinarizer(Ref source); virtual ~GlobalHistogramBinarizer(); virtual Ref getBlackRow(int y, Ref row); virtual Ref getBlackMatrix(); static int estimate(std::vector &histogram); Ref createBinarizer(Ref source); }; } #endif /* GLOBALHISTOGRAMBINARIZER_H_ */ // file: zxing/common/GreyscaleLuminanceSource.h #ifndef __GREYSCALE_LUMINANCE_SOURCE__ #define __GREYSCALE_LUMINANCE_SOURCE__ /* * GreyscaleLuminanceSource.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class GreyscaleLuminanceSource : public LuminanceSource { private: unsigned char* greyData_; int dataWidth_; int dataHeight_; int left_; int top_; int width_; int height_; public: GreyscaleLuminanceSource(unsigned char* greyData, int dataWidth, int dataHeight, int left, int top, int width, int height); unsigned char* getRow(int y, unsigned char* row); unsigned char* getMatrix(); bool isRotateSupported() const { return true; } int getWidth() const { return width_; } int getHeight() const { return height_; } Ref rotateCounterClockwise(); }; } /* namespace */ #endif // file: zxing/common/GreyscaleRotatedLuminanceSource.h #ifndef __GREYSCALE_ROTATED_LUMINANCE_SOURCE__ #define __GREYSCALE_ROTATED_LUMINANCE_SOURCE__ /* * GreyscaleRotatedLuminanceSource.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class GreyscaleRotatedLuminanceSource : public LuminanceSource { private: unsigned char* greyData_; int dataWidth_; int dataHeight_; int left_; int top_; int width_; int height_; public: GreyscaleRotatedLuminanceSource(unsigned char* greyData, int dataWidth, int dataHeight, int left, int top, int width, int height); unsigned char* getRow(int y, unsigned char* row); unsigned char* getMatrix(); bool isRotateSupported() const { return false; } int getWidth() const { return width_; } int getHeight() const { return height_; } }; } /* namespace */ #endif // file: zxing/common/GridSampler.h #ifndef __GRID_SAMPLER_H__ // #define __GRID_SAMPLER_H__ /* * GridSampler.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { class GridSampler { private: static GridSampler gridSampler; GridSampler(); public: Ref sampleGrid(Ref image, int dimension, Ref transform); Ref sampleGrid(Ref image, int dimensionX, int dimensionY, Ref transform); Ref sampleGrid(Ref image, int dimension, float p1ToX, float p1ToY, float p2ToX, float p2ToY, float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX, float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY); static void checkAndNudgePoints(Ref image, std::vector &points); static GridSampler &getInstance(); }; } #endif // __GRID_SAMPLER_H__ // file: zxing/common/HybridBinarizer.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __HYBRIDBINARIZER_H__ // #define __HYBRIDBINARIZER_H__ /* * HybridBinarizer.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include namespace zxing { class HybridBinarizer : public GlobalHistogramBinarizer { private: Ref matrix_; Ref cached_row_; int cached_row_num_; public: HybridBinarizer(Ref source); virtual ~HybridBinarizer(); virtual Ref getBlackMatrix(); Ref createBinarizer(Ref source); private: // We'll be using one-D arrays because C++ can't dynamically allocate 2D // arrays int* calculateBlackPoints(unsigned char* luminances, int subWidth, int subHeight, int width, int height); void calculateThresholdForBlock(unsigned char* luminances, int subWidth, int subHeight, int width, int height, int blackPoints[], Ref const& matrix); void threshold8x8Block(unsigned char* luminances, int xoffset, int yoffset, int threshold, int stride, Ref const& matrix); }; } #endif // file: zxing/common/reedsolomon/GF256.h #ifndef __GF256_H__ // #define __GF256_H__ /* * GF256.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { class GF256Poly; class GF256 { /** *

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

* *

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

* * @author srowen@google.com (Sean Owen) * @author christian.brunschen@gmail.com (Christian Brunschen) */ private: std::vector exp_; std::vector log_; Ref zero_; Ref one_; GF256(int primitive); public: Ref getZero(); Ref getOne(); Ref buildMonomial(int degree, int coefficient); static int addOrSubtract(int a, int b); int exp(int a); int log(int a); int inverse(int a); int multiply(int a, int b); static GF256 QR_CODE_FIELD; static GF256 DATA_MATRIX_FIELD; friend std::ostream& operator<<(std::ostream& out, const GF256& field); }; } #endif // __GF256_H__ // file: zxing/common/reedsolomon/GF256Poly.h #ifndef __GF256_POLY_H__ // #define __GF256_POLY_H__ /* * GF256Poly.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { class GF256; class GF256Poly : public Counted { private: GF256 &field; ArrayRef coefficients; void fixCoefficients(); public: GF256Poly(GF256 &field, ArrayRef c); ~GF256Poly(); int getDegree(); bool isZero(); int getCoefficient(int degree); int evaluateAt(int a); Ref addOrSubtract(Ref other); Ref multiply(Ref other); Ref multiply(int scalar); Ref multiplyByMonomial(int degree, int coefficient); const char *description() const; friend std::ostream& operator<<(std::ostream& out, const GF256Poly& poly); }; } #endif // __GF256_POLY_H__ // file: zxing/common/reedsolomon/ReedSolomonDecoder.h #ifndef __REED_SOLOMON_DECODER_H__ // #define __REED_SOLOMON_DECODER_H__ /* * ReedSolomonDecoder.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { class GF256; class GF256Poly; class ReedSolomonDecoder { private: GF256 &field; public: ReedSolomonDecoder(GF256 &fld); ~ReedSolomonDecoder(); void decode(ArrayRef received, int twoS); private: std::vector > runEuclideanAlgorithm(Ref a, Ref b, int R); ArrayRef findErrorLocations(Ref errorLocator); ArrayRef findErrorMagnitudes(Ref errorEvaluator, ArrayRef errorLocations, bool dataMatrix); }; } #endif // __REED_SOLOMON_DECODER_H__ // file: zxing/common/reedsolomon/ReedSolomonException.h #ifndef __REED_SOLOMON_EXCEPTION_H__ // #define __REED_SOLOMON_EXCEPTION_H__ /* * ReedSolomonException.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class ReedSolomonException : public Exception { public: ReedSolomonException(const char *msg) throw(); ~ReedSolomonException() throw(); }; } #endif // __REED_SOLOMON_EXCEPTION_H__ // file: zxing/BarcodeFormat.h #ifndef __BARCODE_FORMAT_H__ // #define __BARCODE_FORMAT_H__ /* * BarcodeFormat.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace zxing { typedef enum BarcodeFormat { BarcodeFormat_None = 0, BarcodeFormat_QR_CODE, BarcodeFormat_DATA_MATRIX, BarcodeFormat_UPC_E, BarcodeFormat_UPC_A, BarcodeFormat_EAN_8, BarcodeFormat_EAN_13, BarcodeFormat_CODE_128, BarcodeFormat_CODE_39, BarcodeFormat_ITF } BarcodeFormat; /* if you update the enum, please update the name in BarcodeFormat.cpp */ extern const char *barcodeFormatNames[]; } #endif // __BARCODE_FORMAT_H__ // file: zxing/BinaryBitmap.h #ifndef __BINARYBITMAP_H__ // #define __BINARYBITMAP_H__ /* * BinaryBitmap.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { class BinaryBitmap : public Counted { private: Ref binarizer_; int cached_y_; public: BinaryBitmap(Ref binarizer); virtual ~BinaryBitmap(); Ref getBlackRow(int y, Ref row); Ref getBlackMatrix(); Ref getLuminanceSource() const; int getWidth() const; int getHeight() const; bool isRotateSupported() const; Ref rotateCounterClockwise(); bool isCropSupported() const; Ref crop(int left, int top, int width, int height); }; } #endif /* BINARYBITMAP_H_ */ // file: zxing/ResultPointCallback.h #ifndef __RESULT_POINT_CALLBACK_H__ // #define __RESULT_POINT_CALLBACK_H__ /* * ResultPointCallback.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class ResultPoint; class ResultPointCallback : public Counted { protected: ResultPointCallback() {} public: virtual void foundPossibleResultPoint(ResultPoint const& point) = 0; virtual ~ResultPointCallback(); }; } #endif // __RESULT_POINT_CALLBACK_H__ // file: zxing/DecodeHints.h #ifndef __DECODEHINTS_H_ #define __DECODEHINTS_H_ /* * DecodeHintType.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { typedef unsigned int DecodeHintType; class DecodeHints { private: DecodeHintType hints; Ref callback; public: static const DecodeHintType BARCODEFORMAT_QR_CODE_HINT = 1 << BarcodeFormat_QR_CODE; static const DecodeHintType BARCODEFORMAT_DATA_MATRIX_HINT = 1 << BarcodeFormat_DATA_MATRIX; static const DecodeHintType BARCODEFORMAT_UPC_E_HINT = 1 << BarcodeFormat_UPC_E; static const DecodeHintType BARCODEFORMAT_UPC_A_HINT = 1 << BarcodeFormat_UPC_A; static const DecodeHintType BARCODEFORMAT_EAN_8_HINT = 1 << BarcodeFormat_EAN_8; static const DecodeHintType BARCODEFORMAT_EAN_13_HINT = 1 << BarcodeFormat_EAN_13; static const DecodeHintType BARCODEFORMAT_CODE_128_HINT = 1 << BarcodeFormat_CODE_128; static const DecodeHintType BARCODEFORMAT_CODE_39_HINT = 1 << BarcodeFormat_CODE_39; static const DecodeHintType BARCODEFORMAT_ITF_HINT = 1 << BarcodeFormat_ITF; static const DecodeHintType CHARACTER_SET = 1 << 30; static const DecodeHintType TRYHARDER_HINT = 1 << 31; static const DecodeHints PRODUCT_HINT; static const DecodeHints ONED_HINT; static const DecodeHints DEFAULT_HINT; DecodeHints(); DecodeHints(DecodeHintType init); void addFormat(BarcodeFormat toadd); bool containsFormat(BarcodeFormat tocheck) const; void setTryHarder(bool toset); bool getTryHarder() const; void setResultPointCallback(Ref const&); Ref getResultPointCallback() const; }; } #endif // file: zxing/Result.h #ifndef __RESULT_H__ // #define __RESULT_H__ /* * Result.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include // #include namespace zxing { class Result : public Counted { private: Ref text_; ArrayRef rawBytes_; std::vector > resultPoints_; BarcodeFormat format_; public: Result(Ref text, ArrayRef rawBytes, std::vector > resultPoints, BarcodeFormat format); ~Result(); Ref getText(); ArrayRef getRawBytes(); const std::vector >& getResultPoints() const; std::vector >& getResultPoints(); BarcodeFormat getBarcodeFormat() const; friend std::ostream& operator<<(std::ostream &out, Result& result); }; } #endif // __RESULT_H__ // file: zxing/Reader.h #ifndef __READER_H__ // #define __READER_H__ /* * Reader.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { class Reader : public Counted { protected: Reader() {} public: virtual Ref decode(Ref image); virtual Ref decode(Ref image, DecodeHints hints) = 0; virtual ~Reader(); }; } #endif // __READER_H__ // file: zxing/MultiFormatReader.h #ifndef __MULTI_FORMAT_READER_H__ // #define __MULTI_FORMAT_READER_H__ /* * MultiFormatBarcodeReader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { class MultiFormatReader : public Reader { private: Ref decodeInternal(Ref image); std::vector > readers_; DecodeHints hints_; public: MultiFormatReader(); Ref decode(Ref image); Ref decode(Ref image, DecodeHints hints); Ref decodeWithState(Ref image); void setHints(DecodeHints hints); ~MultiFormatReader(); }; } #endif // file: zxing/ReaderException.h #ifndef __READER_EXCEPTION_H__ // #define __READER_EXCEPTION_H__ /* * ReaderException.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class ReaderException : public Exception { public: ReaderException(); ReaderException(const char *msg); ~ReaderException() throw(); }; } #endif // __READER_EXCEPTION_H__ // file: zxing/datamatrix/decoder/Decoder.h #ifndef __DECODER_DM_H__ // #define __DECODER_DM_H__ /* * Decoder.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { namespace datamatrix { class Decoder { private: ReedSolomonDecoder rsDecoder_; void correctErrors(ArrayRef bytes, int numDataCodewords); public: Decoder(); Ref decode(Ref bits); }; } } #endif // __DECODER_DM_H__ // file: zxing/datamatrix/DataMatrixReader.h #ifndef __DATA_MATRIX_READER_H__ // #define __DATA_MATRIX_READER_H__ /* * DataMatrixReader.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace datamatrix { class DataMatrixReader : public Reader { private: Decoder decoder_; public: DataMatrixReader(); virtual Ref decode(Ref image, DecodeHints hints); virtual ~DataMatrixReader(); }; } } #endif // __DATA_MATRIX_READER_H__ // file: zxing/datamatrix/Version.h #ifndef __VERSION_H__ // #define __VERSION_H__ /* * Version.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { namespace datamatrix { class ECB { private: int count_; int dataCodewords_; public: ECB(int count, int dataCodewords); int getCount(); int getDataCodewords(); }; class ECBlocks { private: int ecCodewords_; std::vector ecBlocks_; public: ECBlocks(int ecCodewords, ECB *ecBlocks); ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2); int getECCodewords(); std::vector& getECBlocks(); ~ECBlocks(); }; class Version : public Counted { private: int versionNumber_; int symbolSizeRows_; int symbolSizeColumns_; int dataRegionSizeRows_; int dataRegionSizeColumns_; ECBlocks* ecBlocks_; int totalCodewords_; Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, int dataRegionSizeRows, int dataRegionSizeColumns, ECBlocks *ecBlocks); public: static std::vector > VERSIONS; ~Version(); int getVersionNumber(); int getSymbolSizeRows(); int getSymbolSizeColumns(); int getDataRegionSizeRows(); int getDataRegionSizeColumns(); int getTotalCodewords(); ECBlocks* getECBlocks(); static int buildVersions(); Ref getVersionForDimensions(int numRows, int numColumns); private: Version(const Version&); Version & operator=(const Version&); }; } } #endif // __VERSION_H__ // file: zxing/datamatrix/decoder/BitMatrixParser.h #ifndef __BIT_MATRIX_PARSER_DM_H__ // #define __BIT_MATRIX_PARSER_DM_H__ /* * BitMatrixParser.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include namespace zxing { namespace datamatrix { class BitMatrixParser : public Counted { private: Ref bitMatrix_; Ref parsedVersion_; Ref readBitMatrix_; int copyBit(size_t x, size_t y, int versionBits); public: BitMatrixParser(Ref bitMatrix); Ref readVersion(Ref bitMatrix); ArrayRef readCodewords(); bool readModule(int row, int column, int numRows, int numColumns); private: int readUtah(int row, int column, int numRows, int numColumns); int readCorner1(int numRows, int numColumns); int readCorner2(int numRows, int numColumns); int readCorner3(int numRows, int numColumns); int readCorner4(int numRows, int numColumns); Ref extractDataRegion(Ref bitMatrix); }; } } #endif // __BIT_MATRIX_PARSER_DM_H__ // file: zxing/datamatrix/decoder/DataBlock.h #ifndef __DATA_BLOCK_DM_H__ // #define __DATA_BLOCK_DM_H__ /* * DataBlock.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { namespace datamatrix { class DataBlock : public Counted { private: int numDataCodewords_; ArrayRef codewords_; DataBlock(int numDataCodewords, ArrayRef codewords); public: static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version); int getNumDataCodewords(); ArrayRef getCodewords(); }; } } #endif // __DATA_BLOCK_DM_H__ // file: zxing/datamatrix/decoder/DecodedBitStreamParser.h #ifndef __DECODED_BIT_STREAM_PARSER_DM_H__ // #define __DECODED_BIT_STREAM_PARSER_DM_H__ /* * DecodedBitStreamParser.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { namespace datamatrix { class DecodedBitStreamParser { private: static const int PAD_ENCODE = 0; // Not really an encoding static const int ASCII_ENCODE = 1; static const int C40_ENCODE = 2; static const int TEXT_ENCODE = 3; static const int ANSIX12_ENCODE = 4; static const int EDIFACT_ENCODE = 5; static const int BASE256_ENCODE = 6; /** * See ISO 16022:2006, Annex C Table C.1 * The C40 Basic Character Set (*'s used for placeholders for the shift values) */ static const char C40_BASIC_SET_CHARS[]; static const char C40_SHIFT2_SET_CHARS[]; /** * See ISO 16022:2006, Annex C Table C.2 * The Text Basic Character Set (*'s used for placeholders for the shift values) */ static const char TEXT_BASIC_SET_CHARS[]; static const char TEXT_SHIFT3_SET_CHARS[]; /** * See ISO 16022:2006, 5.2.3 and Annex C, Table C.2 */ int decodeAsciiSegment(Ref bits, std::ostringstream &result, std::ostringstream &resultTrailer); /** * See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 */ void decodeC40Segment(Ref bits, std::ostringstream &result); /** * See ISO 16022:2006, 5.2.6 and Annex C, Table C.2 */ void decodeTextSegment(Ref bits, std::ostringstream &result); /** * See ISO 16022:2006, 5.2.7 */ void decodeAnsiX12Segment(Ref bits, std::ostringstream &result); /** * See ISO 16022:2006, 5.2.8 and Annex C Table C.3 */ void decodeEdifactSegment(Ref bits, std::ostringstream &result); /** * See ISO 16022:2006, 5.2.9 and Annex B, B.2 */ void decodeBase256Segment(Ref bits, std::ostringstream &result, std::vector byteSegments); void parseTwoBytes(int firstByte, int secondByte, int*& result); /** * See ISO 16022:2006, Annex B, B.2 */ unsigned char unrandomize255State(int randomizedBase256Codeword, int base256CodewordPosition) { int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; return (unsigned char) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); }; void append(std::ostream &ost, const unsigned char *bufIn, size_t nIn, const char *src); public: DecodedBitStreamParser() { }; Ref decode(ArrayRef bytes); }; } } #endif // __DECODED_BIT_STREAM_PARSER_DM_H__ // file: zxing/datamatrix/detector/CornerPoint.h #ifndef __CORNER_FINDER_H__ // #define __CORNER_FINDER_H__ /* * CornerPoint.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace datamatrix { class CornerPoint : public ResultPoint { private: int counter_; public: CornerPoint(float posX, float posY); int getCount() const; void incrementCount(); bool equals(Ref other) const; }; } } #endif // __CORNER_FINDER_H__ // file: zxing/datamatrix/detector/MonochromeRectangleDetector.h #ifndef __MONOCHROMERECTANGLEDETECTOR_H__ // #define __MONOCHROMERECTANGLEDETECTOR_H__ /* * MonochromeRectangleDetector.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { namespace datamatrix { struct TwoInts: public Counted { int start; int end; }; class MonochromeRectangleDetector : public Counted { private: static const int MAX_MODULES = 32; Ref image_; public: MonochromeRectangleDetector(Ref image) : image_(image) { }; std::vector > detect(); private: Ref findCornerFromCenter(int centerX, int deltaX, int left, int right, int centerY, int deltaY, int top, int bottom, int maxWhiteRun); Ref blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim, bool horizontal); int max(int a, float b) { return (float) a > b ? a : (int) b;}; }; } } #endif // __MONOCHROMERECTANGLEDETECTOR_H__ // file: zxing/datamatrix/detector/Detector.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __DETECTOR_H__ // #define __DETECTOR_H__ /* * Detector.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include namespace zxing { namespace datamatrix { class ResultPointsAndTransitions: public Counted { private: Ref to_; Ref from_; int transitions_; public: ResultPointsAndTransitions(); ResultPointsAndTransitions(Ref from, Ref to, int transitions); Ref getFrom(); Ref getTo(); int getTransitions(); }; class Detector: public Counted { private: Ref image_; protected: Ref sampleGrid(Ref image, int dimensionX, int dimensionY, Ref transform); void insertionSort(std::vector >& vector); Ref correctTopRightRectangular(Ref bottomLeft, Ref bottomRight, Ref topLeft, Ref topRight, int dimensionTop, int dimensionRight); Ref correctTopRight(Ref bottomLeft, Ref bottomRight, Ref topLeft, Ref topRight, int dimension); bool isValid(Ref p); int distance(Ref a, Ref b); Ref transitionsBetween(Ref from, Ref to); int min(int a, int b) { return a > b ? b : a; } /** * Ends up being a bit faster than round(). This merely rounds its * argument to the nearest int, where x.5 rounds up. */ int round(float d) { return (int) (d + 0.5f); } public: Ref getImage(); Detector(Ref image); virtual Ref createTransform(Ref topLeft, Ref topRight, Ref bottomLeft, Ref bottomRight, int dimensionX, int dimensionY); Ref detect(); private: int compare(Ref a, Ref b); }; } } #endif // __DETECTOR_H__ // file: zxing/oned/OneDReader.h #ifndef __ONED_READER_H__ // #define __ONED_READER_H__ /* * OneDReader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { namespace oned { class OneDReader : public Reader { private: static const int INTEGER_MATH_SHIFT = 8; Ref doDecode(Ref image, DecodeHints hints); public: static const int PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT; OneDReader(); virtual Ref decode(Ref image, DecodeHints hints); // Implementations must not throw any exceptions. If a barcode is not found on this row, // a empty ref should be returned e.g. return Ref(); virtual Ref decodeRow(int rowNumber, Ref row) = 0; static unsigned int patternMatchVariance(int counters[], int countersSize, const int pattern[], int maxIndividualVariance); static bool recordPattern(Ref row, int start, int counters[], int countersCount); virtual ~OneDReader(); }; } } #endif // file: zxing/oned/Code128Reader.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __CODE_128_READER_H__ // #define __CODE_128_READER_H__ /* * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace oned { class Code128Reader : public OneDReader { private: enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 250/1000)}; enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 700/1000)}; static const int CODE_SHIFT = 98; static const int CODE_CODE_C = 99; static const int CODE_CODE_B = 100; static const int CODE_CODE_A = 101; static const int CODE_FNC_1 = 102; static const int CODE_FNC_2 = 97; static const int CODE_FNC_3 = 96; static const int CODE_FNC_4_A = 101; static const int CODE_FNC_4_B = 100; static const int CODE_START_A = 103; static const int CODE_START_B = 104; static const int CODE_START_C = 105; static const int CODE_STOP = 106; static int* findStartPattern(Ref row); static int decodeCode(Ref row, int counters[], int countersCount, int rowOffset); void append(char* s, char c); public: Ref decodeRow(int rowNumber, Ref row); Code128Reader(); ~Code128Reader(); }; } } #endif // file: zxing/oned/Code39Reader.h #ifndef __CODE_39_READER_H__ // #define __CODE_39_READER_H__ /* * Code39Reader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace oned { /** *

Decodes Code 39 barcodes. This does not support "Full ASCII Code 39" yet.

* Ported form Java (author Sean Owen) * @author Lukasz Warchol */ class Code39Reader : public OneDReader { private: std::string alphabet_string; bool usingCheckDigit; bool extendedMode; static int* findAsteriskPattern(Ref row); //throws ReaderException static int toNarrowWidePattern(int counters[], int countersLen); static char patternToChar(int pattern); //throws ReaderException static Ref decodeExtended(std::string encoded); //throws ReaderException void append(char* s, char c); public: Code39Reader(); Code39Reader(bool usingCheckDigit_); Code39Reader(bool usingCheckDigit_, bool extendedMode_); Ref decodeRow(int rowNumber, Ref row); }; } } #endif // file: zxing/oned/UPCEANReader.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __UPC_EAN_READER_H__ // #define __UPC_EAN_READER_H__ /* * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include typedef enum UPC_EAN_PATTERNS { UPC_EAN_PATTERNS_L_PATTERNS = 0, UPC_EAN_PATTERNS_L_AND_G_PATTERNS } UPC_EAN_PATTERNS; namespace zxing { namespace oned { class UPCEANReader : public OneDReader { private: enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 420/1000)}; enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 700/1000)}; static bool findStartGuardPattern(Ref row, int* rangeStart, int* rangeEnd); virtual bool decodeEnd(Ref row, int endStart, int* endGuardBegin, int* endGuardEnd); static bool checkStandardUPCEANChecksum(std::string s); protected: static bool findGuardPattern(Ref row, int rowOffset, bool whiteFirst, const int pattern[], int patternLen, int* start, int* end); virtual int getMIDDLE_PATTERN_LEN(); virtual const int* getMIDDLE_PATTERN(); public: UPCEANReader(); // Returns < 0 on failure, >= 0 on success. virtual int decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString) = 0; Ref decodeRow(int rowNumber, Ref row); // TODO(dswitkin): Should this be virtual so that UPCAReader can override it? Ref decodeRow(int rowNumber, Ref row, int startGuardBegin, int startGuardEnd); // Returns < 0 on failure, >= 0 on success. static int decodeDigit(Ref row, int counters[], int countersLen, int rowOffset, UPC_EAN_PATTERNS patternType); virtual bool checkChecksum(std::string s); virtual BarcodeFormat getBarcodeFormat() = 0; virtual ~UPCEANReader(); }; } } #endif // file: zxing/oned/EAN13Reader.h #ifndef __EAN_13_READER_H__ // #define __EAN_13_READER_H__ /* * EAN13Reader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace oned { class EAN13Reader : public UPCEANReader { private: static bool determineFirstDigit(std::string& resultString, int lgPatternFound); public: EAN13Reader(); int decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString); BarcodeFormat getBarcodeFormat(); }; } } #endif // file: zxing/oned/EAN8Reader.h #ifndef __EAN_8_READER_H__ // #define __EAN_8_READER_H__ /* * EAN8Reader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace oned { class EAN8Reader : public UPCEANReader { public: EAN8Reader(); int decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString); BarcodeFormat getBarcodeFormat(); }; } } #endif // file: zxing/oned/ITFReader.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __ITF_READER_H__ // #define __ITF_READER_H__ /* * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace oned { class ITFReader : public OneDReader { private: enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 420/1000)}; enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 800/1000)}; // Stores the actual narrow line width of the image being decoded. int narrowLineWidth; int* decodeStart(Ref row); //throws ReaderException int* decodeEnd(Ref row); //throws ReaderException static void decodeMiddle(Ref row, int payloadStart, int payloadEnd, std::string& resultString); //throws ReaderException void validateQuietZone(Ref row, int startPattern); //throws ReaderException static int skipWhiteSpace(Ref row); //throws ReaderException static int* findGuardPattern(Ref row, int rowOffset, const int pattern[], int patternLen); //throws ReaderException static int decodeDigit(int counters[], int countersLen); //throws ReaderException void append(char* s, char c); public: Ref decodeRow(int rowNumber, Ref row); ///throws ReaderException ITFReader(); ~ITFReader(); }; } } #endif // file: zxing/oned/MultiFormatOneDReader.h #ifndef __MULTI_FORMAT_ONED_READER_H__ // #define __MULTI_FORMAT_ONED_READER_H__ /* * MultiFormatOneDReader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { namespace oned { class MultiFormatOneDReader : public OneDReader { private: std::vector > readers; public: MultiFormatOneDReader(DecodeHints hints); Ref decodeRow(int rowNumber, Ref row); }; } } #endif // file: zxing/oned/MultiFormatUPCEANReader.h #ifndef __MULTI_FORMAT_UPC_EAN_READER_H__ // #define __MULTI_FORMAT_UPC_EAN_READER_H__ /* * MultiFormatUPCEANReader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { namespace oned { class MultiFormatUPCEANReader : public OneDReader { private: std::vector > readers; public: MultiFormatUPCEANReader(DecodeHints hints); Ref decodeRow(int rowNumber, Ref row); }; } } #endif // file: zxing/oned/OneDResultPoint.h #ifndef __ONED_RESULT_POINT_H__ // #define __ONED_RESULT_POINT_H__ /* * OneDResultPoint.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace oned { class OneDResultPoint : public ResultPoint { public: OneDResultPoint(float posX, float posY); }; } } #endif // file: zxing/oned/UPCAReader.h #ifndef __UPCA_READER_H__ // #define __UPCA_READER_H__ /* * UPCAReader.h * ZXing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace oned { class UPCAReader : public UPCEANReader { private: EAN13Reader ean13Reader; static Ref maybeReturnResult(Ref result); public: UPCAReader(); int decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString); Ref decodeRow(int rowNumber, Ref row); Ref decodeRow(int rowNumber, Ref row, int startGuardBegin, int startGuardEnd); Ref decode(Ref image, DecodeHints hints); BarcodeFormat getBarcodeFormat(); }; } } #endif // file: zxing/oned/UPCEReader.h #ifndef __UPC_E_READER_H__ // #define __UPC_E_READER_H__ /* * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace oned { class UPCEReader : public UPCEANReader { private: static bool determineNumSysAndCheckDigit(std::string& resultString, int lgPatternFound); protected: bool decodeEnd(Ref row, int endStart, int* endGuardBegin, int* endGuardEnd); bool checkChecksum(std::string s); public: UPCEReader(); int decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString); static std::string convertUPCEtoUPCA(std::string upce); BarcodeFormat getBarcodeFormat(); }; } } #endif // file: zxing/qrcode/ErrorCorrectionLevel.h #ifndef __ERROR_CORRECTION_LEVEL_H__ // #define __ERROR_CORRECTION_LEVEL_H__ /* * ErrorCorrectionLevel.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { namespace qrcode { class ErrorCorrectionLevel { private: int ordinal_; int bits_; std::string name_; ErrorCorrectionLevel(int inOrdinal, int bits, char const* name); static ErrorCorrectionLevel *FOR_BITS[]; static int N_LEVELS; public: static ErrorCorrectionLevel L; static ErrorCorrectionLevel M; static ErrorCorrectionLevel Q; static ErrorCorrectionLevel H; int ordinal() const; int bits() const; std::string const& name() const; operator std::string const& () const; static ErrorCorrectionLevel& forBits(int bits); }; } } #endif // __ERROR_CORRECTION_LEVEL_H__ // file: zxing/qrcode/FormatInformation.h #ifndef __FORMAT_INFORMATION_H__ // #define __FORMAT_INFORMATION_H__ /* * FormatInformation.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace qrcode { class FormatInformation : public Counted { private: static int FORMAT_INFO_MASK_QR; static int FORMAT_INFO_DECODE_LOOKUP[][2]; static int N_FORMAT_INFO_DECODE_LOOKUPS; static int BITS_SET_IN_HALF_BYTE[]; ErrorCorrectionLevel &errorCorrectionLevel_; unsigned char dataMask_; FormatInformation(int formatInfo); public: static int numBitsDiffering(unsigned int a, unsigned int b); static Ref decodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2); static Ref doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2); ErrorCorrectionLevel &getErrorCorrectionLevel(); unsigned char getDataMask(); friend bool operator==(const FormatInformation &a, const FormatInformation &b); friend std::ostream& operator<<(std::ostream& out, const FormatInformation& fi); }; } } #endif // __FORMAT_INFORMATION_H__ // file: zxing/qrcode/decoder/Decoder.h #ifndef __DECODER_H__ // #define __DECODER_H__ /* * Decoder.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { namespace qrcode { class Decoder { private: ReedSolomonDecoder rsDecoder_; void correctErrors(ArrayRef bytes, int numDataCodewords); public: Decoder(); Ref decode(Ref bits); }; } } #endif // __DECODER_H__ // file: zxing/qrcode/QRCodeReader.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __QR_CODE_READER_H__ // #define __QR_CODE_READER_H__ /* * QRCodeReader.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace qrcode { class QRCodeReader : public Reader { private: Decoder decoder_; protected: Decoder& getDecoder(); public: QRCodeReader(); virtual Ref decode(Ref image, DecodeHints hints); virtual ~QRCodeReader(); }; } } #endif // __QR_CODE_READER_H__ // file: zxing/qrcode/Version.h #ifndef __VERSION_H__ // #define __VERSION_H__ /* * Version.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { namespace qrcode { class ECB { private: int count_; int dataCodewords_; public: ECB(int count, int dataCodewords); int getCount(); int getDataCodewords(); }; class ECBlocks { private: int ecCodewords_; std::vector ecBlocks_; public: ECBlocks(int ecCodewords, ECB *ecBlocks); ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2); int getECCodewords(); std::vector& getECBlocks(); ~ECBlocks(); }; class Version : public Counted { private: int versionNumber_; std::vector &alignmentPatternCenters_; std::vector ecBlocks_; int totalCodewords_; Version(int versionNumber, std::vector *alignmentPatternCenters, ECBlocks *ecBlocks1, ECBlocks *ecBlocks2, ECBlocks *ecBlocks3, ECBlocks *ecBlocks4); public: static unsigned int VERSION_DECODE_INFO[]; static int N_VERSION_DECODE_INFOS; static std::vector > VERSIONS; ~Version(); int getVersionNumber(); std::vector &getAlignmentPatternCenters(); int getTotalCodewords(); int getDimensionForVersion(); ECBlocks &getECBlocksForLevel(ErrorCorrectionLevel &ecLevel); static Version *getProvisionalVersionForDimension(int dimension); static Version *getVersionForNumber(int versionNumber); static Version *decodeVersionInformation(unsigned int versionBits); Ref buildFunctionPattern(); static int buildVersions(); }; } } #endif // __VERSION_H__ // file: zxing/qrcode/decoder/BitMatrixParser.h #ifndef __BIT_MATRIX_PARSER_H__ // #define __BIT_MATRIX_PARSER_H__ /* * BitMatrixParser.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { namespace qrcode { class BitMatrixParser : public Counted { private: Ref bitMatrix_; Version *parsedVersion_; Ref parsedFormatInfo_; int copyBit(size_t x, size_t y, int versionBits); public: BitMatrixParser(Ref bitMatrix); Ref readFormatInformation(); Version *readVersion(); ArrayRef readCodewords(); private: BitMatrixParser(const BitMatrixParser&); BitMatrixParser& operator =(const BitMatrixParser&); }; } } #endif // __BIT_MATRIX_PARSER_H__ // file: zxing/qrcode/decoder/DataBlock.h #ifndef __DATA_BLOCK_H__ // #define __DATA_BLOCK_H__ /* * DataBlock.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include namespace zxing { namespace qrcode { class DataBlock : public Counted { private: int numDataCodewords_; ArrayRef codewords_; DataBlock(int numDataCodewords, ArrayRef codewords); public: static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); int getNumDataCodewords(); ArrayRef getCodewords(); }; } } #endif // __DATA_BLOCK_H__ // file: zxing/qrcode/decoder/DataMask.h #ifndef __DATA_MASK_H__ // #define __DATA_MASK_H__ /* * DataMask.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { namespace qrcode { class DataMask : public Counted { private: static std::vector > DATA_MASKS; protected: public: static int buildDataMasks(); DataMask(); virtual ~DataMask(); void unmaskBitMatrix(BitMatrix& matrix, size_t dimension); virtual bool isMasked(size_t x, size_t y) = 0; static DataMask& forReference(int reference); }; } } #endif // __DATA_MASK_H__ // file: zxing/qrcode/decoder/Mode.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __MODE_H__ // #define __MODE_H__ /* * Mode.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace qrcode { class Mode { private: int characterCountBitsForVersions0To9_; int characterCountBitsForVersions10To26_; int characterCountBitsForVersions27AndHigher_; int bits_; std::string name_; Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, char const* name); public: static Mode TERMINATOR; static Mode NUMERIC; static Mode ALPHANUMERIC; static Mode STRUCTURED_APPEND; static Mode BYTE; static Mode ECI; static Mode KANJI; static Mode FNC1_FIRST_POSITION; static Mode FNC1_SECOND_POSITION; static Mode HANZI; static Mode& forBits(int bits); int getCharacterCountBits(Version *version); }; } } #endif // __MODE_H__ // file: zxing/common/ECI.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __ECI__ #define __ECI__ /* * Copyright 2008-2011 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace zxing { namespace common { class ECI; } } class zxing::common::ECI { private: const int value; protected: ECI(int value); public: int getValue() const; static ECI* getECIByValue(int value); }; #endif // file: zxing/common/CharacterSetECI.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __CHARACTERSET_ECI__ #define __CHARACTERSET_ECI__ /* * Copyright 2008-2011 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace common { class CharacterSetECI; } } class zxing::common::CharacterSetECI : public ECI { private: static std::map VALUE_TO_ECI; static std::map NAME_TO_ECI; static const bool inited; static bool init_tables(); char const* const encodingName; CharacterSetECI(int value, char const* encodingName); static void addCharacterSet(int value, char const* encodingName); static void addCharacterSet(int value, char const* const* encodingNames); public: char const* getEncodingName(); static CharacterSetECI* getCharacterSetECIByValue(int value); static CharacterSetECI* getCharacterSetECIByName(std::string const& name); }; #endif // file: zxing/qrcode/decoder/DecodedBitStreamParser.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __DECODED_BIT_STREAM_PARSER_H__ // #define __DECODED_BIT_STREAM_PARSER_H__ /* * DecodedBitStreamParser.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include namespace zxing { namespace qrcode { class DecodedBitStreamParser { public: typedef std::map Hashtable; private: static char const ALPHANUMERIC_CHARS[]; static char toAlphaNumericChar(size_t value); static void decodeHanziSegment(Ref bits, std::string &result, int count); static void decodeKanjiSegment(Ref bits, std::string &result, int count); static void decodeByteSegment(Ref bits, std::string &result, int count); static void decodeByteSegment(Ref bits_, std::string& result, int count, zxing::common::CharacterSetECI* currentCharacterSetECI, ArrayRef< ArrayRef >& byteSegments, Hashtable const& hints); static void decodeAlphanumericSegment(Ref bits, std::string &result, int count, bool fc1InEffect); static void decodeNumericSegment(Ref bits, std::string &result, int count); static void append(std::string &ost, const unsigned char *bufIn, size_t nIn, const char *src); static void append(std::string &ost, std::string const& in, const char *src); public: static Ref decode(ArrayRef bytes, Version *version, ErrorCorrectionLevel const& ecLevel, Hashtable const& hints); }; } } #endif // __DECODED_BIT_STREAM_PARSER_H__ // file: zxing/qrcode/detector/AlignmentPattern.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __ALIGNMENT_PATTERN_H__ // #define __ALIGNMENT_PATTERN_H__ /* * AlignmentPattern.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace qrcode { class AlignmentPattern : public ResultPoint { private: float estimatedModuleSize_; public: AlignmentPattern(float posX, float posY, float estimatedModuleSize); bool aboutEquals(float moduleSize, float i, float j) const; Ref combineEstimate(float i, float j, float newModuleSize) const; }; } } #endif // __ALIGNMENT_PATTERN_H__ // file: zxing/qrcode/detector/AlignmentPatternFinder.h #ifndef __ALIGNMENT_PATTERN_FINDER_H__ // #define __ALIGNMENT_PATTERN_FINDER_H__ /* * AlignmentPatternFinder.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include "AlignmentPattern.h" // #include // #include // #include // #include namespace zxing { namespace qrcode { class AlignmentPatternFinder : public Counted { private: static int CENTER_QUORUM; static int MIN_SKIP; static int MAX_MODULES; Ref image_; std::vector *possibleCenters_; size_t startX_; size_t startY_; size_t width_; size_t height_; float moduleSize_; static float centerFromEnd(std::vector &stateCount, int end); bool foundPatternCross(std::vector &stateCount); float crossCheckVertical(size_t startI, size_t centerJ, int maxCount, int originalStateCountTotal); Ref handlePossibleCenter(std::vector &stateCount, size_t i, size_t j); public: AlignmentPatternFinder(Ref image, size_t startX, size_t startY, size_t width, size_t height, float moduleSize, Refconst& callback); ~AlignmentPatternFinder(); Ref find(); private: AlignmentPatternFinder(const AlignmentPatternFinder&); AlignmentPatternFinder& operator =(const AlignmentPatternFinder&); Ref callback_; }; } } #endif // __ALIGNMENT_PATTERN_FINDER_H__ // file: zxing/qrcode/detector/FinderPattern.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __FINDER_PATTERN_H__ // #define __FINDER_PATTERN_H__ /* * FinderPattern.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace qrcode { class FinderPattern : public ResultPoint { private: float estimatedModuleSize_; int count_; public: FinderPattern(float posX, float posY, float estimatedModuleSize); FinderPattern(float posX, float posY, float estimatedModuleSize, int count); int getCount() const; float getEstimatedModuleSize() const; void incrementCount(); bool aboutEquals(float moduleSize, float i, float j) const; Ref combineEstimate(float i, float j, float newModuleSize) const; }; } } #endif // __FINDER_PATTERN_H__ // file: zxing/qrcode/detector/FinderPatternInfo.h #ifndef __FINDER_PATTERN_INFO_H__ // #define __FINDER_PATTERN_INFO_H__ /* * FinderPatternInfo.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { namespace qrcode { class FinderPatternInfo : public Counted { private: Ref bottomLeft_; Ref topLeft_; Ref topRight_; public: FinderPatternInfo(std::vector > patternCenters); Ref getBottomLeft(); Ref getTopLeft(); Ref getTopRight(); }; } } #endif // __FINDER_PATTERN_INFO_H__ // file: zxing/qrcode/detector/Detector.h #ifndef __DETECTOR_H__ // #define __DETECTOR_H__ /* * Detector.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include // #include namespace zxing { class DecodeHints; namespace qrcode { class Detector : public Counted { private: Ref image_; Ref callback_; protected: Ref getImage(); static Ref sampleGrid(Ref image, int dimension, Ref); static int computeDimension(Ref topLeft, Ref topRight, Ref bottomLeft, float moduleSize); float calculateModuleSize(Ref topLeft, Ref topRight, Ref bottomLeft); float calculateModuleSizeOneWay(Ref pattern, Ref otherPattern); float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY); float sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY); Ref findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor); Ref processFinderPatternInfo(Ref info); public: virtual Ref createTransform(Ref topLeft, Ref topRight, Ref < ResultPoint > bottomLeft, Ref alignmentPattern, int dimension); Detector(Ref image); Ref detect(DecodeHints const& hints); }; } } #endif // __DETECTOR_H__ // file: zxing/qrcode/detector/FinderPatternFinder.h #ifndef __FINDER_PATTERN_FINDER_H__ // #define __FINDER_PATTERN_FINDER_H__ /* * FinderPatternFinder.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { class DecodeHints; namespace qrcode { class FinderPatternFinder { private: static int CENTER_QUORUM; protected: static int MIN_SKIP; static int MAX_MODULES; Ref image_; std::vector > possibleCenters_; bool hasSkipped_; Ref callback_; /** stateCount must be int[5] */ static float centerFromEnd(int* stateCount, int end); static bool foundPatternCross(int* stateCount); float crossCheckVertical(size_t startI, size_t centerJ, int maxCount, int originalStateCountTotal); float crossCheckHorizontal(size_t startJ, size_t centerI, int maxCount, int originalStateCountTotal); /** stateCount must be int[5] */ bool handlePossibleCenter(int* stateCount, size_t i, size_t j); int findRowSkip(); bool haveMultiplyConfirmedCenters(); std::vector > selectBestPatterns(); static std::vector > orderBestPatterns(std::vector > patterns); public: static float distance(Ref p1, Ref p2); FinderPatternFinder(Ref image, Refconst&); Ref find(DecodeHints const& hints); }; } } #endif // __FINDER_PATTERN_FINDER_H__ // file: zxing/qrcode/detector/QREdgeDetector.h #ifndef __QREDGEDETECTOR_H__ // #define __QREDGEDETECTOR_H__ /* * QREdgeDetector.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace qrcode { class QREdgeDetector : public Detector { public: QREdgeDetector(Ref image); virtual Ref createTransform(Ref topLeft, Ref topRight, Ref < ResultPoint > bottomLeft, Ref alignmentPattern, int dimension); private: Point findCorner(const BitMatrix& image, Point topLeft, Point topRight, Point bottomLeft, int dimension); Line findPatternEdge(const BitMatrix& image, Point pattern, Point opposite, Point direction, bool invert); Point endOfReverseBlackWhiteBlackRun(const BitMatrix& image, Point from, Point to); Ref get1CornerTransform(Point topLeft, Point topRight, Point bottomLeft, Point corner, int dimension); }; } } #endif // QREDGEDETECTOR_H_ // file: zxing/FormatException.h #ifndef __FORMAT_EXCEPTION_H__ // #define __FORMAT_EXCEPTION_H__ /* * FormatException.h * zxing * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class FormatException : public ReaderException { public: FormatException(); FormatException(const char *msg); ~FormatException() throw(); }; } #endif // __FORMAT_EXCEPTION_H__ // file: zxing/NotFoundException.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __NOT_FOUND_EXCEPTION_H__ // #define __NOT_FOUND_EXCEPTION_H__ /* * Copyright 20011 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include namespace zxing { class NotFoundException : public ReaderException { public: NotFoundException(const char *msg); ~NotFoundException() throw(); }; } #endif // __NOT_FOUND_EXCEPTION_H__ // file: zxing/common/StringUtils.h // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __STRING_UTILS__ #define __STRING_UTILS__ /* * Copyright (C) 2010-2011 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace common { class StringUtils; } } class zxing::common::StringUtils { private: static char const* const PLATFORM_DEFAULT_ENCODING; StringUtils() {} public: static char const* const ASCII; static char const* const SHIFT_JIS; static char const* const GB2312; static char const* const EUC_JP; static char const* const UTF8; static char const* const ISO88591; static const bool ASSUME_SHIFT_JIS; typedef std::map Hashtable; static std::string guessEncoding(unsigned char* bytes, int length, Hashtable const& hints); }; #endif // file: zxing/common/detector/MonochromeRectangleDetector.h #ifndef __MONOCHROMERECTANGLEDETECTOR_H__ // #define __MONOCHROMERECTANGLEDETECTOR_H__ /* * MonochromeRectangleDetector.h * y_wmk * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 y_wmk authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { struct TwoInts: public Counted { int start; int end; }; class MonochromeRectangleDetector : public Counted { private: static const int MAX_MODULES = 32; Ref image_; public: MonochromeRectangleDetector(Ref image) : image_(image) { }; std::vector > detect(); private: Ref findCornerFromCenter(int centerX, int deltaX, int left, int right, int centerY, int deltaY, int top, int bottom, int maxWhiteRun); Ref blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim, bool horizontal); int max(int a, float b) { return (float) a > b ? a : (int) b;}; }; } #endif // __MONOCHROMERECTANGLEDETECTOR_H__ // file: zxing/common/detector/WhiteRectangleDetector.h #ifndef __WHITERECTANGLEDETECTOR_H__ // #define __WHITERECTANGLEDETECTOR_H__ /* * WhiteRectangleDetector.h * * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include // #include namespace zxing { class WhiteRectangleDetector : public Counted { private: static int INIT_SIZE; static int CORR; Ref image_; int width_; int height_; public: WhiteRectangleDetector(Ref image); std::vector > detect(); private: int round(float a); Ref getBlackPointOnSegment(float aX, float aY, float bX, float bY); int distanceL2(float aX, float aY, float bX, float bY); std::vector > centerEdges(Ref y, Ref z, Ref x, Ref t); bool containsBlackPoint(int a, int b, int fixed, bool horizontal); }; } #endif // file: zxing/datamatrix/detector/DetectorException.h /* * DetectorException.h * * Created on: Aug 26, 2011 * Author: luiz */ #ifndef DETECTOREXCEPTION_H_ #define DETECTOREXCEPTION_H_ // #include namespace zxing { namespace datamatrix { class DetectorException : public Exception { public: DetectorException(const char *msg); virtual ~DetectorException() throw(); }; } /* namespace nexxera */ } /* namespace zxing */ #endif /* DETECTOREXCEPTION_H_ */ // file: zxing/multi/ByQuadrantReader.h #ifndef __BY_QUADRANT_READER_H__ // #define __BY_QUADRANT_READER_H__ /* * Copyright 2011 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include namespace zxing { namespace multi { class ByQuadrantReader : public Reader { private: Reader& delegate_; public: ByQuadrantReader(Reader& delegate); virtual ~ByQuadrantReader(); virtual Ref decode(Ref image); virtual Ref decode(Ref image, DecodeHints hints); }; } // End zxing::multi namespace } // End zxing namespace #endif // __BY_QUADRANT_READER_H__ // file: zxing/multi/MultipleBarcodeReader.h #ifndef __MULTIPLE_BARCODE_READER_H__ // #define __MULTIPLE_BARCODE_READER_H__ /* * Copyright 2011 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include // #include // #include namespace zxing { namespace multi { class MultipleBarcodeReader : public Counted { protected: MultipleBarcodeReader() {} public: virtual std::vector > decodeMultiple(Ref image); virtual std::vector > decodeMultiple(Ref image, DecodeHints hints) = 0; virtual ~MultipleBarcodeReader(); }; } // End zxing::multi namespace } // End zxing namespace #endif // __MULTIPLE_BARCODE_READER_H__ // file: zxing/multi/GenericMultipleBarcodeReader.h #ifndef __GENERIC_MULTIPLE_BARCODE_READER_H__ // #define __GENERIC_MULTIPLE_BARCODE_READER_H__ /* * Copyright 2011 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace multi { class GenericMultipleBarcodeReader : public MultipleBarcodeReader { private: static Ref translateResultPoints(Ref result, int xOffset, int yOffset); void doDecodeMultiple(Ref image, DecodeHints hints, std::vector >& results, int xOffset, int yOffset); Reader& delegate_; static const int MIN_DIMENSION_TO_RECUR = 100; public: GenericMultipleBarcodeReader(Reader& delegate); virtual ~GenericMultipleBarcodeReader(); virtual std::vector > decodeMultiple(Ref image, DecodeHints hints); }; } // End zxing::multi namespace } // End zxing namespace #endif // __GENERIC_MULTIPLE_BARCODE_READER_H__ // file: zxing/multi/qrcode/QRCodeMultiReader.h #ifndef __QRCODE_MULTI_READER_H__ // #define __QRCODE_MULTI_READER_H__ /* * Copyright 2011 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include namespace zxing { namespace multi { class QRCodeMultiReader: public zxing::qrcode::QRCodeReader, public MultipleBarcodeReader { public: QRCodeMultiReader(); virtual ~QRCodeMultiReader(); virtual std::vector > decodeMultiple(Ref image, DecodeHints hints); }; } // End zxing::multi namespace } // End zxing namespace #endif // __QRCODE_MULTI_READER_H__ // file: zxing/multi/qrcode/detector/MultiDetector.h #ifndef __MULTI_DETECTOR_H__ // #define __MULTI_DETECTOR_H__ /* * Copyright 2011 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace multi { class MultiDetector : public zxing::qrcode::Detector { public: MultiDetector(Ref image); virtual ~MultiDetector(); virtual std::vector > detectMulti(DecodeHints hints); }; } // End zxing::multi namespace } // End zxing namespace #endif // __MULTI_DETECTOR_H__ // file: zxing/multi/qrcode/detector/MultiFinderPatternFinder.h #ifndef __MULTI_FINDER_PATTERN_FINDER_H__ // #define __MULTI_FINDER_PATTERN_FINDER_H__ /* * Copyright 2011 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #include // #include // #include namespace zxing { namespace multi { class MultiFinderPatternFinder : zxing::qrcode::FinderPatternFinder { private: std::vector > > selectBestPatterns(); static const float MAX_MODULE_COUNT_PER_EDGE; static const float MIN_MODULE_COUNT_PER_EDGE; static const float DIFF_MODSIZE_CUTOFF_PERCENT; static const float DIFF_MODSIZE_CUTOFF; public: MultiFinderPatternFinder(Ref image, Ref resultPointCallback); virtual ~MultiFinderPatternFinder(); virtual std::vector > findMulti(DecodeHints const& hints); }; } } #endif // __MULTI_FINDER_PATTERN_FINDER_H__