diff --git a/.gitignore b/.gitignore index 2f20d0c..b58488c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ Makefile *.loc *.user *.mmp -*.pkg \ No newline at end of file +*.pkg +QZXing-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/ +QZXing-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release/ \ No newline at end of file diff --git a/source/CameraImageWrapper.cpp b/source/CameraImageWrapper.cpp index f88e2c1..90783b8 100644 --- a/source/CameraImageWrapper.cpp +++ b/source/CameraImageWrapper.cpp @@ -164,7 +164,11 @@ ArrayRef CameraImageWrapper::getMatrix() const { ArrayRef tmpRow; tmpRow = getRow(y, ArrayRef(width)); - memcpy(m, tmpRow->values().data(), width); +#if __cplusplus > 199711L + memcpy(m, tmpRow->values()..data(), width); +#else + memcpy(m, &tmpRow->values()[0], width); +#endif m += width * sizeof(unsigned char); //delete tmpRow; diff --git a/source/QZXing.h b/source/QZXing.h index 628a540..9da294b 100644 --- a/source/QZXing.h +++ b/source/QZXing.h @@ -18,12 +18,19 @@ * * Regarding DecoderFormat, by default all of those are enabled (except DataMatrix will is still not supported) */ -class QZXINGSHARED_EXPORT QZXing : public QObject{ +class +#ifndef DISABLE_LIBRARY_FEATURES + QZXINGSHARED_EXPORT +#endif + QZXing : public QObject{ + Q_OBJECT Q_ENUMS(DecoderFormat) + Q_PROPERTY(int processingTime READ getProcessTimeOfLastDecoding) + Q_PROPERTY(uint enabledDecoders READ getEnabledFormats WRITE setDecoder NOTIFY enabledFormatsChanged) + public: /* - * */ enum DecoderFormat { @@ -48,20 +55,12 @@ public: } ; typedef unsigned int DecoderFormatType; -public: QZXing(QObject *parent = NULL); - /** - * Set the enabled decoders. - * As argument it is possible to pass conjuction of decoders by using logic OR. - * e.x. setDecoder ( DecoderFormat_QR_CODE | DecoderFormat_EAN_13 | DecoderFormat_CODE_39 ) - */ - void setDecoder(DecoderFormatType hint); - #if QT_VERSION >= 0x040700 static void registerQMLTypes() { - qmlRegisterType("QZXing", 1, 2, "QZXing"); + qmlRegisterType("QZXing", 2, 2, "QZXing"); } #endif @@ -72,6 +71,12 @@ public slots: */ QString decodeImage(QImage image); + /** + * The decoding function. Will try to decode the given image based on the enabled decoders. + * The input image is read from a local image file. + */ + QString decodeImageFromFile(QString imageFilePath); + /** * The decoding function accessible from QML */ @@ -85,15 +90,32 @@ public slots: const double offsetX = 0 , const double offsetY = 0, const double width = 0, const double height = 0); + /** + * Get the prossecing time in millisecond of the last decode operation. + * Added mainly as a statistic measure. + * Decoding operation fails, the processing time equals to -1. + */ + int getProcessTimeOfLastDecoding(); + + uint getEnabledFormats() const; + /** + * Set the enabled decoders. + * As argument it is possible to pass conjuction of decoders by using logic OR. + * e.x. setDecoder ( DecoderFormat_QR_CODE | DecoderFormat_EAN_13 | DecoderFormat_CODE_39 ) + */ + void setDecoder(const uint& hint); + signals: void decodingStarted(); void decodingFinished(bool succeeded); void tagFound(QString tag); + void enabledFormatsChanged(); private: void* decoder; - DecoderFormatType supportedFormats; + DecoderFormatType enabledDecoders; QObject* imageHandler; + int processingTime; }; #endif // QZXING_H diff --git a/source/QZXing.pri b/source/QZXing.pri index e912de2..3594940 100644 --- a/source/QZXing.pri +++ b/source/QZXing.pri @@ -3,193 +3,231 @@ QT += core gui greaterThan(QT_VERSION, 4.7): QT += declarative DEFINES += QZXING_LIBRARY \ - ZXING_ICONV_CONST + ZXING_ICONV_CONST \ + DISABLE_LIBRARY_FEATURES -INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD \ + $$PWD/zxing + +HEADERS += $$PWD/QZXing_global.h \ HEADERS += $$PWD/QZXing_global.h \ $$PWD/CameraImageWrapper.h \ $$PWD/imagehandler.h \ $$PWD/qzxing.h \ - $$PWD/zxing/ResultPointCallback.h \ - $$PWD/zxing/ResultPoint.h \ - $$PWD/zxing/Result.h \ - $$PWD/zxing/ReaderException.h \ - $$PWD/zxing/Reader.h \ - $$PWD/zxing/NotFoundException.h \ - $$PWD/zxing/MultiFormatReader.h \ - $$PWD/zxing/LuminanceSource.h \ - $$PWD/zxing/FormatException.h \ - $$PWD/zxing/Exception.h \ - $$PWD/zxing/DecodeHints.h \ - $$PWD/zxing/BinaryBitmap.h \ - $$PWD/zxing/Binarizer.h \ - $$PWD/zxing/BarcodeFormat.h \ - $$PWD/zxing/aztec/AztecReader.h \ - $$PWD/zxing/aztec/AztecDetectorResult.h \ - $$PWD/zxing/aztec/decoder/Decoder.h \ - $$PWD/zxing/aztec/detector/Detector.h \ - $$PWD/zxing/common/StringUtils.h \ - $$PWD/zxing/common/Str.h \ - $$PWD/zxing/common/Point.h \ - $$PWD/zxing/common/PerspectiveTransform.h \ - $$PWD/zxing/common/IllegalArgumentException.h \ - $$PWD/zxing/common/HybridBinarizer.h \ - $$PWD/zxing/common/GridSampler.h \ - $$PWD/zxing/common/GreyscaleRotatedLuminanceSource.h \ - $$PWD/zxing/common/GreyscaleLuminanceSource.h \ - $$PWD/zxing/common/GlobalHistogramBinarizer.h \ - $$PWD/zxing/common/EdgeDetector.h \ - $$PWD/zxing/common/DetectorResult.h \ - $$PWD/zxing/common/DecoderResult.h \ - $$PWD/zxing/common/Counted.h \ - $$PWD/zxing/common/CharacterSetECI.h \ - $$PWD/zxing/common/BitSource.h \ - $$PWD/zxing/common/BitMatrix.h \ - $$PWD/zxing/common/BitArray.h \ - $$PWD/zxing/common/Array.h \ - $$PWD/zxing/common/detector/WhiteRectangleDetector.h \ - $$PWD/zxing/common/detector/MonochromeRectangleDetector.h \ - $$PWD/zxing/common/reedsolomon/ReedSolomonException.h \ - $$PWD/zxing/common/reedsolomon/ReedSolomonDecoder.h \ - $$PWD/zxing/common/reedsolomon/GenericGFPoly.h \ - $$PWD/zxing/common/reedsolomon/GenericGF.h \ - $$PWD/zxing/datamatrix/Version.h \ - $$PWD/zxing/datamatrix/DataMatrixReader.h \ - $$PWD/zxing/datamatrix/decoder/Decoder.h \ - $$PWD/zxing/datamatrix/decoder/DecodedBitStreamParser.h \ - $$PWD/zxing/datamatrix/decoder/DataBlock.h \ - $$PWD/zxing/datamatrix/decoder/BitMatrixParser.h \ - $$PWD/zxing/datamatrix/detector/MonochromeRectangleDetector.h \ - $$PWD/zxing/datamatrix/detector/DetectorException.h \ - $$PWD/zxing/datamatrix/detector/Detector.h \ - $$PWD/zxing/datamatrix/detector/CornerPoint.h \ - $$PWD/zxing/oned/UPCEReader.h \ - $$PWD/zxing/oned/UPCEANReader.h \ - $$PWD/zxing/oned/UPCAReader.h \ - $$PWD/zxing/oned/OneDResultPoint.h \ - $$PWD/zxing/oned/OneDReader.h \ - $$PWD/zxing/oned/MultiFormatUPCEANReader.h \ - $$PWD/zxing/oned/MultiFormatOneDReader.h \ - $$PWD/zxing/oned/ITFReader.h \ - $$PWD/zxing/oned/EAN13Reader.h \ - $$PWD/zxing/oned/EAN8Reader.h \ - $$PWD/zxing/oned/Code128Reader.h \ - $$PWD/zxing/oned/Code39Reader.h \ - $$PWD/zxing/qrcode/Version.h \ - $$PWD/zxing/qrcode/QRCodeReader.h \ - $$PWD/zxing/qrcode/FormatInformation.h \ - $$PWD/zxing/qrcode/ErrorCorrectionLevel.h \ - $$PWD/zxing/qrcode/decoder/Mode.h \ - $$PWD/zxing/qrcode/decoder/Decoder.h \ - $$PWD/zxing/qrcode/decoder/DecodedBitStreamParser.h \ - $$PWD/zxing/qrcode/decoder/DataMask.h \ - $$PWD/zxing/qrcode/decoder/DataBlock.h \ - $$PWD/zxing/qrcode/decoder/BitMatrixParser.h \ - $$PWD/zxing/qrcode/detector/QREdgeDetector.h \ - $$PWD/zxing/qrcode/detector/FinderPatternInfo.h \ - $$PWD/zxing/qrcode/detector/FinderPatternFinder.h \ - $$PWD/zxing/qrcode/detector/FinderPattern.h \ - $$PWD/zxing/qrcode/detector/Detector.h \ - $$PWD/zxing/qrcode/detector/AlignmentPatternFinder.h \ - $$PWD/zxing/qrcode/detector/AlignmentPattern.h \ - $$PWD/zxing/multi/MultipleBarcodeReader.h \ - $$PWD/zxing/multi/GenericMultipleBarcodeReader.h \ - $$PWD/zxing/multi/ByQuadrantReader.h \ - $$PWD/zxing/multi/qrcode/QRCodeMultiReader.h \ - $$PWD/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h \ - $$PWD/zxing/multi/qrcode/detector/MultiDetector.h + $$PWD/zxing/zxing/ZXing.h \ + $$PWD/zxing/zxing/IllegalStateException.h \ + $$PWD/zxing/zxing/InvertedLuminanceSource.h \ + $$PWD/zxing/zxing/ChecksumException.h \ + $$PWD/zxing/zxing/ResultPointCallback.h \ + $$PWD/zxing/zxing/ResultPoint.h \ + $$PWD/zxing/zxing/Result.h \ + $$PWD/zxing/zxing/ReaderException.h \ + $$PWD/zxing/zxing/Reader.h \ + $$PWD/zxing/zxing/NotFoundException.h \ + $$PWD/zxing/zxing/MultiFormatReader.h \ + $$PWD/zxing/zxing/LuminanceSource.h \ + $$PWD/zxing/zxing/FormatException.h \ + $$PWD/zxing/zxing/Exception.h \ + $$PWD/zxing/zxing/DecodeHints.h \ + $$PWD/zxing/zxing/BinaryBitmap.h \ + $$PWD/zxing/zxing/Binarizer.h \ + $$PWD/zxing/zxing/BarcodeFormat.h \ + $$PWD/zxing/zxing/aztec/AztecReader.h \ + $$PWD/zxing/zxing/aztec/AztecDetectorResult.h \ + $$PWD/zxing/zxing/aztec/decoder/Decoder.h \ + $$PWD/zxing/zxing/aztec/detector/Detector.h \ + $$PWD/zxing/zxing/common/StringUtils.h \ + $$PWD/zxing/zxing/common/Str.h \ + $$PWD/zxing/zxing/common/Point.h \ + $$PWD/zxing/zxing/common/PerspectiveTransform.h \ + $$PWD/zxing/zxing/common/IllegalArgumentException.h \ + $$PWD/zxing/zxing/common/HybridBinarizer.h \ + $$PWD/zxing/zxing/common/GridSampler.h \ + $$PWD/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h \ + $$PWD/zxing/zxing/common/GreyscaleLuminanceSource.h \ + $$PWD/zxing/zxing/common/GlobalHistogramBinarizer.h \ + $$PWD/zxing/zxing/common/DetectorResult.h \ + $$PWD/zxing/zxing/common/DecoderResult.h \ + $$PWD/zxing/zxing/common/Counted.h \ + $$PWD/zxing/zxing/common/CharacterSetECI.h \ + $$PWD/zxing/zxing/common/BitSource.h \ + $$PWD/zxing/zxing/common/BitMatrix.h \ + $$PWD/zxing/zxing/common/BitArray.h \ + $$PWD/zxing/zxing/common/Array.h \ + $$PWD/zxing/zxing/common/detector/MathUtils.h \ + $$PWD/zxing/zxing/common/detector/JavaMath.h \ + $$PWD/zxing/zxing/common/detector/WhiteRectangleDetector.h \ + $$PWD/zxing/zxing/common/detector/MonochromeRectangleDetector.h \ + $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonException.h \ + $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h \ + $$PWD/zxing/zxing/common/reedsolomon/GenericGFPoly.h \ + $$PWD/zxing/zxing/common/reedsolomon/GenericGF.h \ + $$PWD/zxing/zxing/datamatrix/Version.h \ + $$PWD/zxing/zxing/datamatrix/DataMatrixReader.h \ + $$PWD/zxing/zxing/datamatrix/decoder/Decoder.h \ + $$PWD/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h \ + $$PWD/zxing/zxing/datamatrix/decoder/DataBlock.h \ + $$PWD/zxing/zxing/datamatrix/decoder/BitMatrixParser.h \ + $$PWD/zxing/zxing/datamatrix/detector/DetectorException.h \ + $$PWD/zxing/zxing/datamatrix/detector/Detector.h \ + $$PWD/zxing/zxing/datamatrix/detector/CornerPoint.h \ + $$PWD/zxing/zxing/oned/UPCEReader.h \ + $$PWD/zxing/zxing/oned/UPCEANReader.h \ + $$PWD/zxing/zxing/oned/UPCAReader.h \ + $$PWD/zxing/zxing/oned/OneDResultPoint.h \ + $$PWD/zxing/zxing/oned/OneDReader.h \ + $$PWD/zxing/zxing/oned/MultiFormatUPCEANReader.h \ + $$PWD/zxing/zxing/oned/MultiFormatOneDReader.h \ + $$PWD/zxing/zxing/oned/ITFReader.h \ + $$PWD/zxing/zxing/oned/EAN13Reader.h \ + $$PWD/zxing/zxing/oned/EAN8Reader.h \ + $$PWD/zxing/zxing/oned/Code128Reader.h \ + $$PWD/zxing/zxing/oned/Code39Reader.h \ + $$PWD/zxing/zxing/oned/CodaBarReader.h \ + $$PWD/zxing/zxing/oned/Code93Reader.h \ + $$PWD/zxing/zxing/qrcode/Version.h \ + $$PWD/zxing/zxing/qrcode/QRCodeReader.h \ + $$PWD/zxing/zxing/qrcode/FormatInformation.h \ + $$PWD/zxing/zxing/qrcode/ErrorCorrectionLevel.h \ + $$PWD/zxing/zxing/qrcode/decoder/Mode.h \ + $$PWD/zxing/zxing/qrcode/decoder/Decoder.h \ + $$PWD/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h \ + $$PWD/zxing/zxing/qrcode/decoder/DataMask.h \ + $$PWD/zxing/zxing/qrcode/decoder/DataBlock.h \ + $$PWD/zxing/zxing/qrcode/decoder/BitMatrixParser.h \ + $$PWD/zxing/zxing/qrcode/detector/FinderPatternInfo.h \ + $$PWD/zxing/zxing/qrcode/detector/FinderPatternFinder.h \ + $$PWD/zxing/zxing/qrcode/detector/FinderPattern.h \ + $$PWD/zxing/zxing/qrcode/detector/Detector.h \ + $$PWD/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h \ + $$PWD/zxing/zxing/qrcode/detector/AlignmentPattern.h \ + $$PWD/zxing/zxing/multi/MultipleBarcodeReader.h \ + $$PWD/zxing/zxing/multi/GenericMultipleBarcodeReader.h \ + $$PWD/zxing/zxing/multi/ByQuadrantReader.h \ + $$PWD/zxing/zxing/multi/qrcode/QRCodeMultiReader.h \ + $$PWD/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h \ + $$PWD/zxing/zxing/multi/qrcode/detector/MultiDetector.h \ + $$PWD/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h \ + $$PWD/zxing/zxing/pdf417/decoder/ec/ModulusGF.h \ + $$PWD/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h \ + $$PWD/zxing/zxing/pdf417/decoder/BitMatrixParser.h \ + $$PWD/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h \ + $$PWD/zxing/zxing/pdf417/decoder/Decoder.h \ + $$PWD/zxing/zxing/pdf417/detector/Detector.h \ + $$PWD/zxing/zxing/pdf417/detector/LinesSampler.h \ + $$PWD/zxing/zxing/pdf417/PDF417Reader.h \ + $$PWD/zxing/bigint/NumberlikeArray.hh \ + $$PWD/zxing/bigint/BigUnsignedInABase.hh \ + $$PWD/zxing/bigint/BigUnsigned.hh \ + $$PWD/zxing/bigint/BigIntegerUtils.hh \ + $$PWD/zxing/bigint/BigIntegerLibrary.hh \ + $$PWD/zxing/bigint/BigIntegerAlgorithms.hh \ + $$PWD/zxing/bigint/BigInteger.hh SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/qzxing.cpp \ $$PWD/imagehandler.cpp \ - $$PWD/zxing/ResultPointCallback.cpp \ - $$PWD/zxing/ResultPoint.cpp \ - $$PWD/zxing/Result.cpp \ - $$PWD/zxing/ReaderException.cpp \ - $$PWD/zxing/Reader.cpp \ - $$PWD/zxing/NotFoundException.cpp \ - $$PWD/zxing/MultiFormatReader.cpp \ - $$PWD/zxing/LuminanceSource.cpp \ - $$PWD/zxing/FormatException.cpp \ - $$PWD/zxing/Exception.cpp \ - $$PWD/zxing/DecodeHints.cpp \ - $$PWD/zxing/BinaryBitmap.cpp \ - $$PWD/zxing/Binarizer.cpp \ - $$PWD/zxing/BarcodeFormat.cpp \ - $$PWD/zxing/aztec/AztecReader.cpp \ - $$PWD/zxing/aztec/AztecDetectorResult.cpp \ - $$PWD/zxing/common/StringUtils.cpp \ - $$PWD/zxing/common/Str.cpp \ - $$PWD/zxing/common/PerspectiveTransform.cpp \ - $$PWD/zxing/common/IllegalArgumentException.cpp \ - $$PWD/zxing/common/HybridBinarizer.cpp \ - $$PWD/zxing/common/GridSampler.cpp \ - $$PWD/zxing/common/GreyscaleRotatedLuminanceSource.cpp \ - $$PWD/zxing/common/GreyscaleLuminanceSource.cpp \ - $$PWD/zxing/common/GlobalHistogramBinarizer.cpp \ - $$PWD/zxing/common/EdgeDetector.cpp \ - $$PWD/zxing/common/DetectorResult.cpp \ - $$PWD/zxing/common/DecoderResult.cpp \ - $$PWD/zxing/common/Counted.cpp \ - $$PWD/zxing/common/CharacterSetECI.cpp \ - $$PWD/zxing/common/BitSource.cpp \ - $$PWD/zxing/common/BitMatrix.cpp \ - $$PWD/zxing/common/BitArray.cpp \ - $$PWD/zxing/common/Array.cpp \ - $$PWD/zxing/common/detector/WhiteRectangleDetector.cpp \ - $$PWD/zxing/common/detector/MonochromeRectangleDetector.cpp \ - $$PWD/zxing/common/reedsolomon/ReedSolomonException.cpp \ - $$PWD/zxing/common/reedsolomon/ReedSolomonDecoder.cpp \ - $$PWD/zxing/common/reedsolomon/GenericGFPoly.cpp \ - $$PWD/zxing/common/reedsolomon/GenericGF.cpp \ - $$PWD/zxing/datamatrix/DataMatrixReader.cpp \ - $$PWD/zxing/oned/UPCEReader.cpp \ - $$PWD/zxing/oned/UPCEANReader.cpp \ - $$PWD/zxing/oned/UPCAReader.cpp \ - $$PWD/zxing/oned/OneDResultPoint.cpp \ - $$PWD/zxing/oned/OneDReader.cpp \ - $$PWD/zxing/oned/MultiFormatUPCEANReader.cpp \ - $$PWD/zxing/oned/MultiFormatOneDReader.cpp \ - $$PWD/zxing/oned/ITFReader.cpp \ - $$PWD/zxing/oned/EAN13Reader.cpp \ - $$PWD/zxing/oned/EAN8Reader.cpp \ - $$PWD/zxing/oned/Code128Reader.cpp \ - $$PWD/zxing/oned/Code39Reader.cpp \ - $$PWD/zxing/qrcode/QRCodeReader.cpp \ - $$PWD/zxing/qrcode/detector/QREdgeDetector.cpp \ - $$PWD/zxing/multi/MultipleBarcodeReader.cpp \ - $$PWD/zxing/multi/GenericMultipleBarcodeReader.cpp \ - $$PWD/zxing/multi/ByQuadrantReader.cpp \ - $$PWD/zxing/multi/qrcode/QRCodeMultiReader.cpp \ - $$PWD/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp \ - $$PWD/zxing/multi/qrcode/detector/MultiDetector.cpp \ - $$PWD/zxing/aztec/decoder/AztecDecoder.cpp \ - $$PWD/zxing/aztec/detector/AztecDetector.cpp \ - $$PWD/zxing/datamatrix/DataMatrixVersion.cpp \ - $$PWD/zxing/datamatrix/decoder/DataMatrixDecoder.cpp \ - $$PWD/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp \ - $$PWD/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp \ - $$PWD/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp \ - $$PWD/zxing/datamatrix/detector/DataMatrixCornerPoint.cpp \ - $$PWD/zxing/datamatrix/detector/DataMatrixDetector.cpp \ - $$PWD/zxing/datamatrix/detector/DataMatrixDetectorException.cpp \ - $$PWD/zxing/datamatrix/detector/DataMatrixMonochromeRectangleDetector.cpp \ - $$PWD/zxing/qrcode/decoder/QRBitMatrixParser.cpp \ - $$PWD/zxing/qrcode/decoder/QRDataBlock.cpp \ - $$PWD/zxing/qrcode/decoder/QRDataMask.cpp \ - $$PWD/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp \ - $$PWD/zxing/qrcode/decoder/QRDecoder.cpp \ - $$PWD/zxing/qrcode/decoder/QRMode.cpp \ - $$PWD/zxing/qrcode/detector/QRAlignmentPattern.cpp \ - $$PWD/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp \ - $$PWD/zxing/qrcode/detector/QRDetector.cpp \ - $$PWD/zxing/qrcode/detector/QRFinderPattern.cpp \ - $$PWD/zxing/qrcode/detector/QRFinderPatternFinder.cpp \ - $$PWD/zxing/qrcode/detector/QRFinderPatternInfo.cpp \ - $$PWD/zxing/qrcode/QRVersion.cpp \ - $$PWD/zxing/qrcode/QRFormatInformation.cpp \ - $$PWD/zxing/qrcode/QRErrorCorrectionLevel.cpp + $$PWD/zxing/zxing/ResultIO.cpp \ + $$PWD/zxing/zxing/InvertedLuminanceSource.cpp \ + $$PWD/zxing/zxing/ChecksumException.cpp \ + $$PWD/zxing/zxing/ResultPointCallback.cpp \ + $$PWD/zxing/zxing/ResultPoint.cpp \ + $$PWD/zxing/zxing/Result.cpp \ + $$PWD/zxing/zxing/Reader.cpp \ + $$PWD/zxing/zxing/MultiFormatReader.cpp \ + $$PWD/zxing/zxing/LuminanceSource.cpp \ + $$PWD/zxing/zxing/FormatException.cpp \ + $$PWD/zxing/zxing/Exception.cpp \ + $$PWD/zxing/zxing/DecodeHints.cpp \ + $$PWD/zxing/zxing/BinaryBitmap.cpp \ + $$PWD/zxing/zxing/Binarizer.cpp \ + $$PWD/zxing/zxing/BarcodeFormat.cpp \ + $$PWD/zxing/zxing/aztec/AztecReader.cpp \ + $$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \ + $$PWD/zxing/zxing/common/StringUtils.cpp \ + $$PWD/zxing/zxing/common/Str.cpp \ + $$PWD/zxing/zxing/common/PerspectiveTransform.cpp \ + $$PWD/zxing/zxing/common/IllegalArgumentException.cpp \ + $$PWD/zxing/zxing/common/HybridBinarizer.cpp \ + $$PWD/zxing/zxing/common/GridSampler.cpp \ + $$PWD/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp \ + $$PWD/zxing/zxing/common/GreyscaleLuminanceSource.cpp \ + $$PWD/zxing/zxing/common/GlobalHistogramBinarizer.cpp \ + $$PWD/zxing/zxing/common/DetectorResult.cpp \ + $$PWD/zxing/zxing/common/DecoderResult.cpp \ + $$PWD/zxing/zxing/common/CharacterSetECI.cpp \ + $$PWD/zxing/zxing/common/BitSource.cpp \ + $$PWD/zxing/zxing/common/BitMatrix.cpp \ + $$PWD/zxing/zxing/common/BitArray.cpp \ + $$PWD/zxing/zxing/common/BitArrayIO.cpp \ + $$PWD/zxing/zxing/common/detector/WhiteRectangleDetector.cpp \ + $$PWD/zxing/zxing/common/detector/MonochromeRectangleDetector.cpp \ + $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp \ + $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.cpp \ + $$PWD/zxing/zxing/common/reedsolomon/GenericGFPoly.cpp \ + $$PWD/zxing/zxing/common/reedsolomon/GenericGF.cpp \ + $$PWD/zxing/zxing/datamatrix/DataMatrixReader.cpp \ + $$PWD/zxing/zxing/oned/UPCEReader.cpp \ + $$PWD/zxing/zxing/oned/UPCEANReader.cpp \ + $$PWD/zxing/zxing/oned/UPCAReader.cpp \ + $$PWD/zxing/zxing/oned/OneDResultPoint.cpp \ + $$PWD/zxing/zxing/oned/OneDReader.cpp \ + $$PWD/zxing/zxing/oned/MultiFormatUPCEANReader.cpp \ + $$PWD/zxing/zxing/oned/MultiFormatOneDReader.cpp \ + $$PWD/zxing/zxing/oned/ITFReader.cpp \ + $$PWD/zxing/zxing/oned/EAN13Reader.cpp \ + $$PWD/zxing/zxing/oned/EAN8Reader.cpp \ + $$PWD/zxing/zxing/oned/Code128Reader.cpp \ + $$PWD/zxing/zxing/oned/Code39Reader.cpp \ + $$PWD/zxing/zxing/oned/CodaBarReader.cpp \ + $$PWD/zxing/zxing/oned/Code93Reader.cpp \ + $$PWD/zxing/zxing/qrcode/QRCodeReader.cpp \ + $$PWD/zxing/zxing/multi/MultipleBarcodeReader.cpp \ + $$PWD/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp \ + $$PWD/zxing/zxing/multi/ByQuadrantReader.cpp \ + $$PWD/zxing/zxing/multi/qrcode/QRCodeMultiReader.cpp \ + $$PWD/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp \ + $$PWD/zxing/zxing/multi/qrcode/detector/MultiDetector.cpp \ + $$PWD/zxing/zxing/aztec/decoder/AztecDecoder.cpp \ + $$PWD/zxing/zxing/aztec/detector/AztecDetector.cpp \ + $$PWD/zxing/zxing/datamatrix/DataMatrixVersion.cpp \ + $$PWD/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp \ + $$PWD/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp \ + $$PWD/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp \ + $$PWD/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp \ + $$PWD/zxing/zxing/datamatrix/detector/DataMatrixCornerPoint.cpp \ + $$PWD/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp \ + $$PWD/zxing/zxing/datamatrix/detector/DataMatrixDetectorException.cpp \ + $$PWD/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp \ + $$PWD/zxing/zxing/qrcode/decoder/QRDataBlock.cpp \ + $$PWD/zxing/zxing/qrcode/decoder/QRDataMask.cpp \ + $$PWD/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp \ + $$PWD/zxing/zxing/qrcode/decoder/QRDecoder.cpp \ + $$PWD/zxing/zxing/qrcode/decoder/QRMode.cpp \ + $$PWD/zxing/zxing/qrcode/detector/QRAlignmentPattern.cpp \ + $$PWD/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp \ + $$PWD/zxing/zxing/qrcode/detector/QRDetector.cpp \ + $$PWD/zxing/zxing/qrcode/detector/QRFinderPattern.cpp \ + $$PWD/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp \ + $$PWD/zxing/zxing/qrcode/detector/QRFinderPatternInfo.cpp \ + $$PWD/zxing/zxing/qrcode/QRVersion.cpp \ + $$PWD/zxing/zxing/qrcode/QRFormatInformation.cpp \ + $$PWD/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp \ + $$PWD/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp \ + $$PWD/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp \ + $$PWD/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp \ + $$PWD/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp \ + $$PWD/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp \ + $$PWD/zxing/zxing/pdf417/decoder/PDF417Decoder.cpp \ + $$PWD/zxing/zxing/pdf417/detector/PDF417Detector.cpp \ + $$PWD/zxing/zxing/pdf417/detector/LinesSampler.cpp \ + $$PWD/zxing/zxing/pdf417/PDF417Reader.cpp \ + $$PWD/zxing/bigint/BigUnsignedInABase.cc \ + $$PWD/zxing/bigint/BigUnsigned.cc \ + $$PWD/zxing/bigint/BigIntegerUtils.cc \ + $$PWD/zxing/bigint/BigIntegerAlgorithms.cc \ + $$PWD/zxing/bigint/BigInteger.cc symbian { TARGET.UID3 = 0xE618743C @@ -215,6 +253,21 @@ unix:!symbian { INSTALLS += target } -win32{ - DEFINES += NO_ICONV +win32-msvc*{ + + INCLUDEPATH += $$PWD/zxing/win32/zxing \ + $$PWD/zxing/win32/zxing/stdint + HEADERS += $$PWD/zxing/win32/zxing/stdint/stdint.h \ + $$PWD/zxing/win32/zxing/iconv.h + + SOURCES += $$PWD/zxing/win32/zxing/win_iconv.c +} + +win32-g++{ + + INCLUDEPATH += $$PWD/zxing/win32/zxing + + HEADERS += $$PWD/zxing/win32/zxing/iconv.h + + SOURCES += $$PWD/zxing/win32/zxing/win_iconv.c } diff --git a/source/QZXing.pro b/source/QZXing.pro index 438dbe8..2854039 100644 --- a/source/QZXing.pro +++ b/source/QZXing.pro @@ -1,8 +1,4 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2011-11-13T18:12:28 -# -#------------------------------------------------- + QT += core gui @@ -135,7 +131,6 @@ HEADERS += QZXing_global.h \ zxing/bigint/BigIntegerLibrary.hh \ zxing/bigint/BigIntegerAlgorithms.hh \ zxing/bigint/BigInteger.hh \ - zxing/win32/zxing/stdint.h \ zxing/win32/zxing/iconv.h SOURCES += CameraImageWrapper.cpp \ @@ -269,8 +264,16 @@ unix:!symbian { INSTALLS += target } -win32{ - DEFINES += NO_ICONV +win32-msvc*{ + + INCLUDEPATH += zxing/win32/zxing \ + zxing/win32/zxing/stdint + HEADERS += zxing/win32/zxing/stdint/stdint.h +} + +win32-g++{ + INCLUDEPATH += zxing/win32/zxing +# DEFINES += NO_ICONV } OTHER_FILES += \ diff --git a/source/qzxing.cpp b/source/qzxing.cpp index f9856c5..c66fbfc 100644 --- a/source/qzxing.cpp +++ b/source/qzxing.cpp @@ -7,13 +7,14 @@ #include #include "CameraImageWrapper.h" #include "imagehandler.h" +#include using namespace zxing; QZXing::QZXing(QObject *parent) : QObject(parent) { decoder = new MultiFormatReader(); - setDecoder(DecoderFormat_QR_CODE | + /*setDecoder(DecoderFormat_QR_CODE | DecoderFormat_DATA_MATRIX | DecoderFormat_UPC_E | DecoderFormat_UPC_A | @@ -22,11 +23,11 @@ QZXing::QZXing(QObject *parent) : QObject(parent) DecoderFormat_CODE_128 | DecoderFormat_CODE_39 | DecoderFormat_ITF | - DecoderFormat_Aztec); + DecoderFormat_Aztec);*/ imageHandler = new ImageHandler(); } -void QZXing::setDecoder(DecoderFormatType hint) +void QZXing::setDecoder(const uint &hint) { unsigned int newHints = 0; @@ -81,14 +82,25 @@ void QZXing::setDecoder(DecoderFormatType hint) if(hint & DecoderFormat_UPC_EAN_EXTENSION) newHints |= BarcodeFormat::UPC_EAN_EXTENSION; - supportedFormats = newHints; + enabledDecoders = newHints; + + emit enabledFormatsChanged(); } QString QZXing::decodeImage(QImage image) { + QTime t; + t.start(); Ref res; emit decodingStarted(); + if(image.isNull()) + { + emit decodingFinished(false); + processingTime = -1; + return ""; + } + try{ Ref imageRef(new CameraImageWrapper(image)); GlobalHistogramBinarizer* binz = new GlobalHistogramBinarizer(imageRef); @@ -98,9 +110,10 @@ QString QZXing::decodeImage(QImage image) Ref ref(bb); - res = ((MultiFormatReader*)decoder)->decode(ref, DecodeHints((int)supportedFormats)); + res = ((MultiFormatReader*)decoder)->decode(ref, DecodeHints((int)enabledDecoders)); QString string = QString(res->getText()->getText().c_str()); + processingTime = t.elapsed(); emit tagFound(string); emit decodingFinished(true); return string; @@ -108,10 +121,19 @@ QString QZXing::decodeImage(QImage image) catch(zxing::Exception& e) { emit decodingFinished(false); + processingTime = -1; return ""; } } +QString QZXing::decodeImageFromFile(QString imageFilePath) +{ + //used to have a check if this image exists + //but was removed because if the image file path doesn't point to a valid image + // then the QImage::isNull will return true and the decoding will fail eitherway. + return decodeImage(QImage(imageFilePath)); +} + QString QZXing::decodeImageQML(QObject *item) { return decodeSubImageQML(item); @@ -132,4 +154,16 @@ QString QZXing::decodeSubImageQML(QObject* item, return decodeImage(img); } +int QZXing::getProcessTimeOfLastDecoding() +{ + return processingTime; +} + +uint QZXing::getEnabledFormats() const +{ + return enabledDecoders; +} + + + diff --git a/source/zxing/win32/zxing/stdint.h b/source/zxing/win32/zxing/stdint/stdint.h similarity index 100% rename from source/zxing/win32/zxing/stdint.h rename to source/zxing/win32/zxing/stdint/stdint.h diff --git a/source/zxing/zxing/DecodeHints.cpp b/source/zxing/zxing/DecodeHints.cpp index a3ea73c..d5eb1f7 100644 --- a/source/zxing/zxing/DecodeHints.cpp +++ b/source/zxing/zxing/DecodeHints.cpp @@ -29,7 +29,9 @@ using zxing::DecodeHints; // VC++ using zxing::BarcodeFormat; +#ifndef _MSC_VER const DecodeHintType DecodeHints::CHARACTER_SET; +#endif const DecodeHints DecodeHints::PRODUCT_HINT( UPC_A_HINT | diff --git a/source/zxing/zxing/ZXing.h b/source/zxing/zxing/ZXing.h index 18379fc..5ee4b07 100644 --- a/source/zxing/zxing/ZXing.h +++ b/source/zxing/zxing/ZXing.h @@ -40,23 +40,34 @@ typedef bool boolean; #if defined(_WIN32) || defined(_WIN64) #include +#include // It is needed to undef the isnan, because the Mingw contains the C99 macro #undef isnan namespace zxing { -inline bool isnan(float v) {return _isnan(v) != 0;} -inline bool isnan(double v) {return _isnan(v) != 0;} +inline bool isnan_z(float v) {return _isnan(v) != 0;} +inline bool isnan_z(double v) {return _isnan(v) != 0;} inline float nan() {return std::numeric_limits::quiet_NaN();} } #else -#include +#include + +using namespace std; namespace zxing { -inline bool isnan(float v) {return std::isnan(v);} -inline bool isnan(double v) {return std::isnan(v);} +inline bool isnan_z(float v) { + return /*std::*/isnan(v); +} +inline bool isnan_z(double v) { + return /*std::*/isnan(v); +} + +//#undef isfinite +//#undef signbit + inline float nan() {return std::numeric_limits::quiet_NaN();} } diff --git a/source/zxing/zxing/oned/EAN13Reader.cpp b/source/zxing/zxing/oned/EAN13Reader.cpp index fbec476..9b9a640 100644 --- a/source/zxing/zxing/oned/EAN13Reader.cpp +++ b/source/zxing/zxing/oned/EAN13Reader.cpp @@ -73,7 +73,7 @@ void EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFo // std::cerr << "K " << resultString << " " << lgPatternFound << " " < #include #include +#include #include #ifndef NO_ICONV #include @@ -82,7 +83,11 @@ void DecodedBitStreamParser::append(std::string &result, size_t nTo = maxOut; while (nFrom > 0) { - size_t oneway = iconv(cd, &fromPtr, &nFrom, &toPtr, &nTo); +#ifdef Q_OS_SYMBIAN + size_t oneway = iconv(cd, &fromPtr, &nFrom, &toPtr, &nTo); +#else + size_t oneway = iconv(cd, (char**)&fromPtr, &nFrom, &toPtr, &nTo); +#endif if (oneway == (size_t)(-1)) { iconv_close(cd); delete[] bufOut; diff --git a/source/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp b/source/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp index 8ce4321..5bffdc8 100644 --- a/source/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp +++ b/source/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp @@ -100,7 +100,7 @@ Ref AlignmentPatternFinder::handlePossibleCenter(vector & int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; float centerJ = centerFromEnd(stateCount, j); float centerI = crossCheckVertical(i, (int)centerJ, 2 * stateCount[1], stateCountTotal); - if (!isnan(centerI)) { + if (!zxing::isnan_z(centerI)) { float estimatedModuleSize = (float)(stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f; int max = possibleCenters_->size(); for (int index = 0; index < max; index++) { diff --git a/source/zxing/zxing/qrcode/detector/QRDetector.cpp b/source/zxing/zxing/qrcode/detector/QRDetector.cpp index d1e5506..b5ae1f9 100644 --- a/source/zxing/zxing/qrcode/detector/QRDetector.cpp +++ b/source/zxing/zxing/qrcode/detector/QRDetector.cpp @@ -195,10 +195,10 @@ float Detector::calculateModuleSizeOneWay(Ref pattern, RefgetX(), (int)otherPattern->getY()); float moduleSizeEst2 = sizeOfBlackWhiteBlackRunBothWays((int)otherPattern->getX(), (int)otherPattern->getY(), (int)pattern->getX(), (int)pattern->getY()); - if (zxing::isnan(moduleSizeEst1)) { + if (zxing::isnan_z(moduleSizeEst1)) { return moduleSizeEst2; } - if (zxing::isnan(moduleSizeEst2)) { + if (zxing::isnan_z(moduleSizeEst2)) { return moduleSizeEst1; } // Average them, and divide by 7 since we've counted the width of 3 black modules, diff --git a/source/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp b/source/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp index 1f3228b..eaf05ad 100644 --- a/source/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp +++ b/source/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp @@ -238,10 +238,10 @@ bool FinderPatternFinder::handlePossibleCenter(int* stateCount, size_t i, size_t int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; float centerJ = centerFromEnd(stateCount, j); float centerI = crossCheckVertical(i, (size_t)centerJ, stateCount[2], stateCountTotal); - if (!isnan(centerI)) { + if (!zxing::isnan_z(centerI)) { // Re-cross check centerJ = crossCheckHorizontal((size_t)centerJ, (size_t)centerI, stateCount[2], stateCountTotal); - if (!isnan(centerJ)) { + if (!zxing::isnan_z(centerJ)) { float estimatedModuleSize = (float)stateCountTotal / 7.0f; bool found = false; size_t max = possibleCenters_.size();