changed all Ref to QSharedPointer

This commit is contained in:
Nikolaos Ftylitakis 2021-08-02 00:16:25 +03:00
parent ef2e00df68
commit d601d8e74c
218 changed files with 1570 additions and 1569 deletions

View File

@ -71,7 +71,7 @@ CameraImageWrapper::CameraImageWrapper(const QImage &sourceImage) : LuminanceSou
{
updateImageAsGrayscale( sourceImage );
delegate = Ref<GreyscaleLuminanceSource>(
delegate = QSharedPointer<GreyscaleLuminanceSource>(
new GreyscaleLuminanceSource(getMatrixP(), sourceImage.width(), sourceImage.height(),0, 0, sourceImage.width(), sourceImage.height()));
}
@ -130,7 +130,7 @@ bool CameraImageWrapper::isCropSupported() const
return LuminanceSource::isCropSupported();
}
Ref<LuminanceSource> CameraImageWrapper::crop(int left, int top, int width, int height) const
QSharedPointer<LuminanceSource> CameraImageWrapper::crop(int left, int top, int width, int height) const
{
if(delegate)
return delegate->crop(left, top, width, height);
@ -146,7 +146,7 @@ bool CameraImageWrapper::isRotateSupported() const
return LuminanceSource::isRotateSupported();
}
Ref<LuminanceSource> CameraImageWrapper::invert() const
QSharedPointer<LuminanceSource> CameraImageWrapper::invert() const
{
if(delegate)
return delegate->invert();
@ -154,7 +154,7 @@ Ref<LuminanceSource> CameraImageWrapper::invert() const
return LuminanceSource::invert();
}
Ref<LuminanceSource> CameraImageWrapper::rotateCounterClockwise() const
QSharedPointer<LuminanceSource> CameraImageWrapper::rotateCounterClockwise() const
{
if(delegate)
return delegate->rotateCounterClockwise();

View File

@ -34,16 +34,16 @@ public:
static CameraImageWrapper* Factory(const QImage& image, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation=false);
QSharedPointer<std::vector<QSharedPointer<std::vector<zxing::byte>> > getOriginalImage();
Ref<GreyscaleLuminanceSource> getDelegate() { return delegate; }
QSharedPointer<GreyscaleLuminanceSource> getDelegate() { return delegate; }
QSharedPointer<std::vector<zxing::byte>> getRow(int y, QSharedPointer<std::vector<zxing::byte>> row) const;
QSharedPointer<std::vector<zxing::byte>> getMatrix() const;
bool isCropSupported() const;
Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
QSharedPointer<LuminanceSource> crop(int left, int top, int width, int height) const;
bool isRotateSupported() const;
Ref<LuminanceSource> invert() const;
Ref<LuminanceSource> rotateCounterClockwise() const;
QSharedPointer<LuminanceSource> invert() const;
QSharedPointer<LuminanceSource> rotateCounterClockwise() const;
inline zxing::byte gray(const unsigned int r, const unsigned int g, const unsigned int b);
@ -52,7 +52,7 @@ private:
QSharedPointer<std::vector<zxing::byte>> getMatrixP() const;
void updateImageAsGrayscale(const QImage &origin);
Ref<GreyscaleLuminanceSource> delegate;
QSharedPointer<GreyscaleLuminanceSource> delegate;
QSharedPointer<std::vector<QSharedPointer<std::vector<zxing::byte>>> imageBytesPerRow;
QSharedPointer<std::vector<zxing::byte>> imageBytes;

View File

@ -345,7 +345,7 @@ void QZXing::setDecoder(const uint &hint)
* \param bitMatrix
* \return
*/
QRectF getTagRect(const QSharedPointer<std::vector<Ref<ResultPoint>> > &resultPoints, const Ref<BitMatrix> &bitMatrix)
QRectF getTagRect(const QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > &resultPoints, const QSharedPointer<BitMatrix> &bitMatrix)
{
if (resultPoints->size() < 2)
return QRectF();
@ -355,7 +355,7 @@ QRectF getTagRect(const QSharedPointer<std::vector<Ref<ResultPoint>> > &resultPo
// 1D barcode
if (resultPoints->size() == 2) {
WhiteRectangleDetector detector(bitMatrix);
std::vector<Ref<ResultPoint> > resultRectPoints = detector.detect();
std::vector<QSharedPointer<ResultPoint> > resultRectPoints = detector.detect();
if (resultRectPoints.size() != 4)
return QRectF();
@ -414,7 +414,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
QElapsedTimer t;
t.start();
processingTime = -1;
Ref<Result> res;
QSharedPointer<Result> res;
emit decodingStarted();
if(image.isNull())
@ -434,10 +434,10 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
QString errorMessage = "Unknown";
Ref<LuminanceSource> imageRefOriginal = Ref<LuminanceSource>(ciw);
Ref<LuminanceSource> imageRef = imageRefOriginal;
Ref<GlobalHistogramBinarizer> binz;
Ref<BinaryBitmap> bb;
QSharedPointer<LuminanceSource> imageRefOriginal = QSharedPointer<LuminanceSource>(ciw);
QSharedPointer<LuminanceSource> imageRef = imageRefOriginal;
QSharedPointer<GlobalHistogramBinarizer> binz;
QSharedPointer<BinaryBitmap> bb;
size_t numberOfIterations = 0;
if (imageSourceFilter & SourceFilter_ImageNormal)
@ -451,10 +451,10 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
try {
if((numberOfIterations == 1 && (imageSourceFilter & SourceFilter_ImageInverted)) || i == 1) {
//qDebug() << "Selecting Inverted Luminance source";
imageRef = Ref<LuminanceSource>((LuminanceSource*)(new InvertedLuminanceSource(imageRefOriginal)));
imageRef = QSharedPointer<LuminanceSource>((LuminanceSource*)(new InvertedLuminanceSource(imageRefOriginal)));
}
binz = Ref<GlobalHistogramBinarizer>( new GlobalHistogramBinarizer(imageRef) );
bb = Ref<BinaryBitmap>( new BinaryBitmap(binz) );
binz = QSharedPointer<GlobalHistogramBinarizer>( new GlobalHistogramBinarizer(imageRef) );
bb = QSharedPointer<BinaryBitmap>( new BinaryBitmap(binz) );
DecodeHints hints(static_cast<DecodeHintType>(enabledDecoders));
@ -493,13 +493,13 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
}
if (!lastDecodeOperationSucceded_&& tryHarder_ && (tryHarderType & TryHarderBehaviour_Rotate) && bb->isRotateSupported()) {
Ref<BinaryBitmap> bbTmp = bb;
QSharedPointer<BinaryBitmap> bbTmp = bb;
//qDebug() << "Decoding phase 2, rotate: starting";
hints.setTryHarder(true);
for (int i=0; (i<3 && !lastDecodeOperationSucceded_); i++) {
Ref<BinaryBitmap> rotatedImage(bbTmp->rotateCounterClockwise());
QSharedPointer<BinaryBitmap> rotatedImage(bbTmp->rotateCounterClockwise());
bbTmp = rotatedImage;
try {
@ -670,7 +670,7 @@ QImage QZXing::encodeData(const QString &data, const QZXingEncoderConfig &encode
#ifdef ENABLE_ENCODER_QR_CODE
case EncoderFormat_QR_CODE:
{
Ref<qrcode::QRCode> barcode = qrcode::Encoder::encode(
QSharedPointer<qrcode::QRCode> barcode = qrcode::Encoder::encode(
data.toStdWString(),
encoderConfig.errorCorrectionLevel == EncodeErrorCorrectionLevel_H ?
qrcode::ErrorCorrectionLevel::H :
@ -680,7 +680,7 @@ QImage QZXing::encodeData(const QString &data, const QZXingEncoderConfig &encode
qrcode::ErrorCorrectionLevel::M :
qrcode::ErrorCorrectionLevel::L)));
Ref<qrcode::ByteMatrix> bytesRef = barcode->getMatrix();
QSharedPointer<qrcode::ByteMatrix> bytesRef = barcode->getMatrix();
const std::vector< std::vector <zxing::byte> >& bytes = bytesRef->getArray();
const int width = int(bytesRef->getWidth()) + (encoderConfig.border ? 2 : 0);
const int height = int(bytesRef->getHeight()) + (encoderConfig.border ? 2 : 0);

View File

@ -24,13 +24,13 @@
namespace zxing {
Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source) {
Binarizer::Binarizer(QSharedPointer<LuminanceSource> source) : source_(source) {
}
Binarizer::~Binarizer() {
}
Ref<LuminanceSource> Binarizer::getLuminanceSource() const {
QSharedPointer<LuminanceSource> Binarizer::getLuminanceSource() const {
return source_;
}

View File

@ -27,19 +27,19 @@
namespace zxing {
class Binarizer : public Counted {
class Binarizer {
private:
Ref<LuminanceSource> source_;
QSharedPointer<LuminanceSource> source_;
public:
Binarizer(Ref<LuminanceSource> source);
Binarizer(QSharedPointer<LuminanceSource> source);
virtual ~Binarizer();
virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row) = 0;
virtual Ref<BitMatrix> getBlackMatrix() = 0;
virtual QSharedPointer<BitArray> getBlackRow(int y, QSharedPointer<BitArray> row) = 0;
virtual QSharedPointer<BitMatrix> getBlackMatrix() = 0;
Ref<LuminanceSource> getLuminanceSource() const ;
virtual Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source) = 0;
QSharedPointer<LuminanceSource> getLuminanceSource() const ;
virtual QSharedPointer<Binarizer> createBinarizer(QSharedPointer<LuminanceSource> source) = 0;
int getWidth() const;
int getHeight() const;

View File

@ -25,7 +25,7 @@ using zxing::LuminanceSource;
// VC++
using zxing::Binarizer;
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : binarizer_(binarizer)
BinaryBitmap::BinaryBitmap(QSharedPointer<Binarizer> binarizer) : binarizer_(binarizer)
{
}
@ -33,12 +33,12 @@ BinaryBitmap::~BinaryBitmap()
{
}
Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row)
QSharedPointer<BitArray> BinaryBitmap::getBlackRow(int y, QSharedPointer<BitArray> row)
{
return binarizer_->getBlackRow(y, row);
}
Ref<BitMatrix> BinaryBitmap::getBlackMatrix()
QSharedPointer<BitMatrix> BinaryBitmap::getBlackMatrix()
{
return binarizer_->getBlackMatrix();
}
@ -53,7 +53,7 @@ int BinaryBitmap::getHeight() const
return getLuminanceSource()->getHeight();
}
Ref<LuminanceSource> BinaryBitmap::getLuminanceSource() const
QSharedPointer<LuminanceSource> BinaryBitmap::getLuminanceSource() const
{
return binarizer_->getLuminanceSource();
}
@ -63,9 +63,9 @@ bool BinaryBitmap::isCropSupported() const
return getLuminanceSource()->isCropSupported();
}
Ref<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height)
QSharedPointer<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height)
{
return Ref<BinaryBitmap>(new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
return QSharedPointer<BinaryBitmap>(new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
}
bool BinaryBitmap::isRotateSupported() const
@ -73,12 +73,12 @@ bool BinaryBitmap::isRotateSupported() const
return getLuminanceSource()->isRotateSupported();
}
Ref<BinaryBitmap> BinaryBitmap::rotateCounterClockwise()
QSharedPointer<BinaryBitmap> BinaryBitmap::rotateCounterClockwise()
{
return Ref<BinaryBitmap>(new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
return QSharedPointer<BinaryBitmap>(new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
}
Ref<zxing::BinaryBitmap> BinaryBitmap::rotateCounterClockwise45()
QSharedPointer<zxing::BinaryBitmap> BinaryBitmap::rotateCounterClockwise45()
{
return Ref<BinaryBitmap>(new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise45())));
return QSharedPointer<BinaryBitmap>(new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise45())));
}

View File

@ -27,28 +27,28 @@
namespace zxing {
class BinaryBitmap : public Counted {
class BinaryBitmap {
private:
Ref<Binarizer> binarizer_;
QSharedPointer<Binarizer> binarizer_;
public:
BinaryBitmap(Ref<Binarizer> binarizer);
BinaryBitmap(QSharedPointer<Binarizer> binarizer);
virtual ~BinaryBitmap();
Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
Ref<BitMatrix> getBlackMatrix();
QSharedPointer<BitArray> getBlackRow(int y, QSharedPointer<BitArray> row);
QSharedPointer<BitMatrix> getBlackMatrix();
Ref<LuminanceSource> getLuminanceSource() const;
QSharedPointer<LuminanceSource> getLuminanceSource() const;
int getWidth() const;
int getHeight() const;
bool isRotateSupported() const;
Ref<BinaryBitmap> rotateCounterClockwise();
Ref<BinaryBitmap> rotateCounterClockwise45();
QSharedPointer<BinaryBitmap> rotateCounterClockwise();
QSharedPointer<BinaryBitmap> rotateCounterClockwise45();
bool isCropSupported() const;
Ref<BinaryBitmap> crop(int left, int top, int width, int height);
QSharedPointer<BinaryBitmap> crop(int left, int top, int width, int height);
};
}

View File

@ -245,12 +245,12 @@ std::set<int> DecodeHints::getAllowedEanExtensions() const
return allowedEanExtensions;
}
void DecodeHints::setResultPointCallback(Ref<ResultPointCallback> const &_callback)
void DecodeHints::setResultPointCallback(QSharedPointer<ResultPointCallback> const &_callback)
{
callback = _callback;
}
Ref<ResultPointCallback> DecodeHints::getResultPointCallback() const
QSharedPointer<ResultPointCallback> DecodeHints::getResultPointCallback() const
{
return callback;
}

View File

@ -35,7 +35,7 @@ DecodeHints operator & (DecodeHints const&, DecodeHints const&);
class DecodeHints {
private:
DecodeHintType hints;
Ref<ResultPointCallback> callback;
QSharedPointer<ResultPointCallback> callback;
std::set<int> allowedEanExtensions;
public:
@ -82,8 +82,8 @@ class DecodeHints {
void setAllowedEanExtensions(std::set<int> toset);
std::set<int> getAllowedEanExtensions() const;
void setResultPointCallback(Ref<ResultPointCallback> const&);
Ref<ResultPointCallback> getResultPointCallback() const;
void setResultPointCallback(QSharedPointer<ResultPointCallback> const&);
QSharedPointer<ResultPointCallback> getResultPointCallback() const;
DecodeHints& operator =(DecodeHints const &other);

View File

@ -24,7 +24,7 @@ using zxing::LuminanceSource;
namespace zxing
{
InvertedLuminanceSource::InvertedLuminanceSource(Ref<LuminanceSource> const &delegate_)
InvertedLuminanceSource::InvertedLuminanceSource(QSharedPointer<LuminanceSource> const &delegate_)
: Super(delegate_->getWidth(), delegate_->getHeight()), delegate(delegate_) {}
QSharedPointer<std::vector<zxing::byte>> InvertedLuminanceSource::getRow(int y, QSharedPointer<std::vector<zxing::byte>> row) const
@ -55,9 +55,9 @@ namespace zxing
return delegate->isCropSupported();
}
Ref<LuminanceSource> InvertedLuminanceSource::crop(int left, int top, int width, int height) const
QSharedPointer<LuminanceSource> InvertedLuminanceSource::crop(int left, int top, int width, int height) const
{
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->crop(left, top, width, height)));
return QSharedPointer<LuminanceSource>(new InvertedLuminanceSource(delegate->crop(left, top, width, height)));
}
zxing::boolean InvertedLuminanceSource::isRotateSupported() const
@ -65,14 +65,14 @@ namespace zxing
return delegate->isRotateSupported();
}
Ref<LuminanceSource> InvertedLuminanceSource::invert() const
QSharedPointer<LuminanceSource> InvertedLuminanceSource::invert() const
{
return delegate;
}
Ref<LuminanceSource> InvertedLuminanceSource::rotateCounterClockwise() const
QSharedPointer<LuminanceSource> InvertedLuminanceSource::rotateCounterClockwise() const
{
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->rotateCounterClockwise()));
return QSharedPointer<LuminanceSource>(new InvertedLuminanceSource(delegate->rotateCounterClockwise()));
}
}

View File

@ -25,22 +25,22 @@ namespace zxing {
class InvertedLuminanceSource : public LuminanceSource {
private:
typedef LuminanceSource Super;
const Ref<LuminanceSource> delegate;
const QSharedPointer<LuminanceSource> delegate;
public:
InvertedLuminanceSource(Ref<LuminanceSource> const&);
InvertedLuminanceSource(QSharedPointer<LuminanceSource> const&);
QSharedPointer<std::vector<zxing::byte>> getRow(int y, QSharedPointer<std::vector<zxing::byte>> row) const;
QSharedPointer<std::vector<zxing::byte>> getMatrix() const;
boolean isCropSupported() const;
Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
QSharedPointer<LuminanceSource> crop(int left, int top, int width, int height) const;
boolean isRotateSupported() const;
virtual Ref<LuminanceSource> invert() const;
virtual QSharedPointer<LuminanceSource> invert() const;
Ref<LuminanceSource> rotateCounterClockwise() const;
QSharedPointer<LuminanceSource> rotateCounterClockwise() const;
};
}

View File

@ -34,7 +34,7 @@ bool LuminanceSource::isCropSupported() const
return false;
}
Ref<LuminanceSource> LuminanceSource::crop(int, int, int, int) const
QSharedPointer<LuminanceSource> LuminanceSource::crop(int, int, int, int) const
{
throw IllegalArgumentException("This luminance source does not support cropping.");
}
@ -44,12 +44,12 @@ bool LuminanceSource::isRotateSupported() const
return false;
}
Ref<LuminanceSource> LuminanceSource::rotateCounterClockwise() const
QSharedPointer<LuminanceSource> LuminanceSource::rotateCounterClockwise() const
{
throw IllegalArgumentException("This luminance source does not support rotation.");
}
Ref<zxing::LuminanceSource> LuminanceSource::rotateCounterClockwise45() const
QSharedPointer<zxing::LuminanceSource> LuminanceSource::rotateCounterClockwise45() const
{
throw IllegalArgumentException("This luminance source does not support rotation 45.");
}
@ -88,7 +88,7 @@ LuminanceSource::operator std::string() const
return oss.str();
}
Ref<LuminanceSource> LuminanceSource::invert() const
QSharedPointer<LuminanceSource> LuminanceSource::invert() const
{
// N.B.: this only works because we use counted objects with the
@ -100,5 +100,5 @@ Ref<LuminanceSource> LuminanceSource::invert() const
// needed. And, FWIW, that has nasty semantics in the face of
// exceptions during construction.
return Ref<LuminanceSource>(new InvertedLuminanceSource(Ref<LuminanceSource>(const_cast<LuminanceSource *>(this))));
return QSharedPointer<LuminanceSource>(new InvertedLuminanceSource(QSharedPointer<LuminanceSource>(const_cast<LuminanceSource *>(this))));
}

View File

@ -27,7 +27,7 @@
namespace zxing {
class LuminanceSource : public Counted {
class LuminanceSource {
private:
const int width;
const int height;
@ -44,15 +44,15 @@ class LuminanceSource : public Counted {
virtual QSharedPointer<std::vector<zxing::byte>> getMatrix() const = 0;
virtual bool isCropSupported() const;
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
virtual QSharedPointer<LuminanceSource> crop(int left, int top, int width, int height) const;
virtual bool isRotateSupported() const;
virtual Ref<LuminanceSource> invert() const;
virtual QSharedPointer<LuminanceSource> invert() const;
virtual Ref<LuminanceSource> rotateCounterClockwise() const;
virtual QSharedPointer<LuminanceSource> rotateCounterClockwise() const;
virtual Ref<LuminanceSource> rotateCounterClockwise45() const;
virtual QSharedPointer<LuminanceSource> rotateCounterClockwise45() const;
operator std::string () const;
};

View File

@ -49,19 +49,19 @@ using zxing::DecodeHints;
MultiFormatReader::MultiFormatReader() {}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image)
QSharedPointer<Result> MultiFormatReader::decode(QSharedPointer<BinaryBitmap> image)
{
setHints(DecodeHints::DEFAULT_HINT);
return decodeInternal(image);
}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
QSharedPointer<Result> MultiFormatReader::decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints)
{
setHints(hints);
return decodeInternal(image);
}
Ref<Result> MultiFormatReader::decodeWithState(Ref<BinaryBitmap> image)
QSharedPointer<Result> MultiFormatReader::decodeWithState(QSharedPointer<BinaryBitmap> image)
{
// Make sure to set up the default state so we don't crash
if (readers_.empty())
@ -102,35 +102,35 @@ void MultiFormatReader::enableReaders(zxing::DecodeHints hints, bool allowAll)
#ifdef ENABLE_DECODER_1D_BARCODES
if ((allowAll || addOneDReader) && !tryHarder)
{
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
readers_.push_back(QSharedPointer<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
#endif
#ifdef ENABLE_DECODER_QR_CODE
if (allowAll || hints.containsFormat(BarcodeFormat::QR_CODE))
{
readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
readers_.push_back(QSharedPointer<Reader>(new zxing::qrcode::QRCodeReader()));
}
#endif
#ifdef ENABLE_DECODER_DATA_MATRIX
if (allowAll || hints.containsFormat(BarcodeFormat::DATA_MATRIX))
{
readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
readers_.push_back(QSharedPointer<Reader>(new zxing::datamatrix::DataMatrixReader()));
}
#endif
#ifdef ENABLE_DECODER_AZTEC
if (allowAll || hints.containsFormat(BarcodeFormat::AZTEC))
{
readers_.push_back(Ref<Reader>(new zxing::aztec::AztecReader()));
readers_.push_back(QSharedPointer<Reader>(new zxing::aztec::AztecReader()));
}
#endif
#ifdef ENABLE_DECODER_PDF17
if (allowAll || hints.containsFormat(BarcodeFormat::PDF_417))
{
readers_.push_back(Ref<Reader>(new zxing::pdf417::PDF417Reader()));
readers_.push_back(QSharedPointer<Reader>(new zxing::pdf417::PDF417Reader()));
}
#endif
/*
@ -141,12 +141,12 @@ void MultiFormatReader::enableReaders(zxing::DecodeHints hints, bool allowAll)
#ifdef ENABLE_DECODER_1D_BARCODES
if ((allowAll || addOneDReader) && tryHarder)
{
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
readers_.push_back(QSharedPointer<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
#endif
}
Ref<Result> MultiFormatReader::decodeInternal(Ref<BinaryBitmap> image)
QSharedPointer<Result> MultiFormatReader::decodeInternal(QSharedPointer<BinaryBitmap> image)
{
for (size_t i = 0; i < readers_.size(); i++)
{

View File

@ -29,17 +29,17 @@
namespace zxing {
class MultiFormatReader : public Reader {
private:
Ref<Result> decodeInternal(Ref<BinaryBitmap> image);
QSharedPointer<Result> decodeInternal(QSharedPointer<BinaryBitmap> image);
std::vector<Ref<Reader> > readers_;
std::vector<QSharedPointer<Reader> > readers_;
DecodeHints hints_;
public:
MultiFormatReader();
Ref<Result> decode(Ref<BinaryBitmap> image);
Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
Ref<Result> decodeWithState(Ref<BinaryBitmap> image);
QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image);
QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints);
QSharedPointer<Result> decodeWithState(QSharedPointer<BinaryBitmap> image);
void setHints(DecodeHints hints);
void enableReaders(DecodeHints hints, bool allowAll = false);
~MultiFormatReader();

View File

@ -24,7 +24,7 @@ namespace zxing {
Reader::~Reader() { }
Ref<Result> Reader::decode(Ref<BinaryBitmap> image) {
QSharedPointer<Result> Reader::decode(QSharedPointer<BinaryBitmap> image) {
return decode(image, DecodeHints::DEFAULT_HINT);
}

View File

@ -26,12 +26,12 @@
namespace zxing {
class Reader : public Counted {
class Reader {
protected:
Reader() {}
public:
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image);
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints) = 0;
virtual ~Reader();
};

View File

@ -32,9 +32,9 @@ using zxing::BarcodeFormat;
namespace zxing {
Result::Result(Ref<String> text,
Result::Result(QSharedPointer<String> text,
QSharedPointer<std::vector<zxing::byte>> rawBytes,
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints,
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints,
BarcodeFormat format, const std::string &charSet,
ResultMetadata metadata) :
text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet), metadata_(metadata) {
@ -43,7 +43,7 @@ Result::Result(Ref<String> text,
Result::~Result() {
}
Ref<String> Result::getText() {
QSharedPointer<String> Result::getText() {
return text_;
}
@ -51,11 +51,11 @@ QSharedPointer<std::vector<zxing::byte>> Result::getRawBytes() {
return rawBytes_;
}
QSharedPointer<std::vector<Ref<ResultPoint>> > const& Result::getResultPoints() const {
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > const& Result::getResultPoints() const {
return resultPoints_;
}
QSharedPointer<std::vector<Ref<ResultPoint>> >& Result::getResultPoints() {
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >& Result::getResultPoints() {
return resultPoints_;
}

View File

@ -31,26 +31,26 @@
namespace zxing {
class Result : public Counted {
class Result {
private:
Ref<String> text_;
QSharedPointer<String> text_;
QSharedPointer<std::vector<zxing::byte>> rawBytes_;
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints_;
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints_;
BarcodeFormat format_;
std::string charSet_;
ResultMetadata metadata_;
public:
Result(Ref<String> text,
Result(QSharedPointer<String> text,
QSharedPointer<std::vector<zxing::byte>> rawBytes,
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints,
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints,
BarcodeFormat format, const std::string &charSet = "",
ResultMetadata metadata = ResultMetadata());
~Result();
Ref<String> getText();
QSharedPointer<String> getText();
QSharedPointer<std::vector<zxing::byte>> getRawBytes();
QSharedPointer<std::vector<Ref<ResultPoint>> > const& getResultPoints() const;
QSharedPointer<std::vector<Ref<ResultPoint>> >& getResultPoints();
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > const& getResultPoints() const;
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >& getResultPoints();
BarcodeFormat getBarcodeFormat() const;
std::string getCharSet() const;
ResultMetadata& getMetadata();

View File

@ -42,7 +42,7 @@ float ResultPoint::getY() const {
return posY_;
}
bool ResultPoint::equals(const Ref<ResultPoint> &other) {
bool ResultPoint::equals(const QSharedPointer<ResultPoint> &other) {
return posX_ == other->getX() && posY_ == other->getY();
}
@ -50,7 +50,7 @@ bool ResultPoint::equals(const Ref<ResultPoint> &other) {
* <p>Orders an array of three ResultPoints in an order [A,B,C] such that AB < AC and
* BC < AC and the angle between BC and BA is less than 180 degrees.
*/
void ResultPoint::orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns) {
void ResultPoint::orderBestPatterns(std::vector<QSharedPointer<ResultPoint> > &patterns) {
if(patterns.size() != 3)
return;
@ -59,7 +59,7 @@ void ResultPoint::orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns) {
float oneTwoDistance = distance(patterns[1]->getX(), patterns[2]->getX(),patterns[1]->getY(), patterns[2]->getY());
float zeroTwoDistance = distance(patterns[0]->getX(), patterns[2]->getX(),patterns[0]->getY(), patterns[2]->getY());
Ref<ResultPoint> pointA, pointB, pointC;
QSharedPointer<ResultPoint> pointA, pointB, pointC;
// Assume one closest to other two is B; A and C will just be guesses at first
if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
pointB = patterns[0];
@ -80,7 +80,7 @@ void ResultPoint::orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns) {
// we want for A, B, C. If it's negative, then we've got it flipped around and
// should swap A and C.
if (crossProductZ(pointA, pointB, pointC) < 0.0f) {
Ref<ResultPoint> temp = pointA;
QSharedPointer<ResultPoint> temp = pointA;
pointA = pointC;
pointC = temp;
}
@ -90,7 +90,7 @@ void ResultPoint::orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns) {
patterns[2] = pointC;
}
float ResultPoint::distance(Ref<ResultPoint> pattern1, Ref<ResultPoint> pattern2) {
float ResultPoint::distance(QSharedPointer<ResultPoint> pattern1, QSharedPointer<ResultPoint> pattern2) {
return MathUtils::distance(pattern1->posX_,
pattern1->posY_,
pattern2->posX_,
@ -103,7 +103,7 @@ float ResultPoint::distance(float x1, float x2, float y1, float y2) {
return (float) sqrt((double) (xDiff * xDiff + yDiff * yDiff));
}
float ResultPoint::crossProductZ(Ref<ResultPoint> pointA, Ref<ResultPoint> pointB, Ref<ResultPoint> pointC) {
float ResultPoint::crossProductZ(QSharedPointer<ResultPoint> pointA, QSharedPointer<ResultPoint> pointB, QSharedPointer<ResultPoint> pointC) {
float bX = pointB->getX();
float bY = pointB->getY();
return ((pointC->getX() - bX) * (pointA->getY() - bY)) - ((pointC->getY() - bY) * (pointA->getX() - bX));

View File

@ -26,7 +26,7 @@
namespace zxing {
class ResultPoint : public Counted {
class ResultPoint {
protected:
const float posX_;
const float posY_;
@ -40,14 +40,14 @@ public:
virtual float getX() const;
virtual float getY() const;
bool equals(const Ref<ResultPoint> &other);
bool equals(const QSharedPointer<ResultPoint> &other);
static void orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns);
static float distance(Ref<ResultPoint> point1, Ref<ResultPoint> point2);
static void orderBestPatterns(std::vector<QSharedPointer<ResultPoint> > &patterns);
static float distance(QSharedPointer<ResultPoint> point1, QSharedPointer<ResultPoint> point2);
static float distance(float x1, float x2, float y1, float y2);
private:
static float crossProductZ(Ref<ResultPoint> pointA, Ref<ResultPoint> pointB, Ref<ResultPoint> pointC);
static float crossProductZ(QSharedPointer<ResultPoint> pointA, QSharedPointer<ResultPoint> pointB, QSharedPointer<ResultPoint> pointC);
};
}

View File

@ -26,7 +26,7 @@ namespace zxing {
class ResultPoint;
class ResultPointCallback : public Counted {
class ResultPointCallback {
protected:
ResultPointCallback() {}
public:

View File

@ -29,8 +29,8 @@ using zxing::aztec::AztecDetectorResult;
using zxing::BitMatrix;
using zxing::ResultPoint;
AztecDetectorResult::AztecDetectorResult(Ref<BitMatrix> bits,
QSharedPointer<std::vector<Ref<ResultPoint>>> points,
AztecDetectorResult::AztecDetectorResult(QSharedPointer<BitMatrix> bits,
QSharedPointer<std::vector<QSharedPointer<ResultPoint>>> points,
bool compact,
int nbDatablocks,
int nbLayers)

View File

@ -32,8 +32,8 @@ class AztecDetectorResult : public DetectorResult {
bool compact_;
int nbDatablocks_, nbLayers_;
public:
AztecDetectorResult(Ref<BitMatrix> bits,
QSharedPointer<std::vector<Ref<ResultPoint>> > points,
AztecDetectorResult(QSharedPointer<BitMatrix> bits,
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points,
bool compact,
int nbDatablocks,
int nbLayers);

View File

@ -37,17 +37,17 @@ AztecReader::AztecReader() : decoder_()
// nothing
}
Ref<Result> AztecReader::decode(Ref<zxing::BinaryBitmap> image)
QSharedPointer<Result> AztecReader::decode(QSharedPointer<zxing::BinaryBitmap> image)
{
Detector detector(image->getBlackMatrix());
Ref<AztecDetectorResult> detectorResult(detector.detect());
QSharedPointer<AztecDetectorResult> detectorResult(detector.detect());
QSharedPointer<std::vector<Ref<ResultPoint>>> points(detectorResult->getPoints());
QSharedPointer<std::vector<QSharedPointer<ResultPoint>>> points(detectorResult->getPoints());
Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult));
QSharedPointer<DecoderResult> decoderResult(decoder_.decode(detectorResult));
Ref<Result> result(new Result(decoderResult->getText(),
QSharedPointer<Result> result(new Result(decoderResult->getText(),
decoderResult->getRawBytes(),
points,
BarcodeFormat::AZTEC));
@ -55,7 +55,7 @@ Ref<Result> AztecReader::decode(Ref<zxing::BinaryBitmap> image)
return result;
}
Ref<Result> AztecReader::decode(Ref<BinaryBitmap> image, DecodeHints)
QSharedPointer<Result> AztecReader::decode(QSharedPointer<BinaryBitmap> image, DecodeHints)
{
//cout << "decoding with hints not supported for aztec" << "\n" << flush;
return this->decode(image);

View File

@ -38,8 +38,8 @@ class AztecReader : public Reader {
public:
AztecReader();
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image);
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints);
virtual ~AztecReader();
};

View File

@ -146,13 +146,13 @@ Decoder::Decoder()
// nothing
}
Ref<DecoderResult> Decoder::decode(Ref<zxing::aztec::AztecDetectorResult> detectorResult)
QSharedPointer<DecoderResult> Decoder::decode(QSharedPointer<zxing::aztec::AztecDetectorResult> detectorResult)
{
ddata_ = detectorResult;
// std::printf("getting bits\n");
Ref<BitMatrix> matrix = detectorResult->getBits();
QSharedPointer<BitMatrix> matrix = detectorResult->getBits();
if (!ddata_->isCompact())
{
@ -161,13 +161,13 @@ Ref<DecoderResult> Decoder::decode(Ref<zxing::aztec::AztecDetectorResult> detect
}
// std::printf("extracting bits\n");
Ref<BitArray> rawbits = extractBits(matrix);
QSharedPointer<BitArray> rawbits = extractBits(matrix);
// std::printf("correcting bits\n");
Ref<BitArray> aCorrectedBits = correctBits(rawbits);
QSharedPointer<BitArray> aCorrectedBits = correctBits(rawbits);
// std::printf("decoding bits\n");
Ref<String> result = getEncodedData(aCorrectedBits);
QSharedPointer<String> result = getEncodedData(aCorrectedBits);
// std::printf("constructing array\n");
QSharedPointer<std::vector<zxing::byte>> arrayOut(aCorrectedBits->getSize());
@ -178,10 +178,10 @@ Ref<DecoderResult> Decoder::decode(Ref<zxing::aztec::AztecDetectorResult> detect
// std::printf("returning\n");
return Ref<DecoderResult>(new DecoderResult(arrayOut, result));
return QSharedPointer<DecoderResult>(new DecoderResult(arrayOut, result));
}
Ref<String> Decoder::getEncodedData(Ref<zxing::BitArray> correctedBits)
QSharedPointer<String> Decoder::getEncodedData(QSharedPointer<zxing::BitArray> correctedBits)
{
int endIndex = codewordSize_ * ddata_->getNBDatablocks() - invertedBitCount_;
if (endIndex > (int)correctedBits->getSize())
@ -306,15 +306,15 @@ Ref<String> Decoder::getEncodedData(Ref<zxing::BitArray> correctedBits)
}
}
return Ref<String>(new String(result));
return QSharedPointer<String>(new String(result));
}
Ref<BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits)
QSharedPointer<BitArray> Decoder::correctBits(QSharedPointer<zxing::BitArray> rawbits)
{
//return rawbits;
// std::printf("decoding stuff:%d datablocks in %d layers\n", ddata_->getNBDatablocks(), ddata_->getNBLayers());
Ref<GenericGF> gf = GenericGF::AZTEC_DATA_6;
QSharedPointer<GenericGF> gf = GenericGF::AZTEC_DATA_6;
if (ddata_->getNBLayers() <= 2)
{
@ -391,7 +391,7 @@ Ref<BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits)
offset = 0;
invertedBitCount_ = 0;
Ref<BitArray> correctedBits(new BitArray(numDataCodewords * codewordSize_));
QSharedPointer<BitArray> correctedBits(new BitArray(numDataCodewords * codewordSize_));
for (int i = 0; i < numDataCodewords; i++)
{
@ -441,7 +441,7 @@ Ref<BitArray> Decoder::correctBits(Ref<zxing::BitArray> rawbits)
return correctedBits;
}
Ref<BitArray> Decoder::extractBits(Ref<zxing::BitMatrix> matrix)
QSharedPointer<BitArray> Decoder::extractBits(QSharedPointer<zxing::BitMatrix> matrix)
{
std::vector<bool> rawbits;
@ -496,7 +496,7 @@ Ref<BitArray> Decoder::extractBits(Ref<zxing::BitMatrix> matrix)
size -= 4;
}
Ref<BitArray> returnValue(new BitArray(int(rawbits.size())));
QSharedPointer<BitArray> returnValue(new BitArray(int(rawbits.size())));
for (int i = 0; i < (int)rawbits.size(); i++)
{
if (rawbits[i])
@ -506,10 +506,10 @@ Ref<BitArray> Decoder::extractBits(Ref<zxing::BitMatrix> matrix)
return returnValue;
}
Ref<BitMatrix> Decoder::removeDashedLines(Ref<zxing::BitMatrix> matrix)
QSharedPointer<BitMatrix> Decoder::removeDashedLines(QSharedPointer<zxing::BitMatrix> matrix)
{
int nbDashed = 1 + 2 * ((matrix->getWidth() - 1) / 2 / 16);
Ref<BitMatrix> newMatrix(new BitMatrix(matrix->getWidth() - nbDashed, matrix->getHeight() - nbDashed));
QSharedPointer<BitMatrix> newMatrix(new BitMatrix(matrix->getWidth() - nbDashed, matrix->getHeight() - nbDashed));
int nx = 0;
@ -541,7 +541,7 @@ Ref<BitMatrix> Decoder::removeDashedLines(Ref<zxing::BitMatrix> matrix)
return newMatrix;
}
int Decoder::readCode(Ref<zxing::BitArray> rawbits, int startIndex, int length)
int Decoder::readCode(QSharedPointer<zxing::BitArray> rawbits, int startIndex, int length)
{
int res = 0;

View File

@ -32,7 +32,7 @@ class DecoderResult;
namespace aztec {
class Decoder : public Counted {
class Decoder {
private:
enum Table {
UPPER,
@ -48,19 +48,19 @@ class Decoder : public Counted {
int numCodewords_;
int codewordSize_;
Ref<AztecDetectorResult> ddata_;
QSharedPointer<AztecDetectorResult> ddata_;
int invertedBitCount_;
Ref<String> getEncodedData(Ref<BitArray> correctedBits);
Ref<BitArray> correctBits(Ref<BitArray> rawbits);
Ref<BitArray> extractBits(Ref<BitMatrix> matrix);
static Ref<BitMatrix> removeDashedLines(Ref<BitMatrix> matrix);
static int readCode(Ref<BitArray> rawbits, int startIndex, int length);
QSharedPointer<String> getEncodedData(QSharedPointer<BitArray> correctedBits);
QSharedPointer<BitArray> correctBits(QSharedPointer<BitArray> rawbits);
QSharedPointer<BitArray> extractBits(QSharedPointer<BitMatrix> matrix);
static QSharedPointer<BitMatrix> removeDashedLines(QSharedPointer<BitMatrix> matrix);
static int readCode(QSharedPointer<BitArray> rawbits, int startIndex, int length);
public:
Decoder();
Ref<DecoderResult> decode(Ref<AztecDetectorResult> detectorResult);
QSharedPointer<DecoderResult> decode(QSharedPointer<AztecDetectorResult> detectorResult);
};
}

View File

@ -40,7 +40,7 @@ using zxing::BitArray;
using zxing::BitMatrix;
using zxing::common::detector::MathUtils;
Detector::Detector(Ref<BitMatrix> image):
Detector::Detector(QSharedPointer<BitMatrix> image):
image_(image),
nbLayers_(0),
nbDataBlocks_(0),
@ -48,16 +48,16 @@ Detector::Detector(Ref<BitMatrix> image):
}
Ref<AztecDetectorResult> Detector::detect() {
Ref<Point> pCenter = getMatrixCenter();
QSharedPointer<AztecDetectorResult> Detector::detect() {
QSharedPointer<Point> pCenter = getMatrixCenter();
std::vector<Ref<Point> > bullEyeCornerPoints = getBullEyeCornerPoints(pCenter);
std::vector<QSharedPointer<Point> > bullEyeCornerPoints = getBullEyeCornerPoints(pCenter);
extractParameters(bullEyeCornerPoints);
QSharedPointer<std::vector<Ref<ResultPoint>> > corners = getMatrixCornerPoints(bullEyeCornerPoints);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > corners = getMatrixCornerPoints(bullEyeCornerPoints);
Ref<BitMatrix> bits =
QSharedPointer<BitMatrix> bits =
sampleGrid(image_,
corners[shift_%4],
corners[(shift_+3)%4],
@ -66,16 +66,16 @@ Ref<AztecDetectorResult> Detector::detect() {
// std::printf("------------\ndetected: compact:%s, nbDataBlocks:%d, nbLayers:%d\n------------\n",compact_?"YES":"NO", nbDataBlocks_, nbLayers_);
return Ref<AztecDetectorResult>(new AztecDetectorResult(bits, corners, compact_, nbDataBlocks_, nbLayers_));
return QSharedPointer<AztecDetectorResult>(new AztecDetectorResult(bits, corners, compact_, nbDataBlocks_, nbLayers_));
}
void Detector::extractParameters(std::vector<Ref<Point> > bullEyeCornerPoints) {
void Detector::extractParameters(std::vector<QSharedPointer<Point> > bullEyeCornerPoints) {
int twoCenterLayers = 2 * nbCenterLayers_;
// get the bits around the bull's eye
Ref<BitArray> resab = sampleLine(bullEyeCornerPoints[0], bullEyeCornerPoints[1], twoCenterLayers+1);
Ref<BitArray> resbc = sampleLine(bullEyeCornerPoints[1], bullEyeCornerPoints[2], twoCenterLayers+1);
Ref<BitArray> rescd = sampleLine(bullEyeCornerPoints[2], bullEyeCornerPoints[3], twoCenterLayers+1);
Ref<BitArray> resda = sampleLine(bullEyeCornerPoints[3], bullEyeCornerPoints[0], twoCenterLayers+1);
QSharedPointer<BitArray> resab = sampleLine(bullEyeCornerPoints[0], bullEyeCornerPoints[1], twoCenterLayers+1);
QSharedPointer<BitArray> resbc = sampleLine(bullEyeCornerPoints[1], bullEyeCornerPoints[2], twoCenterLayers+1);
QSharedPointer<BitArray> rescd = sampleLine(bullEyeCornerPoints[2], bullEyeCornerPoints[3], twoCenterLayers+1);
QSharedPointer<BitArray> resda = sampleLine(bullEyeCornerPoints[3], bullEyeCornerPoints[0], twoCenterLayers+1);
// determin the orientation of the matrix
if (resab->get(0) && resab->get(twoCenterLayers)) {
@ -96,8 +96,8 @@ void Detector::extractParameters(std::vector<Ref<Point> > bullEyeCornerPoints) {
//c b
//flatten the bits in a single array
Ref<BitArray> parameterData(new BitArray(compact_?28:40));
Ref<BitArray> shiftedParameterData(new BitArray(compact_?28:40));
QSharedPointer<BitArray> parameterData(new BitArray(compact_?28:40));
QSharedPointer<BitArray> shiftedParameterData(new BitArray(compact_?28:40));
if (compact_) {
for (int i = 0; i < 7; i++) {
@ -135,8 +135,8 @@ void Detector::extractParameters(std::vector<Ref<Point> > bullEyeCornerPoints) {
getParameters(parameterData);
}
QSharedPointer<std::vector<Ref<ResultPoint>> >
Detector::getMatrixCornerPoints(std::vector<Ref<Point> > bullEyeCornerPoints) {
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >
Detector::getMatrixCornerPoints(std::vector<QSharedPointer<Point> > bullEyeCornerPoints) {
float ratio = (2 * nbLayers_ + (nbLayers_ > 4 ? 1 : 0) + (nbLayers_ - 4) / 8) / (2.0f * nbCenterLayers_);
int dx = bullEyeCornerPoints[0]->getX() - bullEyeCornerPoints[2]->getX();
@ -167,16 +167,16 @@ Detector::getMatrixCornerPoints(std::vector<Ref<Point> > bullEyeCornerPoints) {
!isValid(targetdx, targetdy)) {
throw ReaderException("matrix extends over image bounds");
}
std::vector< Ref<ResultPoint> >* array = new std::vector< Ref<ResultPoint> >();
vector< Ref<ResultPoint> >& returnValue (array->values());
returnValue.push_back(Ref<ResultPoint>(new ResultPoint(float(targetax), float(targetay))));
returnValue.push_back(Ref<ResultPoint>(new ResultPoint(float(targetbx), float(targetby))));
returnValue.push_back(Ref<ResultPoint>(new ResultPoint(float(targetcx), float(targetcy))));
returnValue.push_back(Ref<ResultPoint>(new ResultPoint(float(targetdx), float(targetdy))));
return QSharedPointer<std::vector<Ref<ResultPoint>> >(array);
std::vector< QSharedPointer<ResultPoint> >* array = new std::vector< QSharedPointer<ResultPoint> >();
vector< QSharedPointer<ResultPoint> >& returnValue (array->values());
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetax), float(targetay))));
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetbx), float(targetby))));
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetcx), float(targetcy))));
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetdx), float(targetdy))));
return QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >(array);
}
void Detector::correctParameterData(Ref<zxing::BitArray> parameterData, bool compact) {
void Detector::correctParameterData(QSharedPointer<zxing::BitArray> parameterData, bool compact) {
int numCodewords;
int numDataCodewords;
@ -225,19 +225,19 @@ void Detector::correctParameterData(Ref<zxing::BitArray> parameterData, bool com
}
}
std::vector<Ref<Point> > Detector::getBullEyeCornerPoints(Ref<zxing::aztec::Point> pCenter) {
Ref<Point> pina = pCenter;
Ref<Point> pinb = pCenter;
Ref<Point> pinc = pCenter;
Ref<Point> pind = pCenter;
std::vector<QSharedPointer<Point> > Detector::getBullEyeCornerPoints(QSharedPointer<zxing::aztec::Point> pCenter) {
QSharedPointer<Point> pina = pCenter;
QSharedPointer<Point> pinb = pCenter;
QSharedPointer<Point> pinc = pCenter;
QSharedPointer<Point> pind = pCenter;
bool color = true;
for (nbCenterLayers_ = 1; nbCenterLayers_ < 9; nbCenterLayers_++) {
Ref<Point> pouta = getFirstDifferent(pina, color, 1, -1);
Ref<Point> poutb = getFirstDifferent(pinb, color, 1, 1);
Ref<Point> poutc = getFirstDifferent(pinc, color, -1, 1);
Ref<Point> poutd = getFirstDifferent(pind, color, -1, -1);
QSharedPointer<Point> pouta = getFirstDifferent(pina, color, 1, -1);
QSharedPointer<Point> poutb = getFirstDifferent(pinb, color, 1, 1);
QSharedPointer<Point> poutc = getFirstDifferent(pinc, color, -1, 1);
QSharedPointer<Point> poutd = getFirstDifferent(pind, color, -1, -1);
//d a
//
@ -291,21 +291,21 @@ std::vector<Ref<Point> > Detector::getBullEyeCornerPoints(Ref<zxing::aztec::Poin
throw ReaderException("bullseye extends over image bounds");
}
std::vector<Ref<Point> > returnValue;
returnValue.push_back(Ref<Point>(new Point(targetax, targetay)));
returnValue.push_back(Ref<Point>(new Point(targetbx, targetby)));
returnValue.push_back(Ref<Point>(new Point(targetcx, targetcy)));
returnValue.push_back(Ref<Point>(new Point(targetdx, targetdy)));
std::vector<QSharedPointer<Point> > returnValue;
returnValue.push_back(QSharedPointer<Point>(new Point(targetax, targetay)));
returnValue.push_back(QSharedPointer<Point>(new Point(targetbx, targetby)));
returnValue.push_back(QSharedPointer<Point>(new Point(targetcx, targetcy)));
returnValue.push_back(QSharedPointer<Point>(new Point(targetdx, targetdy)));
return returnValue;
}
Ref<Point> Detector::getMatrixCenter() {
Ref<ResultPoint> pointA, pointB, pointC, pointD;
QSharedPointer<Point> Detector::getMatrixCenter() {
QSharedPointer<ResultPoint> pointA, pointB, pointC, pointD;
try {
std::vector<Ref<ResultPoint> > cornerPoints = WhiteRectangleDetector(image_).detect();
std::vector<QSharedPointer<ResultPoint> > cornerPoints = WhiteRectangleDetector(image_).detect();
pointA = cornerPoints[0];
pointB = cornerPoints[1];
pointC = cornerPoints[2];
@ -317,10 +317,10 @@ Ref<Point> Detector::getMatrixCenter() {
int cx = image_->getWidth() / 2;
int cy = image_->getHeight() / 2;
pointA = getFirstDifferent(Ref<Point>(new Point(cx+7, cy-7)), false, 1, -1)->toResultPoint();
pointB = getFirstDifferent(Ref<Point>(new Point(cx+7, cy+7)), false, 1, 1)->toResultPoint();
pointC = getFirstDifferent(Ref<Point>(new Point(cx-7, cy+7)), false, -1, -1)->toResultPoint();
pointD = getFirstDifferent(Ref<Point>(new Point(cx-7, cy-7)), false, -1, -1)->toResultPoint();
pointA = getFirstDifferent(QSharedPointer<Point>(new Point(cx+7, cy-7)), false, 1, -1)->toResultPoint();
pointB = getFirstDifferent(QSharedPointer<Point>(new Point(cx+7, cy+7)), false, 1, 1)->toResultPoint();
pointC = getFirstDifferent(QSharedPointer<Point>(new Point(cx-7, cy+7)), false, -1, -1)->toResultPoint();
pointD = getFirstDifferent(QSharedPointer<Point>(new Point(cx-7, cy-7)), false, -1, -1)->toResultPoint();
}
@ -329,7 +329,7 @@ Ref<Point> Detector::getMatrixCenter() {
try {
std::vector<Ref<ResultPoint> > cornerPoints = WhiteRectangleDetector(image_, 15, cx, cy).detect();
std::vector<QSharedPointer<ResultPoint> > cornerPoints = WhiteRectangleDetector(image_, 15, cx, cy).detect();
pointA = cornerPoints[0];
pointB = cornerPoints[1];
pointC = cornerPoints[2];
@ -338,25 +338,25 @@ Ref<Point> Detector::getMatrixCenter() {
} catch (NotFoundException const& e) {
(void)e;
pointA = getFirstDifferent(Ref<Point>(new Point(cx+7, cy-7)), false, 1, -1)->toResultPoint();
pointB = getFirstDifferent(Ref<Point>(new Point(cx+7, cy+7)), false, 1, 1)->toResultPoint();
pointC = getFirstDifferent(Ref<Point>(new Point(cx-7, cy+7)), false, -1, 1)->toResultPoint();
pointD = getFirstDifferent(Ref<Point>(new Point(cx-7, cy-7)), false, -1, -1)->toResultPoint();
pointA = getFirstDifferent(QSharedPointer<Point>(new Point(cx+7, cy-7)), false, 1, -1)->toResultPoint();
pointB = getFirstDifferent(QSharedPointer<Point>(new Point(cx+7, cy+7)), false, 1, 1)->toResultPoint();
pointC = getFirstDifferent(QSharedPointer<Point>(new Point(cx-7, cy+7)), false, -1, 1)->toResultPoint();
pointD = getFirstDifferent(QSharedPointer<Point>(new Point(cx-7, cy-7)), false, -1, -1)->toResultPoint();
}
cx = MathUtils::round((pointA->getX() + pointD->getX() + pointB->getX() + pointC->getX()) / 4.0f);
cy = MathUtils::round((pointA->getY() + pointD->getY() + pointB->getY() + pointC->getY()) / 4.0f);
return Ref<Point>(new Point(cx, cy));
return QSharedPointer<Point>(new Point(cx, cy));
}
Ref<BitMatrix> Detector::sampleGrid(Ref<zxing::BitMatrix> image,
Ref<zxing::ResultPoint> topLeft,
Ref<zxing::ResultPoint> bottomLeft,
Ref<zxing::ResultPoint> bottomRight,
Ref<zxing::ResultPoint> topRight) {
QSharedPointer<BitMatrix> Detector::sampleGrid(QSharedPointer<zxing::BitMatrix> image,
QSharedPointer<zxing::ResultPoint> topLeft,
QSharedPointer<zxing::ResultPoint> bottomLeft,
QSharedPointer<zxing::ResultPoint> bottomRight,
QSharedPointer<zxing::ResultPoint> topRight) {
int dimension;
if (compact_) {
dimension = 4 * nbLayers_+11;
@ -390,7 +390,7 @@ Ref<BitMatrix> Detector::sampleGrid(Ref<zxing::BitMatrix> image,
bottomLeft->getY());
}
void Detector::getParameters(Ref<zxing::BitArray> parameterData) {
void Detector::getParameters(QSharedPointer<zxing::BitArray> parameterData) {
nbLayers_ = 0;
nbDataBlocks_ = 0;
@ -423,8 +423,8 @@ void Detector::getParameters(Ref<zxing::BitArray> parameterData) {
nbDataBlocks_++;
}
Ref<BitArray> Detector::sampleLine(Ref<zxing::aztec::Point> p1, Ref<zxing::aztec::Point> p2, int size) {
Ref<BitArray> res(new BitArray(size));
QSharedPointer<BitArray> Detector::sampleLine(QSharedPointer<zxing::aztec::Point> p1, QSharedPointer<zxing::aztec::Point> p2, int size) {
QSharedPointer<BitArray> res(new BitArray(size));
float d = distance(p1, p2);
float moduleSize = d / (size-1);
@ -443,10 +443,10 @@ Ref<BitArray> Detector::sampleLine(Ref<zxing::aztec::Point> p1, Ref<zxing::aztec
return res;
}
bool Detector::isWhiteOrBlackRectangle(Ref<zxing::aztec::Point> p1,
Ref<zxing::aztec::Point> p2,
Ref<zxing::aztec::Point> p3,
Ref<zxing::aztec::Point> p4) {
bool Detector::isWhiteOrBlackRectangle(QSharedPointer<zxing::aztec::Point> p1,
QSharedPointer<zxing::aztec::Point> p2,
QSharedPointer<zxing::aztec::Point> p3,
QSharedPointer<zxing::aztec::Point> p4) {
int corr = 3;
p1 = new Point(p1->getX() - corr, p1->getY() + corr);
@ -481,7 +481,7 @@ bool Detector::isWhiteOrBlackRectangle(Ref<zxing::aztec::Point> p1,
return true;
}
int Detector::getColor(Ref<zxing::aztec::Point> p1, Ref<zxing::aztec::Point> p2) {
int Detector::getColor(QSharedPointer<zxing::aztec::Point> p1, QSharedPointer<zxing::aztec::Point> p2) {
float d = distance(p1, p2);
float dx = (p2->getX() - p1->getX()) / d;
@ -512,7 +512,7 @@ int Detector::getColor(Ref<zxing::aztec::Point> p1, Ref<zxing::aztec::Point> p2)
return (errRatio <= 0.1) == colorModel ? 1 : -1;
}
Ref<Point> Detector::getFirstDifferent(Ref<zxing::aztec::Point> init, bool color, int dx, int dy) {
QSharedPointer<Point> Detector::getFirstDifferent(QSharedPointer<zxing::aztec::Point> init, bool color, int dx, int dy) {
int x = init->getX() + dx;
int y = init->getY() + dy;
@ -536,13 +536,13 @@ Ref<Point> Detector::getFirstDifferent(Ref<zxing::aztec::Point> init, bool color
y -= dy;
return Ref<Point>(new Point(x, y));
return QSharedPointer<Point>(new Point(x, y));
}
bool Detector::isValid(int x, int y) {
return x >= 0 && x < (int)image_->getWidth() && y > 0 && y < (int)image_->getHeight();
}
float Detector::distance(Ref<zxing::aztec::Point> a, Ref<zxing::aztec::Point> b) {
float Detector::distance(QSharedPointer<zxing::aztec::Point> a, QSharedPointer<zxing::aztec::Point> b) {
return sqrtf((float)((a->getX() - b->getX()) * (a->getX() - b->getX()) + (a->getY() - b->getY()) * (a->getY() - b->getY())));
}

View File

@ -33,14 +33,14 @@
namespace zxing {
namespace aztec {
class Point : public Counted {
class Point {
private:
const int x;
const int y;
public:
Ref<ResultPoint> toResultPoint() {
return Ref<ResultPoint>(new ResultPoint(float(x), float(y)));
QSharedPointer<ResultPoint> toResultPoint() {
return QSharedPointer<ResultPoint>(new ResultPoint(float(x), float(y)));
}
Point(int ax, int ay) : x(ax), y(ay) {}
@ -49,10 +49,10 @@ class Point : public Counted {
int getY() const { return y; }
};
class Detector : public Counted {
class Detector {
private:
Ref<BitMatrix> image_;
QSharedPointer<BitMatrix> image_;
bool compact_;
int nbLayers_;
@ -60,30 +60,30 @@ class Detector : public Counted {
int nbCenterLayers_;
int shift_;
void extractParameters(std::vector<Ref<Point> > bullEyeCornerPoints);
QSharedPointer<std::vector<Ref<ResultPoint>> > getMatrixCornerPoints(std::vector<Ref<Point> > bullEyeCornerPoints);
static void correctParameterData(Ref<BitArray> parameterData, bool compact);
std::vector<Ref<Point> > getBullEyeCornerPoints(Ref<Point> pCenter);
Ref<Point> getMatrixCenter();
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image,
Ref<ResultPoint> topLeft,
Ref<ResultPoint> bottomLeft,
Ref<ResultPoint> bottomRight,
Ref<ResultPoint> topRight);
void getParameters(Ref<BitArray> parameterData);
Ref<BitArray> sampleLine(Ref<Point> p1, Ref<Point> p2, int size);
bool isWhiteOrBlackRectangle(Ref<Point> p1,
Ref<Point> p2,
Ref<Point> p3,
Ref<Point> p4);
int getColor(Ref<Point> p1, Ref<Point> p2);
Ref<Point> getFirstDifferent(Ref<Point> init, bool color, int dx, int dy);
void extractParameters(std::vector<QSharedPointer<Point> > bullEyeCornerPoints);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > getMatrixCornerPoints(std::vector<QSharedPointer<Point> > bullEyeCornerPoints);
static void correctParameterData(QSharedPointer<BitArray> parameterData, bool compact);
std::vector<QSharedPointer<Point> > getBullEyeCornerPoints(QSharedPointer<Point> pCenter);
QSharedPointer<Point> getMatrixCenter();
QSharedPointer<BitMatrix> sampleGrid(QSharedPointer<BitMatrix> image,
QSharedPointer<ResultPoint> topLeft,
QSharedPointer<ResultPoint> bottomLeft,
QSharedPointer<ResultPoint> bottomRight,
QSharedPointer<ResultPoint> topRight);
void getParameters(QSharedPointer<BitArray> parameterData);
QSharedPointer<BitArray> sampleLine(QSharedPointer<Point> p1, QSharedPointer<Point> p2, int size);
bool isWhiteOrBlackRectangle(QSharedPointer<Point> p1,
QSharedPointer<Point> p2,
QSharedPointer<Point> p3,
QSharedPointer<Point> p4);
int getColor(QSharedPointer<Point> p1, QSharedPointer<Point> p2);
QSharedPointer<Point> getFirstDifferent(QSharedPointer<Point> init, bool color, int dx, int dy);
bool isValid(int x, int y);
static float distance(Ref<Point> a, Ref<Point> b);
static float distance(QSharedPointer<Point> a, QSharedPointer<Point> b);
public:
Detector(Ref<BitMatrix> image);
Ref<AztecDetectorResult> detect();
Detector(QSharedPointer<BitMatrix> image);
QSharedPointer<AztecDetectorResult> detect();
};
}

View File

@ -28,7 +28,7 @@
//namespace zxing {
//template<typename T> class Array : public Counted {
//template<typename T> class Array {
//protected:
//public:
// std::vector<T> values_;
@ -87,7 +87,7 @@
// }
//};
//template<typename T> class ArrayRef : public Counted {
//template<typename T> class ArrayRef {
//private:
//public:
// std::vector<T> *array_;

View File

@ -145,7 +145,7 @@ void BitArray::reverse()
bits = newBits;
}
BitArray::Reverse::Reverse(Ref<BitArray> array_) : array(array_) {
BitArray::Reverse::Reverse(QSharedPointer<BitArray> array_) : array(array_) {
array->reverse();
}

View File

@ -28,7 +28,7 @@
namespace zxing {
class BitArray : public Counted {
class BitArray {
public:
static const int bitsPerWord = std::numeric_limits<unsigned int>::digits;
@ -86,9 +86,9 @@ public:
class Reverse {
private:
Ref<BitArray> array;
QSharedPointer<BitArray> array;
public:
Reverse(Ref<BitArray> array);
Reverse(QSharedPointer<BitArray> array);
~Reverse();
};

View File

@ -59,8 +59,8 @@ void BitMatrix::rotate180()
{
int width = getWidth();
int height = getHeight();
Ref<BitArray> topRow( new BitArray(width) );
Ref<BitArray> bottomRow( new BitArray(width) );
QSharedPointer<BitArray> topRow( new BitArray(width) );
QSharedPointer<BitArray> bottomRow( new BitArray(width) );
for (int i = 0; i < (height+1) / 2; i++) {
getRow(i, topRow);
bottomRow = getRow(height - 1 - i, bottomRow);
@ -91,7 +91,7 @@ void BitMatrix::setRegion(int left, int top, int width, int height) {
}
}
Ref<BitArray> BitMatrix::getRow(int y, Ref<BitArray> row) {
QSharedPointer<BitArray> BitMatrix::getRow(int y, QSharedPointer<BitArray> row) {
if (row.empty() || row->getSize() < width) {
row = new BitArray(width);
}
@ -102,7 +102,7 @@ Ref<BitArray> BitMatrix::getRow(int y, Ref<BitArray> row) {
return row;
}
void BitMatrix::setRow(int y, Ref<zxing::BitArray> row)
void BitMatrix::setRow(int y, QSharedPointer<zxing::BitArray> row)
{
if (y < 0 || y >= bits->size() ||
row->getSize() != width)

View File

@ -28,7 +28,7 @@
namespace zxing {
class BitMatrix : public Counted {
class BitMatrix {
public:
static const int bitsPerWord = std::numeric_limits<unsigned int>::digits;
@ -59,8 +59,8 @@ public:
void clear();
void setRegion(int left, int top, int width, int height);
Ref<BitArray> getRow(int y, Ref<BitArray> row);
void setRow(int y, Ref<BitArray> row);
QSharedPointer<BitArray> getRow(int y, QSharedPointer<BitArray> row);
void setRow(int y, QSharedPointer<BitArray> row);
int getWidth() const;
int getHeight() const;

View File

@ -33,7 +33,7 @@ namespace zxing {
* @author srowen@google.com (Sean Owen)
* @author christian.brunschen@gmail.com (Christian Brunschen)
*/
class BitSource : public Counted {
class BitSource {
private:
QSharedPointer<std::vector<zxing::byte>> bytes_;
int byteOffset_;

View File

@ -27,7 +27,7 @@
namespace zxing {
namespace common {
class CharacterSetECI : public Counted {
class CharacterSetECI {
private:
static std::map<int, CharacterSetECI*> VALUE_TO_ECI;
static std::map<std::string, CharacterSetECI*> NAME_TO_ECI;

View File

@ -19,110 +19,111 @@
*/
#include <iostream>
#include <QSharedPointer>
namespace zxing {
//namespace zxing {
/* base class for reference-counted objects */
class Counted {
private:
size_t count_;
public:
Counted();
///* base class for reference-counted objects */
//class Counted {
//private:
// size_t count_;
//public:
// Counted();
virtual ~Counted();
// virtual ~Counted();
Counted *retain();
// Counted *retain();
void release();
// void release();
/* return the current count for denugging purposes or similar */
size_t count() const;
};
// /* return the current count for denugging purposes or similar */
// size_t count() const;
//};
/* counting reference to reference-counted objects */
template<typename T> class Ref {
private:
public:
T *object_;
explicit Ref(T *o = 0) :
object_(0) {
reset(o);
}
Ref(const Ref &other) :
object_(0) {
reset(other.object_);
}
///* counting reference to reference-counted objects */
//template<typename T> class Ref {
//private:
//public:
// T *object_;
// explicit Ref(T *o = 0) :
// object_(0) {
// reset(o);
// }
// Ref(const Ref &other) :
// object_(0) {
// reset(other.object_);
// }
template<class Y>
Ref(const Ref<Y> &other) :
object_(0) {
reset(other.object_);
}
// template<class Y>
// Ref(const QSharedPointer<Y> &other) :
// object_(0) {
// reset(other.object_);
// }
~Ref() {
if (object_) {
object_->release();
}
}
// ~Ref() {
// if (object_) {
// object_->release();
// }
// }
void reset(T *o) {
if (o) {
o->retain();
}
if (object_ != 0) {
object_->release();
}
object_ = o;
}
Ref& operator=(const Ref &other) {
reset(other.object_);
return *this;
}
template<class Y>
Ref& operator=(const Ref<Y> &other) {
reset(other.object_);
return *this;
}
Ref& operator=(T* o) {
reset(o);
return *this;
}
template<class Y>
Ref& operator=(Y* o) {
reset(o);
return *this;
}
// void reset(T *o) {
// if (o) {
// o->retain();
// }
// if (object_ != 0) {
// object_->release();
// }
// object_ = o;
// }
// Ref& operator=(const Ref &other) {
// reset(other.object_);
// return *this;
// }
// template<class Y>
// Ref& operator=(const QSharedPointer<Y> &other) {
// reset(other.object_);
// return *this;
// }
// Ref& operator=(T* o) {
// reset(o);
// return *this;
// }
// template<class Y>
// Ref& operator=(Y* o) {
// reset(o);
// return *this;
// }
T& operator*() {
return *object_;
}
T* operator->() const {
return object_;
}
operator T*() const {
return object_;
}
// 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<class Y>
bool operator==(const Ref<Y> &other) const {
return object_ == other.object_ || *object_ == *(other.object_);
}
// bool operator==(const T* that) {
// return object_ == that;
// }
// bool operator==(const Ref &other) const {
// return object_ == other.object_ || *object_ == *(other.object_);
// }
// template<class Y>
// bool operator==(const QSharedPointer<Y> &other) const {
// return object_ == other.object_ || *object_ == *(other.object_);
// }
bool operator!=(const T* that) {
return !(*this == that);
}
// bool operator!=(const T* that) {
// return !(*this == that);
// }
bool empty() const {
return object_ == 0;
}
};
// bool empty() const {
// return object_ == 0;
// }
//};
}
//}
#endif // ZXING_COUNTED_H

View File

@ -25,7 +25,7 @@ using namespace std;
using namespace zxing;
DecoderResult::DecoderResult(QSharedPointer<std::vector<zxing::byte>> rawBytes,
Ref<String> text,
QSharedPointer<String> text,
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>> >& byteSegments,
string const& ecLevel, string charSet) :
rawBytes_(rawBytes),
@ -34,14 +34,14 @@ DecoderResult::DecoderResult(QSharedPointer<std::vector<zxing::byte>> rawBytes,
ecLevel_(ecLevel), charSet_(charSet) {}
DecoderResult::DecoderResult(QSharedPointer<std::vector<zxing::byte>> rawBytes,
Ref<String> text)
QSharedPointer<String> text)
: rawBytes_(rawBytes), text_(text),charSet_("") {}
QSharedPointer<std::vector<zxing::byte>> DecoderResult::getRawBytes() {
return rawBytes_;
}
Ref<String> DecoderResult::getText() {
QSharedPointer<String> DecoderResult::getText() {
return text_;
}

View File

@ -28,25 +28,25 @@
namespace zxing {
class DecoderResult : public Counted {
class DecoderResult {
private:
QSharedPointer<std::vector<zxing::byte>> rawBytes_;
Ref<String> text_;
QSharedPointer<String> text_;
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>> > byteSegments_;
std::string ecLevel_;
std::string charSet_;
public:
DecoderResult(QSharedPointer<std::vector<zxing::byte>> rawBytes,
Ref<String> text,
QSharedPointer<String> text,
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>> >& byteSegments,
std::string const& ecLevel,
std::string charSet = "");
DecoderResult(QSharedPointer<std::vector<zxing::byte>> rawBytes, Ref<String> text);
DecoderResult(QSharedPointer<std::vector<zxing::byte>> rawBytes, QSharedPointer<String> text);
QSharedPointer<std::vector<zxing::byte>> getRawBytes();
Ref<String> getText();
QSharedPointer<String> getText();
std::string charSet();
};

View File

@ -23,16 +23,16 @@
namespace zxing {
DetectorResult::DetectorResult(Ref<BitMatrix> bits,
QSharedPointer<std::vector<Ref<ResultPoint>> > points)
DetectorResult::DetectorResult(QSharedPointer<BitMatrix> bits,
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points)
: bits_(bits), points_(points) {
}
Ref<BitMatrix> DetectorResult::getBits() {
QSharedPointer<BitMatrix> DetectorResult::getBits() {
return bits_;
}
QSharedPointer<std::vector<Ref<ResultPoint>> > DetectorResult::getPoints() {
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > DetectorResult::getPoints() {
return points_;
}

View File

@ -27,15 +27,15 @@
namespace zxing {
class DetectorResult : public Counted {
class DetectorResult {
private:
Ref<BitMatrix> bits_;
QSharedPointer<std::vector<Ref<ResultPoint>> > points_;
QSharedPointer<BitMatrix> bits_;
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points_;
public:
DetectorResult(Ref<BitMatrix> bits, QSharedPointer<std::vector<Ref<ResultPoint>> > points);
Ref<BitMatrix> getBits();
QSharedPointer<std::vector<Ref<ResultPoint>> > getPoints();
DetectorResult(QSharedPointer<BitMatrix> bits, QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points);
QSharedPointer<BitMatrix> getBits();
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > getPoints();
};
}

View File

@ -38,7 +38,7 @@ const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
const QSharedPointer<std::vector<zxing::byte>> EMPTY (0);
GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref<LuminanceSource> source)
GlobalHistogramBinarizer::GlobalHistogramBinarizer(QSharedPointer<LuminanceSource> source)
: Binarizer(source), luminances(EMPTY), buckets(LUMINANCE_BUCKETS) {}
GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {}
@ -53,7 +53,7 @@ void GlobalHistogramBinarizer::initArrays(int luminanceSize) {
memset(&buckets[0], 0, sizeof(int) * LUMINANCE_BUCKETS);
}
Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
QSharedPointer<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, QSharedPointer<BitArray> row) {
// std::cerr << "gbr " << y << std::endl;
LuminanceSource& source = *getLuminanceSource();
int width = source.getWidth();
@ -95,11 +95,11 @@ Ref<BitArray> GlobalHistogramBinarizer::getBlackRow(int y, Ref<BitArray> row) {
return row;
}
Ref<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
QSharedPointer<BitMatrix> GlobalHistogramBinarizer::getBlackMatrix() {
LuminanceSource& source = *getLuminanceSource();
int width = source.getWidth();
int height = source.getHeight();
Ref<BitMatrix> matrix(new BitMatrix(width, height));
QSharedPointer<BitMatrix> matrix(new BitMatrix(width, height));
// Quickly calculates the histogram by sampling four rows from the image.
// This proved to be more robust on the blackbox tests than sampling a
@ -207,8 +207,8 @@ int GlobalHistogramBinarizer::estimateBlackPoint(QSharedPointer<std::vector<int>
return bestValley << LUMINANCE_SHIFT;
}
Ref<Binarizer> GlobalHistogramBinarizer::createBinarizer(Ref<LuminanceSource> source) {
return Ref<Binarizer> (new GlobalHistogramBinarizer(source));
QSharedPointer<Binarizer> GlobalHistogramBinarizer::createBinarizer(QSharedPointer<LuminanceSource> source) {
return QSharedPointer<Binarizer> (new GlobalHistogramBinarizer(source));
}
}

View File

@ -32,13 +32,13 @@ private:
QSharedPointer<std::vector<zxing::byte>> luminances;
QSharedPointer<std::vector<int>> buckets;
public:
GlobalHistogramBinarizer(Ref<LuminanceSource> source);
GlobalHistogramBinarizer(QSharedPointer<LuminanceSource> source);
virtual ~GlobalHistogramBinarizer();
virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
virtual Ref<BitMatrix> getBlackMatrix();
virtual QSharedPointer<BitArray> getBlackRow(int y, QSharedPointer<BitArray> row);
virtual QSharedPointer<BitMatrix> getBlackMatrix();
static int estimateBlackPoint(QSharedPointer<std::vector<int>> const& buckets);
Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source);
QSharedPointer<Binarizer> createBinarizer(QSharedPointer<LuminanceSource> source);
private:
void initArrays(int luminanceSize);
};

View File

@ -69,10 +69,10 @@ QSharedPointer<std::vector<zxing::byte>> GreyscaleLuminanceSource::getMatrix() c
return result;
}
Ref<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() const {
QSharedPointer<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() const {
// Intentionally flip the left, top, width, and height arguments as
// needed. dataWidth and dataHeight are always kept unrotated.
Ref<LuminanceSource> result (
QSharedPointer<LuminanceSource> result (
new GreyscaleRotatedLuminanceSource(greyData_,
dataWidth_, dataHeight_,
top_, left_, getHeight(), getWidth()));

View File

@ -45,7 +45,7 @@ public:
return true;
}
Ref<LuminanceSource> rotateCounterClockwise() const;
QSharedPointer<LuminanceSource> rotateCounterClockwise() const;
};
}

View File

@ -32,8 +32,8 @@ GridSampler GridSampler::gridSampler;
GridSampler::GridSampler() {
}
Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform> transform) {
Ref<BitMatrix> bits(new BitMatrix(dimension));
QSharedPointer<BitMatrix> GridSampler::sampleGrid(QSharedPointer<BitMatrix> image, int dimension, QSharedPointer<PerspectiveTransform> transform) {
QSharedPointer<BitMatrix> bits(new BitMatrix(dimension));
vector<float> points(dimension << 1, 0.0f);
for (int y = 0; y < dimension; y++) {
int max = int(points.size());
@ -53,8 +53,8 @@ Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimension, Ref<
return bits;
}
Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimensionX, int dimensionY, Ref<PerspectiveTransform> transform) {
Ref<BitMatrix> bits(new BitMatrix(dimensionX, dimensionY));
QSharedPointer<BitMatrix> GridSampler::sampleGrid(QSharedPointer<BitMatrix> image, int dimensionX, int dimensionY, QSharedPointer<PerspectiveTransform> transform) {
QSharedPointer<BitMatrix> bits(new BitMatrix(dimensionX, dimensionY));
vector<float> points(dimensionX << 1, 0.0f);
for (int y = 0; y < dimensionY; y++) {
int max = int(points.size());
@ -74,17 +74,17 @@ Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimensionX, int
return bits;
}
Ref<BitMatrix> GridSampler::sampleGrid(Ref<BitMatrix> image, int dimension, float p1ToX, float p1ToY, float p2ToX,
QSharedPointer<BitMatrix> GridSampler::sampleGrid(QSharedPointer<BitMatrix> 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) {
Ref<PerspectiveTransform> transform(PerspectiveTransform::quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY,
QSharedPointer<PerspectiveTransform> transform(PerspectiveTransform::quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY,
p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY));
return sampleGrid(image, dimension, transform);
}
void GridSampler::checkAndNudgePoints(Ref<BitMatrix> image, vector<float> &points) {
void GridSampler::checkAndNudgePoints(QSharedPointer<BitMatrix> image, vector<float> &points) {
int width = image->getWidth();
int height = image->getHeight();

View File

@ -31,13 +31,13 @@ private:
GridSampler();
public:
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform> transform);
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimensionX, int dimensionY, Ref<PerspectiveTransform> transform);
QSharedPointer<BitMatrix> sampleGrid(QSharedPointer<BitMatrix> image, int dimension, QSharedPointer<PerspectiveTransform> transform);
QSharedPointer<BitMatrix> sampleGrid(QSharedPointer<BitMatrix> image, int dimensionX, int dimensionY, QSharedPointer<PerspectiveTransform> transform);
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, float p1ToX, float p1ToY, float p2ToX, float p2ToY,
QSharedPointer<BitMatrix> sampleGrid(QSharedPointer<BitMatrix> 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<BitMatrix> image, std::vector<float> &points);
static void checkAndNudgePoints(QSharedPointer<BitMatrix> image, std::vector<float> &points);
static GridSampler &getInstance();
};
}

View File

@ -32,7 +32,7 @@ namespace {
const int MINIMUM_DIMENSION = BLOCK_SIZE * 5;
}
HybridBinarizer::HybridBinarizer(Ref<LuminanceSource> source) :
HybridBinarizer::HybridBinarizer(QSharedPointer<LuminanceSource> source) :
GlobalHistogramBinarizer(source), matrix_(NULL), cached_row_(NULL) {
}
@ -40,9 +40,9 @@ HybridBinarizer::~HybridBinarizer() {
}
Ref<Binarizer>
HybridBinarizer::createBinarizer(Ref<LuminanceSource> source) {
return Ref<Binarizer> (new HybridBinarizer(source));
QSharedPointer<Binarizer>
HybridBinarizer::createBinarizer(QSharedPointer<LuminanceSource> source) {
return QSharedPointer<Binarizer> (new HybridBinarizer(source));
}
@ -51,7 +51,7 @@ HybridBinarizer::createBinarizer(Ref<LuminanceSource> source) {
* constructor instead, but there are some advantages to doing it lazily, such as making
* profiling easier, and not doing heavy lifting when callers don't expect it.
*/
Ref<BitMatrix> HybridBinarizer::getBlackMatrix() {
QSharedPointer<BitMatrix> HybridBinarizer::getBlackMatrix() {
if (matrix_) {
return matrix_;
}
@ -71,7 +71,7 @@ Ref<BitMatrix> HybridBinarizer::getBlackMatrix() {
QSharedPointer<std::vector<int>> blackPoints =
calculateBlackPoints(luminances, subWidth, subHeight, width, height);
Ref<BitMatrix> newMatrix (new BitMatrix(width, height));
QSharedPointer<BitMatrix> newMatrix (new BitMatrix(width, height));
calculateThresholdForBlock(luminances,
subWidth,
subHeight,
@ -100,7 +100,7 @@ HybridBinarizer::calculateThresholdForBlock(QSharedPointer<std::vector<zxing::by
int width,
int height,
QSharedPointer<std::vector<int>> blackPoints,
Ref<BitMatrix> const& matrix) {
QSharedPointer<BitMatrix> const& matrix) {
for (int y = 0; y < subHeight; y++) {
int yoffset = y << BLOCK_SIZE_POWER;
int maxYOffset = height - BLOCK_SIZE;
@ -135,7 +135,7 @@ void HybridBinarizer::thresholdBlock(QSharedPointer<std::vector<zxing::byte>> lu
int yoffset,
int threshold,
int stride,
Ref<BitMatrix> const& matrix) {
QSharedPointer<BitMatrix> const& matrix) {
for (int y = 0, offset = yoffset * stride + xoffset;
y < BLOCK_SIZE;
y++, offset += stride) {

View File

@ -30,15 +30,15 @@ namespace zxing {
class HybridBinarizer : public GlobalHistogramBinarizer {
private:
Ref<BitMatrix> matrix_;
Ref<BitArray> cached_row_;
QSharedPointer<BitMatrix> matrix_;
QSharedPointer<BitArray> cached_row_;
public:
HybridBinarizer(Ref<LuminanceSource> source);
HybridBinarizer(QSharedPointer<LuminanceSource> source);
virtual ~HybridBinarizer();
virtual Ref<BitMatrix> getBlackMatrix();
Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source);
virtual QSharedPointer<BitMatrix> getBlackMatrix();
QSharedPointer<Binarizer> createBinarizer(QSharedPointer<LuminanceSource> source);
private:
// We'll be using one-D arrays because C++ can't dynamically allocate 2D
// arrays
@ -53,13 +53,13 @@ namespace zxing {
int width,
int height,
QSharedPointer<std::vector<int>> blackPoints,
Ref<BitMatrix> const& matrix);
QSharedPointer<BitMatrix> const& matrix);
void thresholdBlock(QSharedPointer<std::vector<zxing::byte>>luminances,
int xoffset,
int yoffset,
int threshold,
int stride,
Ref<BitMatrix> const& matrix);
QSharedPointer<BitMatrix> const& matrix);
};
}

View File

@ -31,20 +31,20 @@ PerspectiveTransform::PerspectiveTransform(float inA11, float inA21,
a11(inA11), a12(inA12), a13(inA13), a21(inA21), a22(inA22), a23(inA23),
a31(inA31), a32(inA32), a33(inA33) {}
Ref<PerspectiveTransform> PerspectiveTransform::quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1,
QSharedPointer<PerspectiveTransform> PerspectiveTransform::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) {
Ref<PerspectiveTransform> qToS = PerspectiveTransform::quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
Ref<PerspectiveTransform> sToQ =
QSharedPointer<PerspectiveTransform> qToS = PerspectiveTransform::quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
QSharedPointer<PerspectiveTransform> sToQ =
PerspectiveTransform::squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
return sToQ->times(qToS);
}
Ref<PerspectiveTransform> PerspectiveTransform::squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2,
QSharedPointer<PerspectiveTransform> PerspectiveTransform::squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2,
float y2, float x3, float y3) {
float dx3 = x0 - x1 + x2 - x3;
float dy3 = y0 - y1 + y2 - y3;
Ref<PerspectiveTransform> result;
QSharedPointer<PerspectiveTransform> result;
if (dx3 == 0.0f && dy3 == 0.0f) {
result = new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0f,
0.0f, 1.0f);
@ -65,22 +65,22 @@ Ref<PerspectiveTransform> PerspectiveTransform::squareToQuadrilateral(float x0,
return result;
}
Ref<PerspectiveTransform> PerspectiveTransform::quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2,
QSharedPointer<PerspectiveTransform> PerspectiveTransform::quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2,
float y2, float x3, float y3) {
// Here, the adjoint serves as the inverse:
return squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)->buildAdjoint();
}
Ref<PerspectiveTransform> PerspectiveTransform::buildAdjoint() {
QSharedPointer<PerspectiveTransform> PerspectiveTransform::buildAdjoint() {
// Adjoint is the transpose of the cofactor matrix:
Ref<PerspectiveTransform> result(new PerspectiveTransform(a22 * a33 - a23 * a32, a23 * a31 - a21 * a33, a21 * a32
QSharedPointer<PerspectiveTransform> result(new PerspectiveTransform(a22 * a33 - a23 * a32, a23 * a31 - a21 * a33, a21 * a32
- a22 * a31, a13 * a32 - a12 * a33, a11 * a33 - a13 * a31, a12 * a31 - a11 * a32, a12 * a23 - a13 * a22,
a13 * a21 - a11 * a23, a11 * a22 - a12 * a21));
return result;
}
Ref<PerspectiveTransform> PerspectiveTransform::times(Ref<PerspectiveTransform> other) {
Ref<PerspectiveTransform> result(new PerspectiveTransform(a11 * other->a11 + a21 * other->a12 + a31 * other->a13,
QSharedPointer<PerspectiveTransform> PerspectiveTransform::times(QSharedPointer<PerspectiveTransform> other) {
QSharedPointer<PerspectiveTransform> result(new PerspectiveTransform(a11 * other->a11 + a21 * other->a12 + a31 * other->a13,
a11 * other->a21 + a21 * other->a22 + a31 * other->a23, a11 * other->a31 + a21 * other->a32 + a31
* other->a33, a12 * other->a11 + a22 * other->a12 + a32 * other->a13, a12 * other->a21 + a22
* other->a22 + a32 * other->a23, a12 * other->a31 + a22 * other->a32 + a32 * other->a33, a13

View File

@ -24,22 +24,22 @@
#include <vector>
namespace zxing {
class PerspectiveTransform : public Counted {
class PerspectiveTransform {
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<PerspectiveTransform>
static QSharedPointer<PerspectiveTransform>
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<PerspectiveTransform> squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2,
static QSharedPointer<PerspectiveTransform> squareToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2,
float x3, float y3);
static Ref<PerspectiveTransform> quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, float y2,
static QSharedPointer<PerspectiveTransform> quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, float y2,
float x3, float y3);
Ref<PerspectiveTransform> buildAdjoint();
Ref<PerspectiveTransform> times(Ref<PerspectiveTransform> other);
QSharedPointer<PerspectiveTransform> buildAdjoint();
QSharedPointer<PerspectiveTransform> times(QSharedPointer<PerspectiveTransform> other);
void transformPoints(std::vector<float> &points);
friend std::ostream& operator<<(std::ostream& out, const PerspectiveTransform &pt);

View File

@ -43,8 +43,8 @@ int String::size() const { return int(text_.size()); }
int String::length() const { return int(text_.size()); }
Ref<String> String::substring(int i, int j) const {
return Ref<String>(new String(text_.substr(i, j)));
QSharedPointer<String> String::substring(int i, int j) const {
return QSharedPointer<String>(new String(text_.substr(i, j)));
}
void String::append(const std::string &tail) {

View File

@ -30,14 +30,14 @@ namespace zxing {
class String;
std::ostream& operator << (std::ostream& out, String const& s);
class String : public Counted {
class String {
private:
std::string text_;
public:
explicit String(const std::string &text);
explicit String(int);
char charAt(int) const;
Ref<String> substring(int, int = -1) const;
QSharedPointer<String> substring(int, int = -1) const;
const std::string& getText() const;
int size() const;
void append(std::string const& tail);

View File

@ -30,7 +30,7 @@ using zxing::ResultPoint;
using zxing::TwoInts;
using zxing::MonochromeRectangleDetector;
vector<Ref<ResultPoint> > MonochromeRectangleDetector::detect() {
vector<QSharedPointer<ResultPoint> > MonochromeRectangleDetector::detect() {
int height = image_->getHeight();
int width = image_->getWidth();
int halfHeight = height >> 1;
@ -42,16 +42,16 @@ vector<Ref<ResultPoint> > MonochromeRectangleDetector::detect() {
int bottom = height;
int left = 0;
int right = width;
Ref<ResultPoint> pointA(findCornerFromCenter(halfWidth, 0, left, right,
QSharedPointer<ResultPoint> pointA(findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, -deltaY, top, bottom, halfWidth >> 1));
top = (int) pointA->getY() - 1;;
Ref<ResultPoint> pointB(findCornerFromCenter(halfWidth, -deltaX, left, right,
QSharedPointer<ResultPoint> pointB(findCornerFromCenter(halfWidth, -deltaX, left, right,
halfHeight, 0, top, bottom, halfHeight >> 1));
left = (int) pointB->getX() - 1;
Ref<ResultPoint> pointC(findCornerFromCenter(halfWidth, deltaX, left, right,
QSharedPointer<ResultPoint> pointC(findCornerFromCenter(halfWidth, deltaX, left, right,
halfHeight, 0, top, bottom, halfHeight >> 1));
right = (int) pointC->getX() + 1;
Ref<ResultPoint> pointD(findCornerFromCenter(halfWidth, 0, left, right,
QSharedPointer<ResultPoint> pointD(findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, deltaY, top, bottom, halfWidth >> 1));
bottom = (int) pointD->getY() + 1;
@ -59,7 +59,7 @@ vector<Ref<ResultPoint> > MonochromeRectangleDetector::detect() {
pointA.reset(findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, -deltaY, top, bottom, halfWidth >> 2));
vector<Ref<ResultPoint> > corners(4);
vector<QSharedPointer<ResultPoint> > corners(4);
corners[0].reset(pointA);
corners[1].reset(pointB);
corners[2].reset(pointC);
@ -67,13 +67,13 @@ vector<Ref<ResultPoint> > MonochromeRectangleDetector::detect() {
return corners;
}
Ref<ResultPoint> MonochromeRectangleDetector::findCornerFromCenter(int centerX, int deltaX, int left, int right,
QSharedPointer<ResultPoint> MonochromeRectangleDetector::findCornerFromCenter(int centerX, int deltaX, int left, int right,
int centerY, int deltaY, int top, int bottom, int maxWhiteRun) {
Ref<TwoInts> lastRange(NULL);
QSharedPointer<TwoInts> lastRange(NULL);
for (int y = centerY, x = centerX;
y < bottom && y >= top && x < right && x >= left;
y += deltaY, x += deltaX) {
Ref<TwoInts> range(NULL);
QSharedPointer<TwoInts> range(NULL);
if (deltaX == 0) {
// horizontal slices, up and down
range = blackWhiteRange(y, maxWhiteRun, left, right, true);
@ -91,26 +91,26 @@ Ref<ResultPoint> MonochromeRectangleDetector::findCornerFromCenter(int centerX,
if (lastRange->start < centerX) {
if (lastRange->end > centerX) {
// straddle, choose one or the other based on direction
Ref<ResultPoint> result(new ResultPoint(deltaY > 0 ? lastRange->start : lastRange->end, lastY));
QSharedPointer<ResultPoint> result(new ResultPoint(deltaY > 0 ? lastRange->start : lastRange->end, lastY));
return result;
}
Ref<ResultPoint> result(new ResultPoint(lastRange->start, lastY));
QSharedPointer<ResultPoint> result(new ResultPoint(lastRange->start, lastY));
return result;
} else {
Ref<ResultPoint> result(new ResultPoint(lastRange->end, lastY));
QSharedPointer<ResultPoint> result(new ResultPoint(lastRange->end, lastY));
return result;
}
} else {
int lastX = x - deltaX;
if (lastRange->start < centerY) {
if (lastRange->end > centerY) {
Ref<ResultPoint> result(new ResultPoint(lastX, deltaX < 0 ? lastRange->start : lastRange->end));
QSharedPointer<ResultPoint> result(new ResultPoint(lastX, deltaX < 0 ? lastRange->start : lastRange->end));
return result;
}
Ref<ResultPoint> result(new ResultPoint(lastX, lastRange->start));
QSharedPointer<ResultPoint> result(new ResultPoint(lastX, lastRange->start));
return result;
} else {
Ref<ResultPoint> result(new ResultPoint(lastX, lastRange->end));
QSharedPointer<ResultPoint> result(new ResultPoint(lastX, lastRange->end));
return result;
}
}
@ -121,7 +121,7 @@ Ref<ResultPoint> MonochromeRectangleDetector::findCornerFromCenter(int centerX,
throw NotFoundException("Couldn't find corners");
}
Ref<TwoInts> MonochromeRectangleDetector::blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim,
QSharedPointer<TwoInts> MonochromeRectangleDetector::blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim,
bool horizontal) {
int center = (minDim + maxDim) >> 1;
@ -165,7 +165,7 @@ Ref<TwoInts> MonochromeRectangleDetector::blackWhiteRange(int fixedDimension, in
}
}
end--;
Ref<TwoInts> result(NULL);
QSharedPointer<TwoInts> result(NULL);
if (end > start) {
result = new TwoInts;
result->start = start;

View File

@ -32,26 +32,26 @@
namespace zxing {
struct TwoInts: public Counted {
struct TwoInts {
int start;
int end;
};
class MonochromeRectangleDetector : public Counted {
class MonochromeRectangleDetector {
private:
static const int MAX_MODULES = 32;
Ref<BitMatrix> image_;
QSharedPointer<BitMatrix> image_;
public:
MonochromeRectangleDetector(Ref<BitMatrix> image) : image_(image) { };
MonochromeRectangleDetector(QSharedPointer<BitMatrix> image) : image_(image) { };
std::vector<Ref<ResultPoint> > detect();
std::vector<QSharedPointer<ResultPoint> > detect();
private:
Ref<ResultPoint> findCornerFromCenter(int centerX, int deltaX, int left, int right,
QSharedPointer<ResultPoint> findCornerFromCenter(int centerX, int deltaX, int left, int right,
int centerY, int deltaY, int top, int bottom, int maxWhiteRun);
Ref<TwoInts> blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim,
QSharedPointer<TwoInts> blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim,
bool horizontal);
int max(int a, float b) { return (float) a > b ? a : (int) b;};

View File

@ -36,12 +36,12 @@ using zxing::BitMatrix;
int WhiteRectangleDetector::INIT_SIZE = 10;
int WhiteRectangleDetector::CORR = 1;
WhiteRectangleDetector::WhiteRectangleDetector(Ref<BitMatrix> image) :
WhiteRectangleDetector::WhiteRectangleDetector(QSharedPointer<BitMatrix> image) :
WhiteRectangleDetector(image, INIT_SIZE, image->getWidth() >> 1, image->getHeight() >> 1)
{
}
WhiteRectangleDetector::WhiteRectangleDetector(Ref<BitMatrix> image, int initSize, int x, int y) : image_(image) {
WhiteRectangleDetector::WhiteRectangleDetector(QSharedPointer<BitMatrix> image, int initSize, int x, int y) : image_(image) {
width_ = image->getWidth();
height_ = image->getHeight();
@ -63,14 +63,14 @@ WhiteRectangleDetector::WhiteRectangleDetector(Ref<BitMatrix> image, int initSiz
* region until it finds a white rectangular region.
* </p>
*
* @return {@link vector<Ref<ResultPoint> >} describing the corners of the rectangular
* @return {@link vector<QSharedPointer<ResultPoint> >} describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be
* leftmost and the third, the rightmost
* @throws NotFoundException if no Data Matrix Code can be found
*/
std::vector<Ref<ResultPoint> > WhiteRectangleDetector::detect() {
std::vector<QSharedPointer<ResultPoint> > WhiteRectangleDetector::detect() {
int left = leftInit_;
int right = rightInit_;
int up = upInit_;
@ -160,7 +160,7 @@ std::vector<Ref<ResultPoint> > WhiteRectangleDetector::detect() {
int maxSize = right - left;
Ref<ResultPoint> z(NULL);
QSharedPointer<ResultPoint> z(NULL);
//go up right
for (int i = 1; i < maxSize; i++) {
z = getBlackPointOnSegment(left, down - i, left + i, down);
@ -173,7 +173,7 @@ std::vector<Ref<ResultPoint> > WhiteRectangleDetector::detect() {
throw NotFoundException("z == NULL");
}
Ref<ResultPoint> t(NULL);
QSharedPointer<ResultPoint> t(NULL);
//go down right
for (int i = 1; i < maxSize; i++) {
t = getBlackPointOnSegment(left, up + i, left + i, up);
@ -186,7 +186,7 @@ std::vector<Ref<ResultPoint> > WhiteRectangleDetector::detect() {
throw NotFoundException("t == NULL");
}
Ref<ResultPoint> x(NULL);
QSharedPointer<ResultPoint> x(NULL);
//go down left
for (int i = 1; i < maxSize; i++) {
x = getBlackPointOnSegment(right, up + i, right - i, up);
@ -199,7 +199,7 @@ std::vector<Ref<ResultPoint> > WhiteRectangleDetector::detect() {
throw NotFoundException("x == NULL");
}
Ref<ResultPoint> y(NULL);
QSharedPointer<ResultPoint> y(NULL);
//go up left
for (int i = 1; i < maxSize; i++) {
y = getBlackPointOnSegment(right, down - i, right - i, down);
@ -219,7 +219,7 @@ std::vector<Ref<ResultPoint> > WhiteRectangleDetector::detect() {
}
}
Ref<ResultPoint>
QSharedPointer<ResultPoint>
WhiteRectangleDetector::getBlackPointOnSegment(int aX_, int aY_, int bX_, int bY_) {
float aX = float(aX_), aY = float(aY_), bX = float(bX_), bY = float(bY_);
int dist = MathUtils::round(MathUtils::distance(aX, aY, bX, bY));
@ -230,11 +230,11 @@ WhiteRectangleDetector::getBlackPointOnSegment(int aX_, int aY_, int bX_, int bY
int x = MathUtils::round(aX + i * xStep);
int y = MathUtils::round(aY + i * yStep);
if (image_->get(x, y)) {
Ref<ResultPoint> point(new ResultPoint(float(x), float(y)));
QSharedPointer<ResultPoint> point(new ResultPoint(float(x), float(y)));
return point;
}
}
Ref<ResultPoint> point(NULL);
QSharedPointer<ResultPoint> point(NULL);
return point;
}
@ -245,14 +245,14 @@ WhiteRectangleDetector::getBlackPointOnSegment(int aX_, int aY_, int bX_, int bY
* @param z left most point
* @param x right most point
* @param t top most point
* @return {@link vector<Ref<ResultPoint> >} describing the corners of the rectangular
* @return {@link vector<QSharedPointer<ResultPoint> >} describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be
* leftmost and the third, the rightmost
*/
vector<Ref<ResultPoint> > WhiteRectangleDetector::centerEdges(Ref<ResultPoint> y, Ref<ResultPoint> z,
Ref<ResultPoint> x, Ref<ResultPoint> t) {
vector<QSharedPointer<ResultPoint> > WhiteRectangleDetector::centerEdges(QSharedPointer<ResultPoint> y, QSharedPointer<ResultPoint> z,
QSharedPointer<ResultPoint> x, QSharedPointer<ResultPoint> t) {
//
// t t
@ -270,21 +270,21 @@ vector<Ref<ResultPoint> > WhiteRectangleDetector::centerEdges(Ref<ResultPoint> y
float ti = t->getX();
float tj = t->getY();
std::vector<Ref<ResultPoint> > corners(4);
std::vector<QSharedPointer<ResultPoint> > corners(4);
if (yi < (float)width_/2.0f) {
Ref<ResultPoint> pointA(new ResultPoint(ti - CORR, tj + CORR));
Ref<ResultPoint> pointB(new ResultPoint(zi + CORR, zj + CORR));
Ref<ResultPoint> pointC(new ResultPoint(xi - CORR, xj - CORR));
Ref<ResultPoint> pointD(new ResultPoint(yi + CORR, yj - CORR));
QSharedPointer<ResultPoint> pointA(new ResultPoint(ti - CORR, tj + CORR));
QSharedPointer<ResultPoint> pointB(new ResultPoint(zi + CORR, zj + CORR));
QSharedPointer<ResultPoint> pointC(new ResultPoint(xi - CORR, xj - CORR));
QSharedPointer<ResultPoint> pointD(new ResultPoint(yi + CORR, yj - CORR));
corners[0].reset(pointA);
corners[1].reset(pointB);
corners[2].reset(pointC);
corners[3].reset(pointD);
} else {
Ref<ResultPoint> pointA(new ResultPoint(ti + CORR, tj + CORR));
Ref<ResultPoint> pointB(new ResultPoint(zi + CORR, zj - CORR));
Ref<ResultPoint> pointC(new ResultPoint(xi - CORR, xj + CORR));
Ref<ResultPoint> pointD(new ResultPoint(yi - CORR, yj - CORR));
QSharedPointer<ResultPoint> pointA(new ResultPoint(ti + CORR, tj + CORR));
QSharedPointer<ResultPoint> pointB(new ResultPoint(zi + CORR, zj - CORR));
QSharedPointer<ResultPoint> pointC(new ResultPoint(xi - CORR, xj + CORR));
QSharedPointer<ResultPoint> pointD(new ResultPoint(yi - CORR, yj - CORR));
corners[0].reset(pointA);
corners[1].reset(pointB);
corners[2].reset(pointC);

View File

@ -31,11 +31,11 @@
namespace zxing {
class WhiteRectangleDetector : public Counted {
class WhiteRectangleDetector {
private:
static int INIT_SIZE;
static int CORR;
Ref<BitMatrix> image_;
QSharedPointer<BitMatrix> image_;
int width_;
int height_;
int leftInit_;
@ -44,14 +44,14 @@ class WhiteRectangleDetector : public Counted {
int upInit_;
public:
WhiteRectangleDetector(Ref<BitMatrix> image);
WhiteRectangleDetector(Ref<BitMatrix> image, int initSize, int x, int y);
std::vector<Ref<ResultPoint> > detect();
WhiteRectangleDetector(QSharedPointer<BitMatrix> image);
WhiteRectangleDetector(QSharedPointer<BitMatrix> image, int initSize, int x, int y);
std::vector<QSharedPointer<ResultPoint> > detect();
private:
Ref<ResultPoint> getBlackPointOnSegment(int aX, int aY, int bX, int bY);
std::vector<Ref<ResultPoint> > centerEdges(Ref<ResultPoint> y, Ref<ResultPoint> z,
Ref<ResultPoint> x, Ref<ResultPoint> t);
QSharedPointer<ResultPoint> getBlackPointOnSegment(int aX, int aY, int bX, int bY);
std::vector<QSharedPointer<ResultPoint> > centerEdges(QSharedPointer<ResultPoint> y, QSharedPointer<ResultPoint> z,
QSharedPointer<ResultPoint> x, QSharedPointer<ResultPoint> t);
bool containsBlackPoint(int a, int b, int fixed, bool horizontal);
};
}

View File

@ -28,14 +28,14 @@ using zxing::GenericGF;
using zxing::GenericGFPoly;
using zxing::Ref;
Ref<GenericGF> GenericGF::AZTEC_DATA_12(new GenericGF(0x1069, 4096, 1));
Ref<GenericGF> GenericGF::AZTEC_DATA_10(new GenericGF(0x409, 1024, 1));
Ref<GenericGF> GenericGF::AZTEC_DATA_6(new GenericGF(0x43, 64, 1));
Ref<GenericGF> GenericGF::AZTEC_PARAM(new GenericGF(0x13, 16, 1));
Ref<GenericGF> GenericGF::QR_CODE_FIELD_256(new GenericGF(0x011D, 256, 0));
Ref<GenericGF> GenericGF::DATA_MATRIX_FIELD_256(new GenericGF(0x012D, 256, 1));
Ref<GenericGF> GenericGF::AZTEC_DATA_8 = DATA_MATRIX_FIELD_256;
Ref<GenericGF> GenericGF::MAXICODE_FIELD_64 = AZTEC_DATA_6;
QSharedPointer<GenericGF> GenericGF::AZTEC_DATA_12(new GenericGF(0x1069, 4096, 1));
QSharedPointer<GenericGF> GenericGF::AZTEC_DATA_10(new GenericGF(0x409, 1024, 1));
QSharedPointer<GenericGF> GenericGF::AZTEC_DATA_6(new GenericGF(0x43, 64, 1));
QSharedPointer<GenericGF> GenericGF::AZTEC_PARAM(new GenericGF(0x13, 16, 1));
QSharedPointer<GenericGF> GenericGF::QR_CODE_FIELD_256(new GenericGF(0x011D, 256, 0));
QSharedPointer<GenericGF> GenericGF::DATA_MATRIX_FIELD_256(new GenericGF(0x012D, 256, 1));
QSharedPointer<GenericGF> GenericGF::AZTEC_DATA_8 = DATA_MATRIX_FIELD_256;
QSharedPointer<GenericGF> GenericGF::MAXICODE_FIELD_64 = AZTEC_DATA_6;
namespace {
size_t INITIALIZATION_THRESHOLD = 0;
@ -77,8 +77,8 @@ void GenericGF::initialize() {
coefficients_zero[0] = 0;
coefficients_one[0] = 1;
zero = Ref<GenericGFPoly>(new GenericGFPoly(this, coefficients_zero));
one = Ref<GenericGFPoly>(new GenericGFPoly(this, coefficients_one));
zero = QSharedPointer<GenericGFPoly>(new GenericGFPoly(this, coefficients_zero));
one = QSharedPointer<GenericGFPoly>(new GenericGFPoly(this, coefficients_one));
initialized = true;
}
@ -88,17 +88,17 @@ void GenericGF::checkInit() {
}
}
Ref<GenericGFPoly> GenericGF::getZero() {
QSharedPointer<GenericGFPoly> GenericGF::getZero() {
checkInit();
return zero;
}
Ref<GenericGFPoly> GenericGF::getOne() {
QSharedPointer<GenericGFPoly> GenericGF::getOne() {
checkInit();
return one;
}
Ref<GenericGFPoly> GenericGF::buildMonomial(int degree, int coefficient) {
QSharedPointer<GenericGFPoly> GenericGF::buildMonomial(int degree, int coefficient) {
checkInit();
if (degree < 0) {
@ -110,7 +110,7 @@ Ref<GenericGFPoly> GenericGF::buildMonomial(int degree, int coefficient) {
QSharedPointer<std::vector<int>> coefficients(degree + 1);
coefficients[0] = coefficient;
return Ref<GenericGFPoly>(new GenericGFPoly(this, coefficients));
return QSharedPointer<GenericGFPoly>(new GenericGFPoly(this, coefficients));
}
int GenericGF::addOrSubtract(int a, int b) {

View File

@ -28,13 +28,13 @@
namespace zxing {
class GenericGFPoly;
class GenericGF : public Counted {
class GenericGF {
private:
std::vector<int> expTable;
std::vector<int> logTable;
Ref<GenericGFPoly> zero;
Ref<GenericGFPoly> one;
QSharedPointer<GenericGFPoly> zero;
QSharedPointer<GenericGFPoly> one;
size_t size;
int primitive;
int generatorBase;
@ -47,20 +47,20 @@ namespace zxing {
void checkInit();
public:
static Ref<GenericGF> AZTEC_DATA_12;
static Ref<GenericGF> AZTEC_DATA_10;
static Ref<GenericGF> AZTEC_DATA_8;
static Ref<GenericGF> AZTEC_DATA_6;
static Ref<GenericGF> AZTEC_PARAM;
static Ref<GenericGF> QR_CODE_FIELD_256;
static Ref<GenericGF> DATA_MATRIX_FIELD_256;
static Ref<GenericGF> MAXICODE_FIELD_64;
static QSharedPointer<GenericGF> AZTEC_DATA_12;
static QSharedPointer<GenericGF> AZTEC_DATA_10;
static QSharedPointer<GenericGF> AZTEC_DATA_8;
static QSharedPointer<GenericGF> AZTEC_DATA_6;
static QSharedPointer<GenericGF> AZTEC_PARAM;
static QSharedPointer<GenericGF> QR_CODE_FIELD_256;
static QSharedPointer<GenericGF> DATA_MATRIX_FIELD_256;
static QSharedPointer<GenericGF> MAXICODE_FIELD_64;
Ref<GenericGFPoly> getZero();
Ref<GenericGFPoly> getOne();
QSharedPointer<GenericGFPoly> getZero();
QSharedPointer<GenericGFPoly> getOne();
size_t getSize();
int getGeneratorBase();
Ref<GenericGFPoly> buildMonomial(int degree, int coefficient);
QSharedPointer<GenericGFPoly> buildMonomial(int degree, int coefficient);
static int addOrSubtract(int a, int b);
int exp(int a);

View File

@ -95,7 +95,7 @@ int GenericGFPoly::evaluateAt(int a) {
return result;
}
Ref<GenericGFPoly> GenericGFPoly::addOrSubtract(Ref<zxing::GenericGFPoly> other) {
QSharedPointer<GenericGFPoly> GenericGFPoly::addOrSubtract(QSharedPointer<zxing::GenericGFPoly> other) {
if (!(field_ == other->field_)) {
throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
}
@ -103,7 +103,7 @@ Ref<GenericGFPoly> GenericGFPoly::addOrSubtract(Ref<zxing::GenericGFPoly> other)
return other;
}
if (other->isZero()) {
return Ref<GenericGFPoly>(this);
return QSharedPointer<GenericGFPoly>(this);
}
QSharedPointer<std::vector<int>> smallerCoefficients = coefficients_;
@ -126,10 +126,10 @@ Ref<GenericGFPoly> GenericGFPoly::addOrSubtract(Ref<zxing::GenericGFPoly> other)
largerCoefficients[i]);
}
return Ref<GenericGFPoly>(new GenericGFPoly(field_, sumDiff));
return QSharedPointer<GenericGFPoly>(new GenericGFPoly(field_, sumDiff));
}
Ref<GenericGFPoly> GenericGFPoly::multiply(Ref<zxing::GenericGFPoly> other) {
QSharedPointer<GenericGFPoly> GenericGFPoly::multiply(QSharedPointer<zxing::GenericGFPoly> other) {
if (!(field_ == other->field_)) {
throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
}
@ -153,25 +153,25 @@ Ref<GenericGFPoly> GenericGFPoly::multiply(Ref<zxing::GenericGFPoly> other) {
}
}
return Ref<GenericGFPoly>(new GenericGFPoly(field_, product));
return QSharedPointer<GenericGFPoly>(new GenericGFPoly(field_, product));
}
Ref<GenericGFPoly> GenericGFPoly::multiply(int scalar) {
QSharedPointer<GenericGFPoly> GenericGFPoly::multiply(int scalar) {
if (scalar == 0) {
return field_->getZero();
}
if (scalar == 1) {
return Ref<GenericGFPoly>(this);
return QSharedPointer<GenericGFPoly>(this);
}
int size = coefficients_->size();
QSharedPointer<std::vector<int>> product(size);
for (int i = 0; i < size; i++) {
product[i] = field_->multiply(coefficients_[i], scalar);
}
return Ref<GenericGFPoly>(new GenericGFPoly(field_, product));
return QSharedPointer<GenericGFPoly>(new GenericGFPoly(field_, product));
}
Ref<GenericGFPoly> GenericGFPoly::multiplyByMonomial(int degree, int coefficient) {
QSharedPointer<GenericGFPoly> GenericGFPoly::multiplyByMonomial(int degree, int coefficient) {
if (degree < 0) {
throw IllegalArgumentException("degree must not be less then 0");
}
@ -183,10 +183,10 @@ Ref<GenericGFPoly> GenericGFPoly::multiplyByMonomial(int degree, int coefficient
for (int i = 0; i < size; i++) {
product[i] = field_->multiply(coefficients_[i], coefficient);
}
return Ref<GenericGFPoly>(new GenericGFPoly(field_, product));
return QSharedPointer<GenericGFPoly>(new GenericGFPoly(field_, product));
}
std::vector<Ref<GenericGFPoly>> GenericGFPoly::divide(Ref<GenericGFPoly> other) {
std::vector<QSharedPointer<GenericGFPoly>> GenericGFPoly::divide(QSharedPointer<GenericGFPoly> other) {
if (!(field_ == other->field_)) {
throw IllegalArgumentException("GenericGFPolys do not have same GenericGF field");
}
@ -194,8 +194,8 @@ std::vector<Ref<GenericGFPoly>> GenericGFPoly::divide(Ref<GenericGFPoly> other)
throw IllegalArgumentException("divide by 0");
}
Ref<GenericGFPoly> quotient = field_->getZero();
Ref<GenericGFPoly> remainder = Ref<GenericGFPoly>(this);
QSharedPointer<GenericGFPoly> quotient = field_->getZero();
QSharedPointer<GenericGFPoly> remainder = QSharedPointer<GenericGFPoly>(this);
int denominatorLeadingTerm = other->getCoefficient(other->getDegree());
int inverseDenominatorLeadingTerm = field_->inverse(denominatorLeadingTerm);
@ -204,14 +204,14 @@ std::vector<Ref<GenericGFPoly>> GenericGFPoly::divide(Ref<GenericGFPoly> other)
int degreeDifference = remainder->getDegree() - other->getDegree();
int scale = field_->multiply(remainder->getCoefficient(remainder->getDegree()),
inverseDenominatorLeadingTerm);
Ref<GenericGFPoly> term = other->multiplyByMonomial(degreeDifference, scale);
Ref<GenericGFPoly> iterationQuotiont = field_->buildMonomial(degreeDifference,
QSharedPointer<GenericGFPoly> term = other->multiplyByMonomial(degreeDifference, scale);
QSharedPointer<GenericGFPoly> iterationQuotiont = field_->buildMonomial(degreeDifference,
scale);
quotient = quotient->addOrSubtract(iterationQuotiont);
remainder = remainder->addOrSubtract(term);
}
std::vector<Ref<GenericGFPoly> > returnValue;
std::vector<QSharedPointer<GenericGFPoly> > returnValue;
returnValue.push_back(quotient);
returnValue.push_back(remainder);
return returnValue;

View File

@ -30,7 +30,7 @@ namespace zxing {
class GenericGF;
class GenericGFPoly : public Counted {
class GenericGFPoly {
private:
GenericGF *field_;
QSharedPointer<std::vector<int>> coefficients_;
@ -42,11 +42,11 @@ public:
bool isZero();
int getCoefficient(int degree);
int evaluateAt(int a);
Ref<GenericGFPoly> addOrSubtract(Ref<GenericGFPoly> other);
Ref<GenericGFPoly> multiply(Ref<GenericGFPoly> other);
Ref<GenericGFPoly> multiply(int scalar);
Ref<GenericGFPoly> multiplyByMonomial(int degree, int coefficient);
std::vector<Ref<GenericGFPoly>> divide(Ref<GenericGFPoly> other);
QSharedPointer<GenericGFPoly> addOrSubtract(QSharedPointer<GenericGFPoly> other);
QSharedPointer<GenericGFPoly> multiply(QSharedPointer<GenericGFPoly> other);
QSharedPointer<GenericGFPoly> multiply(int scalar);
QSharedPointer<GenericGFPoly> multiplyByMonomial(int degree, int coefficient);
std::vector<QSharedPointer<GenericGFPoly>> divide(QSharedPointer<GenericGFPoly> other);
};

View File

@ -34,13 +34,13 @@ using zxing::IllegalStateException;
// VC++
using zxing::GenericGF;
ReedSolomonDecoder::ReedSolomonDecoder(Ref<GenericGF> field_) : field(field_) {}
ReedSolomonDecoder::ReedSolomonDecoder(QSharedPointer<GenericGF> field_) : field(field_) {}
ReedSolomonDecoder::~ReedSolomonDecoder() {
}
void ReedSolomonDecoder::decode(QSharedPointer<std::vector<int>> received, int twoS) {
Ref<GenericGFPoly> poly(new GenericGFPoly(field, received));
QSharedPointer<GenericGFPoly> poly(new GenericGFPoly(field, received));
QSharedPointer<std::vector<int>> syndromeCoefficients(twoS);
bool noError = true;
for (int i = 0; i < twoS; i++) {
@ -53,11 +53,11 @@ void ReedSolomonDecoder::decode(QSharedPointer<std::vector<int>> received, int t
if (noError) {
return;
}
Ref<GenericGFPoly> syndrome(new GenericGFPoly(field, syndromeCoefficients));
vector<Ref<GenericGFPoly> > sigmaOmega =
QSharedPointer<GenericGFPoly> syndrome(new GenericGFPoly(field, syndromeCoefficients));
vector<QSharedPointer<GenericGFPoly> > sigmaOmega =
runEuclideanAlgorithm(field->buildMonomial(twoS, 1), syndrome, twoS);
Ref<GenericGFPoly> sigma = sigmaOmega[0];
Ref<GenericGFPoly> omega = sigmaOmega[1];
QSharedPointer<GenericGFPoly> sigma = sigmaOmega[0];
QSharedPointer<GenericGFPoly> omega = sigmaOmega[1];
QSharedPointer<std::vector<int>> errorLocations = findErrorLocations(sigma);
QSharedPointer<std::vector<int>> errorMagitudes = findErrorMagnitudes(omega, errorLocations);
for (int i = 0; i < errorLocations->size(); i++) {
@ -69,25 +69,25 @@ void ReedSolomonDecoder::decode(QSharedPointer<std::vector<int>> received, int t
}
}
vector<Ref<GenericGFPoly> > ReedSolomonDecoder::runEuclideanAlgorithm(Ref<GenericGFPoly> a,
Ref<GenericGFPoly> b,
vector<QSharedPointer<GenericGFPoly> > ReedSolomonDecoder::runEuclideanAlgorithm(QSharedPointer<GenericGFPoly> a,
QSharedPointer<GenericGFPoly> b,
int R) {
// Assume a's degree is >= b's
if (a->getDegree() < b->getDegree()) {
Ref<GenericGFPoly> tmp = a;
QSharedPointer<GenericGFPoly> tmp = a;
a = b;
b = tmp;
}
Ref<GenericGFPoly> rLast(a);
Ref<GenericGFPoly> r(b);
Ref<GenericGFPoly> tLast(field->getZero());
Ref<GenericGFPoly> t(field->getOne());
QSharedPointer<GenericGFPoly> rLast(a);
QSharedPointer<GenericGFPoly> r(b);
QSharedPointer<GenericGFPoly> tLast(field->getZero());
QSharedPointer<GenericGFPoly> t(field->getOne());
// Run Euclidean algorithm until r's degree is less than R/2
while (r->getDegree() >= R / 2) {
Ref<GenericGFPoly> rLastLast(rLast);
Ref<GenericGFPoly> tLastLast(tLast);
QSharedPointer<GenericGFPoly> rLastLast(rLast);
QSharedPointer<GenericGFPoly> tLastLast(tLast);
rLast = r;
tLast = t;
@ -97,7 +97,7 @@ vector<Ref<GenericGFPoly> > ReedSolomonDecoder::runEuclideanAlgorithm(Ref<Generi
throw ReedSolomonException("r_{i-1} was zero");
}
r = rLastLast;
Ref<GenericGFPoly> q = field->getZero();
QSharedPointer<GenericGFPoly> q = field->getZero();
int denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree());
int dltInverse = field->inverse(denominatorLeadingTerm);
while (r->getDegree() >= rLast->getDegree() && !r->isZero()) {
@ -120,15 +120,15 @@ vector<Ref<GenericGFPoly> > ReedSolomonDecoder::runEuclideanAlgorithm(Ref<Generi
}
int inverse = field->inverse(sigmaTildeAtZero);
Ref<GenericGFPoly> sigma(t->multiply(inverse));
Ref<GenericGFPoly> omega(r->multiply(inverse));
vector<Ref<GenericGFPoly> > result(2);
QSharedPointer<GenericGFPoly> sigma(t->multiply(inverse));
QSharedPointer<GenericGFPoly> omega(r->multiply(inverse));
vector<QSharedPointer<GenericGFPoly> > result(2);
result[0] = sigma;
result[1] = omega;
return result;
}
QSharedPointer<std::vector<int>> ReedSolomonDecoder::findErrorLocations(Ref<GenericGFPoly> errorLocator) {
QSharedPointer<std::vector<int>> ReedSolomonDecoder::findErrorLocations(QSharedPointer<GenericGFPoly> errorLocator) {
// This is a direct application of Chien's search
int numErrors = errorLocator->getDegree();
if (numErrors == 1) { // shortcut
@ -150,7 +150,7 @@ QSharedPointer<std::vector<int>> ReedSolomonDecoder::findErrorLocations(Ref<Gene
return result;
}
QSharedPointer<std::vector<int>> ReedSolomonDecoder::findErrorMagnitudes(Ref<GenericGFPoly> errorEvaluator, QSharedPointer<std::vector<int>> errorLocations) {
QSharedPointer<std::vector<int>> ReedSolomonDecoder::findErrorMagnitudes(QSharedPointer<GenericGFPoly> errorEvaluator, QSharedPointer<std::vector<int>> errorLocations) {
// This is directly applying Forney's Formula
int s = errorLocations->size();
QSharedPointer<std::vector<int>> result(new std::vector<int>(s));

View File

@ -33,16 +33,16 @@ class GenericGF;
class ReedSolomonDecoder {
private:
Ref<GenericGF> field;
QSharedPointer<GenericGF> field;
public:
ReedSolomonDecoder(Ref<GenericGF> fld);
ReedSolomonDecoder(QSharedPointer<GenericGF> fld);
~ReedSolomonDecoder();
void decode(QSharedPointer<std::vector<int>> received, int twoS);
std::vector<Ref<GenericGFPoly> > runEuclideanAlgorithm(Ref<GenericGFPoly> a, Ref<GenericGFPoly> b, int R);
std::vector<QSharedPointer<GenericGFPoly> > runEuclideanAlgorithm(QSharedPointer<GenericGFPoly> a, QSharedPointer<GenericGFPoly> b, int R);
private:
QSharedPointer<std::vector<int>> findErrorLocations(Ref<GenericGFPoly> errorLocator);
QSharedPointer<std::vector<int>> findErrorMagnitudes(Ref<GenericGFPoly> errorEvaluator, QSharedPointer<std::vector<int>> errorLocations);
QSharedPointer<std::vector<int>> findErrorLocations(QSharedPointer<GenericGFPoly> errorLocator);
QSharedPointer<std::vector<int>> findErrorMagnitudes(QSharedPointer<GenericGFPoly> errorEvaluator, QSharedPointer<std::vector<int>> errorLocations);
};
}

View File

@ -6,26 +6,26 @@
namespace zxing {
ReedSolomonEncoder::ReedSolomonEncoder(Ref<GenericGF> field) :
ReedSolomonEncoder::ReedSolomonEncoder(QSharedPointer<GenericGF> field) :
field_(field), cachedGenerators_()
{
QSharedPointer<std::vector<int>> arrayRef(1); //will this work?
arrayRef[0] = 1;
Ref< GenericGFPoly > tmpGeneratorRef(new GenericGFPoly(field, arrayRef));
QSharedPointer< GenericGFPoly > tmpGeneratorRef(new GenericGFPoly(field, arrayRef));
cachedGenerators_.push_back(tmpGeneratorRef);
}
Ref<GenericGFPoly> ReedSolomonEncoder::buildGenerator(int degree)
QSharedPointer<GenericGFPoly> ReedSolomonEncoder::buildGenerator(int degree)
{
if (degree >= int(cachedGenerators_.size())) {
Ref<GenericGFPoly> lastGenerator = cachedGenerators_.at(cachedGenerators_.size() - 1);
QSharedPointer<GenericGFPoly> lastGenerator = cachedGenerators_.at(cachedGenerators_.size() - 1);
for (int d = int(cachedGenerators_.size()); d <= degree; d++)
{
QSharedPointer<std::vector<int>> arrayRef(2); //will this work?
arrayRef[0] = 1;
arrayRef[1] = field_->exp(d - 1 + field_->getGeneratorBase());
Ref<GenericGFPoly> tmpGFRef(new GenericGFPoly(field_, arrayRef));
Ref<GenericGFPoly> nextGenerator = (*lastGenerator).multiply(tmpGFRef);
QSharedPointer<GenericGFPoly> tmpGFRef(new GenericGFPoly(field_, arrayRef));
QSharedPointer<GenericGFPoly> nextGenerator = (*lastGenerator).multiply(tmpGFRef);
cachedGenerators_.push_back(nextGenerator);
lastGenerator = nextGenerator;
}
@ -47,16 +47,16 @@ void ReedSolomonEncoder::encode(std::vector<zxing::byte> &toEncode, int ecBytes)
if (dataBytes <= 0) {
throw Exception("No data bytes provided");
}
Ref<GenericGFPoly> generator = buildGenerator(ecBytes);
QSharedPointer<GenericGFPoly> generator = buildGenerator(ecBytes);
QSharedPointer<std::vector<int>> infoCoefficients(dataBytes);
//to-do optimize the following loop
for(int i=0; i< dataBytes; i++)
infoCoefficients[i] = toEncode[size_t(i)];
Ref<GenericGFPoly> info(new GenericGFPoly(field_, infoCoefficients));
QSharedPointer<GenericGFPoly> info(new GenericGFPoly(field_, infoCoefficients));
info = info->multiplyByMonomial(ecBytes, 1);
Ref<GenericGFPoly> remainder = info->divide(generator)[1];
QSharedPointer<GenericGFPoly> remainder = info->divide(generator)[1];
QSharedPointer<std::vector<int>> coefficients = remainder->getCoefficients();
int numZeroCoefficients = ecBytes - coefficients->size();
for (int i = 0; i < numZeroCoefficients; i++) {

View File

@ -11,13 +11,13 @@ namespace zxing {
class ReedSolomonEncoder
{
private:
Ref<GenericGF> field_;
std::vector< Ref< GenericGFPoly > >cachedGenerators_;
QSharedPointer<GenericGF> field_;
std::vector< QSharedPointer< GenericGFPoly > >cachedGenerators_;
Ref<GenericGFPoly> buildGenerator(int degree);
QSharedPointer<GenericGFPoly> buildGenerator(int degree);
public:
ReedSolomonEncoder(Ref<GenericGF> field);
ReedSolomonEncoder(QSharedPointer<GenericGF> field);
void encode(std::vector<zxing::byte> &toEncode, int ecBytes);
};

View File

@ -32,16 +32,16 @@ DataMatrixReader::DataMatrixReader() :
decoder_() {
}
Ref<Result> DataMatrixReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
QSharedPointer<Result> DataMatrixReader::decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints) {
(void)hints;
Detector detector(image->getBlackMatrix());
Ref<DetectorResult> detectorResult(detector.detect());
QSharedPointer<std::vector<Ref<ResultPoint>> > points(detectorResult->getPoints());
QSharedPointer<DetectorResult> detectorResult(detector.detect());
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points(detectorResult->getPoints());
Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult->getBits()));
QSharedPointer<DecoderResult> decoderResult(decoder_.decode(detectorResult->getBits()));
Ref<Result> result(
QSharedPointer<Result> result(
new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::DATA_MATRIX));
return result;

View File

@ -34,7 +34,7 @@ private:
public:
DataMatrixReader();
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints);
virtual ~DataMatrixReader();
};

View File

@ -61,7 +61,7 @@ ECBlocks::~ECBlocks() {
}
}
vector<Ref<Version>> Version::VERSIONS;
vector<QSharedPointer<Version>> Version::VERSIONS;
static int N_VERSIONS = Version::buildVersions();
Version::Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, int dataRegionSizeRows,
@ -112,7 +112,7 @@ ECBlocks* Version::getECBlocks() const {
return ecBlocks_;
}
Ref<Version> Version::getVersionForDimensions(int numRows, int numColumns) {
QSharedPointer<Version> Version::getVersionForDimensions(int numRows, int numColumns) {
if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) {
throw ReaderException("Number of rows and columns must be even");
}
@ -121,7 +121,7 @@ Ref<Version> Version::getVersionForDimensions(int numRows, int numColumns) {
// If we interleave the rectangular versions with the square versions we could
// do a binary search.
for (int i = 0; i < N_VERSIONS; ++i){
Ref<Version> version = VERSIONS[i];
QSharedPointer<Version> version = VERSIONS[i];
if (version->getSymbolSizeRows() == numRows && version->getSymbolSizeColumns() == numColumns) {
return version;
}
@ -133,65 +133,65 @@ Ref<Version> Version::getVersionForDimensions(int numRows, int numColumns) {
* See ISO 16022:2006 5.5.1 Table 7
*/
int Version::buildVersions() {
VERSIONS.push_back(Ref<Version>(new Version(1, 10, 10, 8, 8,
VERSIONS.push_back(QSharedPointer<Version>(new Version(1, 10, 10, 8, 8,
new ECBlocks(5, new ECB(1, 3)))));
VERSIONS.push_back(Ref<Version>(new Version(2, 12, 12, 10, 10,
VERSIONS.push_back(QSharedPointer<Version>(new Version(2, 12, 12, 10, 10,
new ECBlocks(7, new ECB(1, 5)))));
VERSIONS.push_back(Ref<Version>(new Version(3, 14, 14, 12, 12,
VERSIONS.push_back(QSharedPointer<Version>(new Version(3, 14, 14, 12, 12,
new ECBlocks(10, new ECB(1, 8)))));
VERSIONS.push_back(Ref<Version>(new Version(4, 16, 16, 14, 14,
VERSIONS.push_back(QSharedPointer<Version>(new Version(4, 16, 16, 14, 14,
new ECBlocks(12, new ECB(1, 12)))));
VERSIONS.push_back(Ref<Version>(new Version(5, 18, 18, 16, 16,
VERSIONS.push_back(QSharedPointer<Version>(new Version(5, 18, 18, 16, 16,
new ECBlocks(14, new ECB(1, 18)))));
VERSIONS.push_back(Ref<Version>(new Version(6, 20, 20, 18, 18,
VERSIONS.push_back(QSharedPointer<Version>(new Version(6, 20, 20, 18, 18,
new ECBlocks(18, new ECB(1, 22)))));
VERSIONS.push_back(Ref<Version>(new Version(7, 22, 22, 20, 20,
VERSIONS.push_back(QSharedPointer<Version>(new Version(7, 22, 22, 20, 20,
new ECBlocks(20, new ECB(1, 30)))));
VERSIONS.push_back(Ref<Version>(new Version(8, 24, 24, 22, 22,
VERSIONS.push_back(QSharedPointer<Version>(new Version(8, 24, 24, 22, 22,
new ECBlocks(24, new ECB(1, 36)))));
VERSIONS.push_back(Ref<Version>(new Version(9, 26, 26, 24, 24,
VERSIONS.push_back(QSharedPointer<Version>(new Version(9, 26, 26, 24, 24,
new ECBlocks(28, new ECB(1, 44)))));
VERSIONS.push_back(Ref<Version>(new Version(10, 32, 32, 14, 14,
VERSIONS.push_back(QSharedPointer<Version>(new Version(10, 32, 32, 14, 14,
new ECBlocks(36, new ECB(1, 62)))));
VERSIONS.push_back(Ref<Version>(new Version(11, 36, 36, 16, 16,
VERSIONS.push_back(QSharedPointer<Version>(new Version(11, 36, 36, 16, 16,
new ECBlocks(42, new ECB(1, 86)))));
VERSIONS.push_back(Ref<Version>(new Version(12, 40, 40, 18, 18,
VERSIONS.push_back(QSharedPointer<Version>(new Version(12, 40, 40, 18, 18,
new ECBlocks(48, new ECB(1, 114)))));
VERSIONS.push_back(Ref<Version>(new Version(13, 44, 44, 20, 20,
VERSIONS.push_back(QSharedPointer<Version>(new Version(13, 44, 44, 20, 20,
new ECBlocks(56, new ECB(1, 144)))));
VERSIONS.push_back(Ref<Version>(new Version(14, 48, 48, 22, 22,
VERSIONS.push_back(QSharedPointer<Version>(new Version(14, 48, 48, 22, 22,
new ECBlocks(68, new ECB(1, 174)))));
VERSIONS.push_back(Ref<Version>(new Version(15, 52, 52, 24, 24,
VERSIONS.push_back(QSharedPointer<Version>(new Version(15, 52, 52, 24, 24,
new ECBlocks(42, new ECB(2, 102)))));
VERSIONS.push_back(Ref<Version>(new Version(16, 64, 64, 14, 14,
VERSIONS.push_back(QSharedPointer<Version>(new Version(16, 64, 64, 14, 14,
new ECBlocks(56, new ECB(2, 140)))));
VERSIONS.push_back(Ref<Version>(new Version(17, 72, 72, 16, 16,
VERSIONS.push_back(QSharedPointer<Version>(new Version(17, 72, 72, 16, 16,
new ECBlocks(36, new ECB(4, 92)))));
VERSIONS.push_back(Ref<Version>(new Version(18, 80, 80, 18, 18,
VERSIONS.push_back(QSharedPointer<Version>(new Version(18, 80, 80, 18, 18,
new ECBlocks(48, new ECB(4, 114)))));
VERSIONS.push_back(Ref<Version>(new Version(19, 88, 88, 20, 20,
VERSIONS.push_back(QSharedPointer<Version>(new Version(19, 88, 88, 20, 20,
new ECBlocks(56, new ECB(4, 144)))));
VERSIONS.push_back(Ref<Version>(new Version(20, 96, 96, 22, 22,
VERSIONS.push_back(QSharedPointer<Version>(new Version(20, 96, 96, 22, 22,
new ECBlocks(68, new ECB(4, 174)))));
VERSIONS.push_back(Ref<Version>(new Version(21, 104, 104, 24, 24,
VERSIONS.push_back(QSharedPointer<Version>(new Version(21, 104, 104, 24, 24,
new ECBlocks(56, new ECB(6, 136)))));
VERSIONS.push_back(Ref<Version>(new Version(22, 120, 120, 18, 18,
VERSIONS.push_back(QSharedPointer<Version>(new Version(22, 120, 120, 18, 18,
new ECBlocks(68, new ECB(6, 175)))));
VERSIONS.push_back(Ref<Version>(new Version(23, 132, 132, 20, 20,
VERSIONS.push_back(QSharedPointer<Version>(new Version(23, 132, 132, 20, 20,
new ECBlocks(62, new ECB(8, 163)))));
VERSIONS.push_back(Ref<Version>(new Version(24, 144, 144, 22, 22,
VERSIONS.push_back(QSharedPointer<Version>(new Version(24, 144, 144, 22, 22,
new ECBlocks(62, new ECB(8, 156), new ECB(2, 155)))));
VERSIONS.push_back(Ref<Version>(new Version(25, 8, 18, 6, 16,
VERSIONS.push_back(QSharedPointer<Version>(new Version(25, 8, 18, 6, 16,
new ECBlocks(7, new ECB(1, 5)))));
VERSIONS.push_back(Ref<Version>(new Version(26, 8, 32, 6, 14,
VERSIONS.push_back(QSharedPointer<Version>(new Version(26, 8, 32, 6, 14,
new ECBlocks(11, new ECB(1, 10)))));
VERSIONS.push_back(Ref<Version>(new Version(27, 12, 26, 10, 24,
VERSIONS.push_back(QSharedPointer<Version>(new Version(27, 12, 26, 10, 24,
new ECBlocks(14, new ECB(1, 16)))));
VERSIONS.push_back(Ref<Version>(new Version(28, 12, 36, 10, 16,
VERSIONS.push_back(QSharedPointer<Version>(new Version(28, 12, 36, 10, 16,
new ECBlocks(18, new ECB(1, 22)))));
VERSIONS.push_back(Ref<Version>(new Version(29, 16, 36, 14, 16,
VERSIONS.push_back(QSharedPointer<Version>(new Version(29, 16, 36, 14, 16,
new ECBlocks(24, new ECB(1, 32)))));
VERSIONS.push_back(Ref<Version>(new Version(30, 16, 48, 14, 22,
VERSIONS.push_back(QSharedPointer<Version>(new Version(30, 16, 48, 14, 22,
new ECBlocks(28, new ECB(1, 49)))));
return int(VERSIONS.size());
}

View File

@ -51,7 +51,7 @@ public:
~ECBlocks();
};
class Version : public Counted {
class Version {
private:
int versionNumber_;
int symbolSizeRows_;
@ -64,7 +64,7 @@ private:
int dataRegionSizeColumns, ECBlocks *ecBlocks);
public:
static std::vector<Ref<Version>> VERSIONS;
static std::vector<QSharedPointer<Version>> VERSIONS;
~Version();
int getVersionNumber() const;
@ -75,7 +75,7 @@ public:
int getTotalCodewords() const;
ECBlocks* getECBlocks() const;
static int buildVersions();
Ref<Version>getVersionForDimensions(int numRows, int numColumns);
QSharedPointer<Version>getVersionForDimensions(int numRows, int numColumns);
private:
Version(const Version&);

View File

@ -30,17 +30,17 @@
namespace zxing {
namespace datamatrix {
class BitMatrixParser : public Counted {
class BitMatrixParser {
private:
Ref<BitMatrix> bitMatrix_;
Ref<Version> parsedVersion_;
Ref<BitMatrix> readBitMatrix_;
QSharedPointer<BitMatrix> bitMatrix_;
QSharedPointer<Version> parsedVersion_;
QSharedPointer<BitMatrix> readBitMatrix_;
int copyBit(size_t x, size_t y, int versionBits);
public:
BitMatrixParser(Ref<BitMatrix> bitMatrix);
Ref<Version> readVersion(Ref<BitMatrix> bitMatrix);
BitMatrixParser(QSharedPointer<BitMatrix> bitMatrix);
QSharedPointer<Version> readVersion(QSharedPointer<BitMatrix> bitMatrix);
QSharedPointer<std::vector<zxing::byte>> readCodewords();
bool readModule(int row, int column, int numRows, int numColumns);
@ -50,7 +50,7 @@ private:
int readCorner2(int numRows, int numColumns);
int readCorner3(int numRows, int numColumns);
int readCorner4(int numRows, int numColumns);
Ref<BitMatrix> extractDataRegion(Ref<BitMatrix> bitMatrix);
QSharedPointer<BitMatrix> extractDataRegion(QSharedPointer<BitMatrix> bitMatrix);
};
}

View File

@ -29,7 +29,7 @@
namespace zxing {
namespace datamatrix {
class DataBlock : public Counted {
class DataBlock {
private:
int numDataCodewords_;
QSharedPointer<std::vector<zxing::byte>> codewords_;
@ -37,7 +37,7 @@ private:
DataBlock(int numDataCodewords, QSharedPointer<std::vector<zxing::byte>> codewords);
public:
static std::vector<Ref<DataBlock> > getDataBlocks(QSharedPointer<std::vector<zxing::byte>> rawCodewords, Ref<Version>version);
static std::vector<QSharedPointer<DataBlock> > getDataBlocks(QSharedPointer<std::vector<zxing::byte>> rawCodewords, QSharedPointer<Version>version);
int getNumDataCodewords();
QSharedPointer<std::vector<zxing::byte>> getCodewords();

View File

@ -30,7 +30,7 @@ int BitMatrixParser::copyBit(size_t x, size_t y, int versionBits) {
return bitMatrix_->get(int(x), int(y)) ? (versionBits << 1) | 0x1 : versionBits << 1;
}
BitMatrixParser::BitMatrixParser(Ref<BitMatrix> bitMatrix) : bitMatrix_(NULL),
BitMatrixParser::BitMatrixParser(QSharedPointer<BitMatrix> bitMatrix) : bitMatrix_(NULL),
parsedVersion_(NULL),
readBitMatrix_(NULL) {
size_t dimension = bitMatrix->getHeight();
@ -42,7 +42,7 @@ BitMatrixParser::BitMatrixParser(Ref<BitMatrix> bitMatrix) : bitMatrix_(NULL),
readBitMatrix_ = new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight());
}
Ref<Version> BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
QSharedPointer<Version> BitMatrixParser::readVersion(QSharedPointer<BitMatrix> bitMatrix) {
if (parsedVersion_ != 0) {
return parsedVersion_;
}
@ -50,7 +50,7 @@ Ref<Version> BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
int numRows = bitMatrix->getHeight();
int numColumns = bitMatrix->getWidth();
Ref<Version> version = parsedVersion_->getVersionForDimensions(numRows, numColumns);
QSharedPointer<Version> version = parsedVersion_->getVersionForDimensions(numRows, numColumns);
if (version != 0) {
return version;
}
@ -319,7 +319,7 @@ int BitMatrixParser::readCorner4(int numRows, int numColumns) {
return currentByte;
}
Ref<BitMatrix> BitMatrixParser::extractDataRegion(Ref<BitMatrix> bitMatrix) {
QSharedPointer<BitMatrix> BitMatrixParser::extractDataRegion(QSharedPointer<BitMatrix> bitMatrix) {
int symbolSizeRows = parsedVersion_->getSymbolSizeRows();
int symbolSizeColumns = parsedVersion_->getSymbolSizeColumns();
@ -336,7 +336,7 @@ Ref<BitMatrix> BitMatrixParser::extractDataRegion(Ref<BitMatrix> bitMatrix) {
int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
Ref<BitMatrix> bitMatrixWithoutAlignment(new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow));
QSharedPointer<BitMatrix> bitMatrixWithoutAlignment(new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow));
for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) {

View File

@ -38,7 +38,7 @@ QSharedPointer<std::vector<zxing::byte>> DataBlock::getCodewords() {
return codewords_;
}
std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<std::vector<zxing::byte>> rawCodewords, Ref<Version>version) {
std::vector<QSharedPointer<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<std::vector<zxing::byte>> rawCodewords, QSharedPointer<Version>version) {
// Figure out the number and size of data blocks used by this version and
// error correction level
ECBlocks* ecBlocks = version->getECBlocks();
@ -51,7 +51,7 @@ std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<std::vector
}
// Now establish DataBlocks of the appropriate size and number of data codewords
std::vector<Ref<DataBlock> > result(totalBlocks);
std::vector<QSharedPointer<DataBlock> > result(totalBlocks);
int numResultBlocks = 0;
for (size_t j = 0; j < ecBlockArray.size(); j++) {
ECB *ecBlock = ecBlockArray[j];
@ -59,7 +59,7 @@ std::vector<Ref<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<std::vector
int numDataCodewords = ecBlock->getDataCodewords();
int numBlockCodewords = ecBlocks->getECCodewords() + numDataCodewords;
QSharedPointer<std::vector<zxing::byte>> buffer(numBlockCodewords);
Ref<DataBlock> blockRef(new DataBlock(numDataCodewords, buffer));
QSharedPointer<DataBlock> blockRef(new DataBlock(numDataCodewords, buffer));
result[numResultBlocks++] = blockRef;
}
}

View File

@ -51,8 +51,8 @@ const char DecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = {
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (zxing::byte) 127
};
Ref<DecoderResult> DecodedBitStreamParser::decode(QSharedPointer<std::vector<zxing::byte>> bytes) {
Ref<BitSource> bits(new BitSource(bytes));
QSharedPointer<DecoderResult> DecodedBitStreamParser::decode(QSharedPointer<std::vector<zxing::byte>> bytes) {
QSharedPointer<BitSource> bits(new BitSource(bytes));
ostringstream result;
ostringstream resultTrailer;
vector<zxing::byte> byteSegments;
@ -88,11 +88,11 @@ Ref<DecoderResult> DecodedBitStreamParser::decode(QSharedPointer<std::vector<zxi
result << resultTrailer.str();
}
QSharedPointer<std::vector<zxing::byte>> rawBytes(bytes);
Ref<String> text(new String(result.str()));
return Ref<DecoderResult>(new DecoderResult(rawBytes, text));
QSharedPointer<String> text(new String(result.str()));
return QSharedPointer<DecoderResult>(new DecoderResult(rawBytes, text));
}
int DecodedBitStreamParser::decodeAsciiSegment(Ref<BitSource> bits, ostringstream & result,
int DecodedBitStreamParser::decodeAsciiSegment(QSharedPointer<BitSource> bits, ostringstream & result,
ostringstream & resultTrailer) {
bool upperShift = false;
do {
@ -150,7 +150,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref<BitSource> bits, ostringstrea
return ASCII_ENCODE;
}
void DecodedBitStreamParser::decodeC40Segment(Ref<BitSource> bits, ostringstream & result) {
void DecodedBitStreamParser::decodeC40Segment(QSharedPointer<BitSource> bits, ostringstream & result) {
// Three C40 values are encoded in a 16-bit value as
// (1600 * C1) + (40 * C2) + C3 + 1
// TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time
@ -227,7 +227,7 @@ void DecodedBitStreamParser::decodeC40Segment(Ref<BitSource> bits, ostringstream
} while (bits->available() > 0);
}
void DecodedBitStreamParser::decodeTextSegment(Ref<BitSource> bits, ostringstream & result) {
void DecodedBitStreamParser::decodeTextSegment(QSharedPointer<BitSource> bits, ostringstream & result) {
// Three Text values are encoded in a 16-bit value as
// (1600 * C1) + (40 * C2) + C3 + 1
// TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time
@ -305,7 +305,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref<BitSource> bits, ostringstrea
} while (bits->available() > 0);
}
void DecodedBitStreamParser::decodeAnsiX12Segment(Ref<BitSource> bits, ostringstream & result) {
void DecodedBitStreamParser::decodeAnsiX12Segment(QSharedPointer<BitSource> bits, ostringstream & result) {
// Three ANSI X12 values are encoded in a 16-bit value as
// (1600 * C1) + (40 * C2) + C3 + 1
@ -353,7 +353,7 @@ void DecodedBitStreamParser::parseTwoBytes(int firstByte, int secondByte, int* r
result[2] = fullBitValue - temp * 40;
}
void DecodedBitStreamParser::decodeEdifactSegment(Ref<BitSource> bits, ostringstream & result) {
void DecodedBitStreamParser::decodeEdifactSegment(QSharedPointer<BitSource> bits, ostringstream & result) {
do {
// If there is only two or less bytes left then it will be encoded as ASCII
if (bits->available() <= 16) {
@ -381,7 +381,7 @@ void DecodedBitStreamParser::decodeEdifactSegment(Ref<BitSource> bits, ostringst
} while (bits->available() > 0);
}
void DecodedBitStreamParser::decodeBase256Segment(Ref<BitSource> bits, ostringstream& result, vector<zxing::byte> byteSegments) {
void DecodedBitStreamParser::decodeBase256Segment(QSharedPointer<BitSource> bits, ostringstream& result, vector<zxing::byte> byteSegments) {
// Figure out how long the Base 256 Segment is.
int codewordPosition = 1 + bits->getByteOffset(); // position is 1-indexed
int d1 = unrandomize255State(bits->readBits(8), codewordPosition++);

View File

@ -62,15 +62,15 @@ void Decoder::correctErrors(QSharedPointer<std::vector<zxing::byte>> codewordByt
}
}
Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
QSharedPointer<DecoderResult> Decoder::decode(QSharedPointer<BitMatrix> bits) {
// Construct a parser and read version, error-correction level
BitMatrixParser parser(bits);
Ref<Version>version = parser.readVersion(bits);
QSharedPointer<Version>version = parser.readVersion(bits);
// Read codewords
QSharedPointer<std::vector<zxing::byte>> codewords(parser.readCodewords());
// Separate into data blocks
std::vector<Ref<DataBlock> > dataBlocks = DataBlock::getDataBlocks(codewords, version);
std::vector<QSharedPointer<DataBlock> > dataBlocks = DataBlock::getDataBlocks(codewords, version);
int dataBlocksCount = int(dataBlocks.size());
@ -83,7 +83,7 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
// Error-correct and copy data blocks together into a stream of bytes
for (int j = 0; j < dataBlocksCount; j++) {
Ref<DataBlock> dataBlock(dataBlocks[j]);
QSharedPointer<DataBlock> dataBlock(dataBlocks[j]);
QSharedPointer<std::vector<zxing::byte>> codewordBytes = dataBlock->getCodewords();
int numDataCodewords = dataBlock->getNumDataCodewords();
correctErrors(codewordBytes, numDataCodewords);
@ -94,7 +94,7 @@ Ref<DecoderResult> Decoder::decode(Ref<BitMatrix> bits) {
}
// Decode the contents of that stream of bytes
DecodedBitStreamParser decodedBSParser;
return Ref<DecoderResult> (decodedBSParser.decode(resultBytes));
return QSharedPointer<DecoderResult> (decodedBSParser.decode(resultBytes));
}
}

View File

@ -59,27 +59,27 @@ private:
/**
* See ISO 16022:2006, 5.2.3 and Annex C, Table C.2
*/
int decodeAsciiSegment(Ref<BitSource> bits, std::ostringstream &result, std::ostringstream &resultTrailer);
int decodeAsciiSegment(QSharedPointer<BitSource> bits, std::ostringstream &result, std::ostringstream &resultTrailer);
/**
* See ISO 16022:2006, 5.2.5 and Annex C, Table C.1
*/
void decodeC40Segment(Ref<BitSource> bits, std::ostringstream &result);
void decodeC40Segment(QSharedPointer<BitSource> bits, std::ostringstream &result);
/**
* See ISO 16022:2006, 5.2.6 and Annex C, Table C.2
*/
void decodeTextSegment(Ref<BitSource> bits, std::ostringstream &result);
void decodeTextSegment(QSharedPointer<BitSource> bits, std::ostringstream &result);
/**
* See ISO 16022:2006, 5.2.7
*/
void decodeAnsiX12Segment(Ref<BitSource> bits, std::ostringstream &result);
void decodeAnsiX12Segment(QSharedPointer<BitSource> bits, std::ostringstream &result);
/**
* See ISO 16022:2006, 5.2.8 and Annex C Table C.3
*/
void decodeEdifactSegment(Ref<BitSource> bits, std::ostringstream &result);
void decodeEdifactSegment(QSharedPointer<BitSource> bits, std::ostringstream &result);
/**
* See ISO 16022:2006, 5.2.9 and Annex B, B.2
*/
void decodeBase256Segment(Ref<BitSource> bits, std::ostringstream &result, std::vector<zxing::byte> byteSegments);
void decodeBase256Segment(QSharedPointer<BitSource> bits, std::ostringstream &result, std::vector<zxing::byte> byteSegments);
void parseTwoBytes(int firstByte, int secondByte, int* result);
/**
@ -96,7 +96,7 @@ private:
public:
DecodedBitStreamParser() { }
Ref<DecoderResult> decode(QSharedPointer<std::vector<zxing::byte>> bytes);
QSharedPointer<DecoderResult> decode(QSharedPointer<std::vector<zxing::byte>> bytes);
};
}

View File

@ -40,7 +40,7 @@ private:
public:
Decoder();
Ref<DecoderResult> decode(Ref<BitMatrix> bits);
QSharedPointer<DecoderResult> decode(QSharedPointer<BitMatrix> bits);
};
}

View File

@ -35,7 +35,7 @@ namespace zxing {
CornerPoint(float posX, float posY);
int getCount() const;
void incrementCount();
bool equals(Ref<CornerPoint> other) const;
bool equals(QSharedPointer<CornerPoint> other) const;
};
}
}

View File

@ -38,7 +38,7 @@ namespace zxing {
counter_++;
}
bool CornerPoint::equals(Ref<CornerPoint> other) const {
bool CornerPoint::equals(QSharedPointer<CornerPoint> other) const {
return posX_ == other->getX() && posY_ == other->getY();
}

View File

@ -41,30 +41,30 @@ using zxing::datamatrix::ResultPointsAndTransitions;
using zxing::common::detector::MathUtils;
namespace {
typedef std::map<Ref<ResultPoint>, int> PointMap;
void increment(PointMap& table, Ref<ResultPoint> const& key) {
typedef std::map<QSharedPointer<ResultPoint>, int> PointMap;
void increment(PointMap& table, QSharedPointer<ResultPoint> const& key) {
int& value = table[key];
value += 1;
}
}
ResultPointsAndTransitions::ResultPointsAndTransitions() {
Ref<ResultPoint> ref(new ResultPoint(0, 0));
QSharedPointer<ResultPoint> ref(new ResultPoint(0, 0));
from_ = ref;
to_ = ref;
transitions_ = 0;
}
ResultPointsAndTransitions::ResultPointsAndTransitions(Ref<ResultPoint> from, Ref<ResultPoint> to,
ResultPointsAndTransitions::ResultPointsAndTransitions(QSharedPointer<ResultPoint> from, QSharedPointer<ResultPoint> to,
int transitions)
: to_(to), from_(from), transitions_(transitions) {
}
Ref<ResultPoint> ResultPointsAndTransitions::getFrom() {
QSharedPointer<ResultPoint> ResultPointsAndTransitions::getFrom() {
return from_;
}
Ref<ResultPoint> ResultPointsAndTransitions::getTo() {
QSharedPointer<ResultPoint> ResultPointsAndTransitions::getTo() {
return to_;
}
@ -72,26 +72,26 @@ int ResultPointsAndTransitions::getTransitions() {
return transitions_;
}
Detector::Detector(Ref<BitMatrix> image)
Detector::Detector(QSharedPointer<BitMatrix> image)
: image_(image) {
}
Ref<BitMatrix> Detector::getImage() {
QSharedPointer<BitMatrix> Detector::getImage() {
return image_;
}
Ref<DetectorResult> Detector::detect() {
Ref<WhiteRectangleDetector> rectangleDetector_(new WhiteRectangleDetector(image_));
std::vector<Ref<ResultPoint> > ResultPoints = rectangleDetector_->detect();
Ref<ResultPoint> pointA = ResultPoints[0];
Ref<ResultPoint> pointB = ResultPoints[1];
Ref<ResultPoint> pointC = ResultPoints[2];
Ref<ResultPoint> pointD = ResultPoints[3];
QSharedPointer<DetectorResult> Detector::detect() {
QSharedPointer<WhiteRectangleDetector> rectangleDetector_(new WhiteRectangleDetector(image_));
std::vector<QSharedPointer<ResultPoint> > ResultPoints = rectangleDetector_->detect();
QSharedPointer<ResultPoint> pointA = ResultPoints[0];
QSharedPointer<ResultPoint> pointB = ResultPoints[1];
QSharedPointer<ResultPoint> pointC = ResultPoints[2];
QSharedPointer<ResultPoint> pointD = ResultPoints[3];
// Point A and D are across the diagonal from one another,
// as are B and C. Figure out which are the solid black lines
// by counting transitions
std::vector<Ref<ResultPointsAndTransitions> > transitions(4);
std::vector<QSharedPointer<ResultPointsAndTransitions> > transitions(4);
transitions[0].reset(transitionsBetween(pointA, pointB));
transitions[1].reset(transitionsBetween(pointA, pointC));
transitions[2].reset(transitionsBetween(pointB, pointD));
@ -100,12 +100,12 @@ Ref<DetectorResult> Detector::detect() {
// Sort by number of transitions. First two will be the two solid sides; last two
// will be the two alternating black/white sides
Ref<ResultPointsAndTransitions> lSideOne(transitions[0]);
Ref<ResultPointsAndTransitions> lSideTwo(transitions[1]);
QSharedPointer<ResultPointsAndTransitions> lSideOne(transitions[0]);
QSharedPointer<ResultPointsAndTransitions> lSideTwo(transitions[1]);
// Figure out which point is their intersection by tallying up the number of times we see the
// endpoints in the four endpoints. One will show up twice.
typedef std::map<Ref<ResultPoint>, int> PointMap;
typedef std::map<QSharedPointer<ResultPoint>, int> PointMap;
PointMap pointCount;
increment(pointCount, lSideOne->getFrom());
increment(pointCount, lSideOne->getTo());
@ -114,11 +114,11 @@ Ref<DetectorResult> Detector::detect() {
// Figure out which point is their intersection by tallying up the number of times we see the
// endpoints in the four endpoints. One will show up twice.
Ref<ResultPoint> maybeTopLeft;
Ref<ResultPoint> bottomLeft;
Ref<ResultPoint> maybeBottomRight;
QSharedPointer<ResultPoint> maybeTopLeft;
QSharedPointer<ResultPoint> bottomLeft;
QSharedPointer<ResultPoint> maybeBottomRight;
for (PointMap::const_iterator entry = pointCount.begin(), end = pointCount.end(); entry != end; ++entry) {
Ref<ResultPoint> const& point = entry->first;
QSharedPointer<ResultPoint> const& point = entry->first;
int value = entry->second;
if (value == 2) {
bottomLeft = point; // this is definitely the bottom left, then -- end of two L sides
@ -137,7 +137,7 @@ Ref<DetectorResult> Detector::detect() {
}
// Bottom left is correct but top left and bottom right might be switched
std::vector<Ref<ResultPoint> > corners(3);
std::vector<QSharedPointer<ResultPoint> > corners(3);
corners[0].reset(maybeTopLeft);
corners[1].reset(bottomLeft);
corners[2].reset(maybeBottomRight);
@ -146,12 +146,12 @@ Ref<DetectorResult> Detector::detect() {
ResultPoint::orderBestPatterns(corners);
// Now we know which is which:
Ref<ResultPoint> bottomRight(corners[0]);
QSharedPointer<ResultPoint> bottomRight(corners[0]);
bottomLeft = corners[1];
Ref<ResultPoint> topLeft(corners[2]);
QSharedPointer<ResultPoint> topLeft(corners[2]);
// Which point didn't we find in relation to the "L" sides? that's the top right corner
Ref<ResultPoint> topRight;
QSharedPointer<ResultPoint> topRight;
if (!(pointA->equals(bottomRight) || pointA->equals(bottomLeft) || pointA->equals(topLeft))) {
topRight = pointA;
} else if (!(pointB->equals(bottomRight) || pointB->equals(bottomLeft)
@ -190,9 +190,9 @@ Ref<DetectorResult> Detector::detect() {
}
dimensionRight += 2;
Ref<BitMatrix> bits;
Ref<PerspectiveTransform> transform;
Ref<ResultPoint> correctedTopRight;
QSharedPointer<BitMatrix> bits;
QSharedPointer<PerspectiveTransform> transform;
QSharedPointer<ResultPoint> correctedTopRight;
// Rectanguar symbols are 6x16, 6x28, 10x24, 10x32, 14x32, or 14x44. If one dimension is more
@ -246,12 +246,12 @@ Ref<DetectorResult> Detector::detect() {
bits = sampleGrid(image_, dimensionCorrected, dimensionCorrected, transform);
}
QSharedPointer<std::vector<Ref<ResultPoint>> > points (new std::vector< Ref<ResultPoint> >(4));
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points (new std::vector< QSharedPointer<ResultPoint> >(4));
points[0].reset(topLeft);
points[1].reset(bottomLeft);
points[2].reset(correctedTopRight);
points[3].reset(bottomRight);
Ref<DetectorResult> detectorResult(new DetectorResult(bits, points));
QSharedPointer<DetectorResult> detectorResult(new DetectorResult(bits, points));
return detectorResult;
}
@ -259,8 +259,8 @@ Ref<DetectorResult> Detector::detect() {
* Calculates the position of the white top right module using the output of the rectangle detector
* for a rectangular matrix
*/
Ref<ResultPoint> Detector::correctTopRightRectangular(Ref<ResultPoint> bottomLeft,
Ref<ResultPoint> bottomRight, Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight,
QSharedPointer<ResultPoint> Detector::correctTopRightRectangular(QSharedPointer<ResultPoint> bottomLeft,
QSharedPointer<ResultPoint> bottomRight, QSharedPointer<ResultPoint> topLeft, QSharedPointer<ResultPoint> topRight,
int dimensionTop, int dimensionRight) {
float corr = distance(bottomLeft, bottomRight) / (float) dimensionTop;
@ -268,7 +268,7 @@ Ref<ResultPoint> Detector::correctTopRightRectangular(Ref<ResultPoint> bottomLef
float cos = (topRight->getX() - topLeft->getX()) / norm;
float sin = (topRight->getY() - topLeft->getY()) / norm;
Ref<ResultPoint> c1(
QSharedPointer<ResultPoint> c1(
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
corr = distance(bottomLeft, topLeft) / (float) dimensionRight;
@ -276,14 +276,14 @@ Ref<ResultPoint> Detector::correctTopRightRectangular(Ref<ResultPoint> bottomLef
cos = (topRight->getX() - bottomRight->getX()) / norm;
sin = (topRight->getY() - bottomRight->getY()) / norm;
Ref<ResultPoint> c2(
QSharedPointer<ResultPoint> c2(
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
if (!isValid(c1)) {
if (isValid(c2)) {
return c2;
}
return Ref<ResultPoint>(NULL);
return QSharedPointer<ResultPoint>(NULL);
}
if (!isValid(c2)) {
return c1;
@ -301,8 +301,8 @@ Ref<ResultPoint> Detector::correctTopRightRectangular(Ref<ResultPoint> bottomLef
* Calculates the position of the white top right module using the output of the rectangle detector
* for a square matrix
*/
Ref<ResultPoint> Detector::correctTopRight(Ref<ResultPoint> bottomLeft,
Ref<ResultPoint> bottomRight, Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight,
QSharedPointer<ResultPoint> Detector::correctTopRight(QSharedPointer<ResultPoint> bottomLeft,
QSharedPointer<ResultPoint> bottomRight, QSharedPointer<ResultPoint> topLeft, QSharedPointer<ResultPoint> topRight,
int dimension) {
float corr = distance(bottomLeft, bottomRight) / (float) dimension;
@ -310,7 +310,7 @@ Ref<ResultPoint> Detector::correctTopRight(Ref<ResultPoint> bottomLeft,
float cos = (topRight->getX() - topLeft->getX()) / norm;
float sin = (topRight->getY() - topLeft->getY()) / norm;
Ref<ResultPoint> c1(
QSharedPointer<ResultPoint> c1(
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
corr = distance(bottomLeft, topLeft) / (float) dimension;
@ -318,14 +318,14 @@ Ref<ResultPoint> Detector::correctTopRight(Ref<ResultPoint> bottomLeft,
cos = (topRight->getX() - bottomRight->getX()) / norm;
sin = (topRight->getY() - bottomRight->getY()) / norm;
Ref<ResultPoint> c2(
QSharedPointer<ResultPoint> c2(
new ResultPoint(topRight->getX() + corr * cos, topRight->getY() + corr * sin));
if (!isValid(c1)) {
if (isValid(c2)) {
return c2;
}
return Ref<ResultPoint>(NULL);
return QSharedPointer<ResultPoint>(NULL);
}
if (!isValid(c2)) {
return c1;
@ -341,17 +341,17 @@ Ref<ResultPoint> Detector::correctTopRight(Ref<ResultPoint> bottomLeft,
return l1 <= l2 ? c1 : c2;
}
bool Detector::isValid(Ref<ResultPoint> p) {
bool Detector::isValid(QSharedPointer<ResultPoint> p) {
return p->getX() >= 0 && p->getX() < image_->getWidth() && p->getY() > 0
&& p->getY() < image_->getHeight();
}
int Detector::distance(Ref<ResultPoint> a, Ref<ResultPoint> b) {
int Detector::distance(QSharedPointer<ResultPoint> a, QSharedPointer<ResultPoint> b) {
return MathUtils::round(ResultPoint::distance(a, b));
}
Ref<ResultPointsAndTransitions> Detector::transitionsBetween(Ref<ResultPoint> from,
Ref<ResultPoint> to) {
QSharedPointer<ResultPointsAndTransitions> Detector::transitionsBetween(QSharedPointer<ResultPoint> from,
QSharedPointer<ResultPoint> to) {
// See QR Code Detector, sizeOfBlackWhiteBlackRun()
int fromX = (int) from->getX();
int fromY = (int) from->getY();
@ -389,15 +389,15 @@ Ref<ResultPointsAndTransitions> Detector::transitionsBetween(Ref<ResultPoint> fr
error -= dx;
}
}
Ref<ResultPointsAndTransitions> result(new ResultPointsAndTransitions(from, to, transitions));
QSharedPointer<ResultPointsAndTransitions> result(new ResultPointsAndTransitions(from, to, transitions));
return result;
}
Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft,
Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft, Ref<ResultPoint> bottomRight,
QSharedPointer<PerspectiveTransform> Detector::createTransform(QSharedPointer<ResultPoint> topLeft,
QSharedPointer<ResultPoint> topRight, QSharedPointer<ResultPoint> bottomLeft, QSharedPointer<ResultPoint> bottomRight,
int dimensionX, int dimensionY) {
Ref<PerspectiveTransform> transform(
QSharedPointer<PerspectiveTransform> transform(
PerspectiveTransform::quadrilateralToQuadrilateral(
0.5f,
0.5f,
@ -418,17 +418,17 @@ Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft,
return transform;
}
Ref<BitMatrix> Detector::sampleGrid(Ref<BitMatrix> image, int dimensionX, int dimensionY,
Ref<PerspectiveTransform> transform) {
QSharedPointer<BitMatrix> Detector::sampleGrid(QSharedPointer<BitMatrix> image, int dimensionX, int dimensionY,
QSharedPointer<PerspectiveTransform> transform) {
GridSampler &sampler = GridSampler::getInstance();
return sampler.sampleGrid(image, dimensionX, dimensionY, transform);
}
void Detector::insertionSort(std::vector<Ref<ResultPointsAndTransitions> > &vector) {
void Detector::insertionSort(std::vector<QSharedPointer<ResultPointsAndTransitions> > &vector) {
int max = int(vector.size());
bool swapped = true;
Ref<ResultPointsAndTransitions> value;
Ref<ResultPointsAndTransitions> valueB;
QSharedPointer<ResultPointsAndTransitions> value;
QSharedPointer<ResultPointsAndTransitions> valueB;
do {
swapped = false;
for (int i = 1; i < max; i++) {
@ -442,6 +442,6 @@ void Detector::insertionSort(std::vector<Ref<ResultPointsAndTransitions> > &vect
} while (swapped);
}
int Detector::compare(Ref<ResultPointsAndTransitions> a, Ref<ResultPointsAndTransitions> b) {
int Detector::compare(QSharedPointer<ResultPointsAndTransitions> a, QSharedPointer<ResultPointsAndTransitions> b) {
return a->getTransitions() - b->getTransitions();
}

View File

@ -31,38 +31,38 @@
namespace zxing {
namespace datamatrix {
class ResultPointsAndTransitions: public Counted {
class ResultPointsAndTransitions {
private:
Ref<ResultPoint> to_;
Ref<ResultPoint> from_;
QSharedPointer<ResultPoint> to_;
QSharedPointer<ResultPoint> from_;
int transitions_;
public:
ResultPointsAndTransitions();
ResultPointsAndTransitions(Ref<ResultPoint> from, Ref<ResultPoint> to, int transitions);
Ref<ResultPoint> getFrom();
Ref<ResultPoint> getTo();
ResultPointsAndTransitions(QSharedPointer<ResultPoint> from, QSharedPointer<ResultPoint> to, int transitions);
QSharedPointer<ResultPoint> getFrom();
QSharedPointer<ResultPoint> getTo();
int getTransitions();
};
class Detector: public Counted {
class Detector {
private:
Ref<BitMatrix> image_;
QSharedPointer<BitMatrix> image_;
protected:
Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimensionX, int dimensionY,
Ref<PerspectiveTransform> transform);
QSharedPointer<BitMatrix> sampleGrid(QSharedPointer<BitMatrix> image, int dimensionX, int dimensionY,
QSharedPointer<PerspectiveTransform> transform);
void insertionSort(std::vector<Ref<ResultPointsAndTransitions> >& vector);
void insertionSort(std::vector<QSharedPointer<ResultPointsAndTransitions> >& vector);
Ref<ResultPoint> correctTopRightRectangular(Ref<ResultPoint> bottomLeft,
Ref<ResultPoint> bottomRight, Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight,
QSharedPointer<ResultPoint> correctTopRightRectangular(QSharedPointer<ResultPoint> bottomLeft,
QSharedPointer<ResultPoint> bottomRight, QSharedPointer<ResultPoint> topLeft, QSharedPointer<ResultPoint> topRight,
int dimensionTop, int dimensionRight);
Ref<ResultPoint> correctTopRight(Ref<ResultPoint> bottomLeft, Ref<ResultPoint> bottomRight,
Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, int dimension);
bool isValid(Ref<ResultPoint> p);
int distance(Ref<ResultPoint> a, Ref<ResultPoint> b);
Ref<ResultPointsAndTransitions> transitionsBetween(Ref<ResultPoint> from, Ref<ResultPoint> to);
QSharedPointer<ResultPoint> correctTopRight(QSharedPointer<ResultPoint> bottomLeft, QSharedPointer<ResultPoint> bottomRight,
QSharedPointer<ResultPoint> topLeft, QSharedPointer<ResultPoint> topRight, int dimension);
bool isValid(QSharedPointer<ResultPoint> p);
int distance(QSharedPointer<ResultPoint> a, QSharedPointer<ResultPoint> b);
QSharedPointer<ResultPointsAndTransitions> transitionsBetween(QSharedPointer<ResultPoint> from, QSharedPointer<ResultPoint> to);
int min(int a, int b) {
return a > b ? b : a;
}
@ -75,17 +75,17 @@ class Detector: public Counted {
}
public:
Ref<BitMatrix> getImage();
Detector(Ref<BitMatrix> image);
QSharedPointer<BitMatrix> getImage();
Detector(QSharedPointer<BitMatrix> image);
virtual Ref<PerspectiveTransform> createTransform(Ref<ResultPoint> topLeft,
Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft, Ref<ResultPoint> bottomRight,
virtual QSharedPointer<PerspectiveTransform> createTransform(QSharedPointer<ResultPoint> topLeft,
QSharedPointer<ResultPoint> topRight, QSharedPointer<ResultPoint> bottomLeft, QSharedPointer<ResultPoint> bottomRight,
int dimensionX, int dimensionY);
Ref<DetectorResult> detect();
QSharedPointer<DetectorResult> detect();
private:
int compare(Ref<ResultPointsAndTransitions> a, Ref<ResultPointsAndTransitions> b);
int compare(QSharedPointer<ResultPointsAndTransitions> a, QSharedPointer<ResultPointsAndTransitions> b);
};
}

View File

@ -24,16 +24,16 @@ ByQuadrantReader::ByQuadrantReader(Reader& delegate) : delegate_(delegate) {}
ByQuadrantReader::~ByQuadrantReader(){}
Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image){
QSharedPointer<Result> ByQuadrantReader::decode(QSharedPointer<BinaryBitmap> image){
return decode(image, DecodeHints::DEFAULT_HINT);
}
Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints){
QSharedPointer<Result> ByQuadrantReader::decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints){
int width = image->getWidth();
int height = image->getHeight();
int halfWidth = width / 2;
int halfHeight = height / 2;
Ref<BinaryBitmap> topLeft = image->crop(0, 0, halfWidth, halfHeight);
QSharedPointer<BinaryBitmap> topLeft = image->crop(0, 0, halfWidth, halfHeight);
try {
return delegate_.decode(topLeft, hints);
} catch (ReaderException const& re) {
@ -41,7 +41,7 @@ Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
// continue
}
Ref<BinaryBitmap> topRight = image->crop(halfWidth, 0, halfWidth, halfHeight);
QSharedPointer<BinaryBitmap> topRight = image->crop(halfWidth, 0, halfWidth, halfHeight);
try {
return delegate_.decode(topRight, hints);
} catch (ReaderException const& re) {
@ -49,7 +49,7 @@ Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
// continue
}
Ref<BinaryBitmap> bottomLeft = image->crop(0, halfHeight, halfWidth, halfHeight);
QSharedPointer<BinaryBitmap> bottomLeft = image->crop(0, halfHeight, halfWidth, halfHeight);
try {
return delegate_.decode(bottomLeft, hints);
} catch (ReaderException const& re) {
@ -57,7 +57,7 @@ Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
// continue
}
Ref<BinaryBitmap> bottomRight = image->crop(halfWidth, halfHeight, halfWidth, halfHeight);
QSharedPointer<BinaryBitmap> bottomRight = image->crop(halfWidth, halfHeight, halfWidth, halfHeight);
try {
return delegate_.decode(bottomRight, hints);
} catch (ReaderException const& re) {
@ -67,7 +67,7 @@ Ref<Result> ByQuadrantReader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
int quarterWidth = halfWidth / 2;
int quarterHeight = halfHeight / 2;
Ref<BinaryBitmap> center = image->crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
QSharedPointer<BinaryBitmap> center = image->crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
return delegate_.decode(center, hints);
}

View File

@ -32,8 +32,8 @@ class ByQuadrantReader : public Reader {
public:
ByQuadrantReader(Reader& delegate);
virtual ~ByQuadrantReader();
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image);
virtual QSharedPointer<Result> decode(QSharedPointer<BinaryBitmap> image, DecodeHints hints);
};
}

View File

@ -34,9 +34,9 @@ GenericMultipleBarcodeReader::GenericMultipleBarcodeReader(Reader& delegate)
GenericMultipleBarcodeReader::~GenericMultipleBarcodeReader(){}
vector<Ref<Result> > GenericMultipleBarcodeReader::decodeMultiple(Ref<BinaryBitmap> image,
vector<QSharedPointer<Result> > GenericMultipleBarcodeReader::decodeMultiple(QSharedPointer<BinaryBitmap> image,
DecodeHints hints) {
vector<Ref<Result> > results;
vector<QSharedPointer<Result> > results;
doDecodeMultiple(image, hints, results, 0, 0, 0);
if (results.empty()){
throw ReaderException("No code detected");
@ -44,16 +44,16 @@ vector<Ref<Result> > GenericMultipleBarcodeReader::decodeMultiple(Ref<BinaryBitm
return results;
}
void GenericMultipleBarcodeReader::doDecodeMultiple(Ref<BinaryBitmap> image,
void GenericMultipleBarcodeReader::doDecodeMultiple(QSharedPointer<BinaryBitmap> image,
DecodeHints hints,
vector<Ref<Result> >& results,
vector<QSharedPointer<Result> >& results,
int xOffset,
int yOffset,
int currentDepth) {
if (currentDepth > MAX_DEPTH) {
return;
}
Ref<Result> result;
QSharedPointer<Result> result;
try {
result = delegate_.decode(image, hints);
} catch (ReaderException const& ignored) {
@ -62,7 +62,7 @@ void GenericMultipleBarcodeReader::doDecodeMultiple(Ref<BinaryBitmap> image,
}
bool alreadyFound = false;
for (unsigned int i = 0; i < results.size(); i++) {
Ref<Result> existingResult = results[i];
QSharedPointer<Result> existingResult = results[i];
if (existingResult->getText()->getText() == result->getText()->getText()) {
alreadyFound = true;
break;
@ -72,7 +72,7 @@ void GenericMultipleBarcodeReader::doDecodeMultiple(Ref<BinaryBitmap> image,
results.push_back(translateResultPoints(result, xOffset, yOffset));
}
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints = result->getResultPoints();
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints = result->getResultPoints();
if (resultPoints->empty()) {
return;
}
@ -84,7 +84,7 @@ void GenericMultipleBarcodeReader::doDecodeMultiple(Ref<BinaryBitmap> image,
float maxX = 0.0f;
float maxY = 0.0f;
for (int i = 0; i < resultPoints->size(); i++) {
Ref<ResultPoint> point = resultPoints[i];
QSharedPointer<ResultPoint> point = resultPoints[i];
float x = point->getX();
float y = point->getY();
if (x < minX) {
@ -123,15 +123,15 @@ void GenericMultipleBarcodeReader::doDecodeMultiple(Ref<BinaryBitmap> image,
}
}
Ref<Result> GenericMultipleBarcodeReader::translateResultPoints(Ref<Result> result, int xOffset, int yOffset){
QSharedPointer<std::vector<Ref<ResultPoint>> > oldResultPoints = result->getResultPoints();
QSharedPointer<Result> GenericMultipleBarcodeReader::translateResultPoints(QSharedPointer<Result> result, int xOffset, int yOffset){
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > oldResultPoints = result->getResultPoints();
if (oldResultPoints->empty()) {
return result;
}
QSharedPointer<std::vector<Ref<ResultPoint>> > newResultPoints;
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > newResultPoints;
for (int i = 0; i < oldResultPoints->size(); i++) {
Ref<ResultPoint> oldPoint = oldResultPoints[i];
newResultPoints->values().push_back(Ref<ResultPoint>(new ResultPoint(oldPoint->getX() + xOffset, oldPoint->getY() + yOffset)));
QSharedPointer<ResultPoint> oldPoint = oldResultPoints[i];
newResultPoints->values().push_back(QSharedPointer<ResultPoint>(new ResultPoint(oldPoint->getX() + xOffset, oldPoint->getY() + yOffset)));
}
return Ref<Result>(new Result(result->getText(), result->getRawBytes(), newResultPoints, result->getBarcodeFormat()));
return QSharedPointer<Result>(new Result(result->getText(), result->getRawBytes(), newResultPoints, result->getBarcodeFormat()));
}

View File

@ -26,12 +26,12 @@ namespace multi {
class GenericMultipleBarcodeReader : public MultipleBarcodeReader {
private:
static Ref<Result> translateResultPoints(Ref<Result> result,
static QSharedPointer<Result> translateResultPoints(QSharedPointer<Result> result,
int xOffset,
int yOffset);
void doDecodeMultiple(Ref<BinaryBitmap> image,
void doDecodeMultiple(QSharedPointer<BinaryBitmap> image,
DecodeHints hints,
std::vector<Ref<Result> >& results,
std::vector<QSharedPointer<Result> >& results,
int xOffset,
int yOffset,
int currentDepth);
@ -42,7 +42,7 @@ class GenericMultipleBarcodeReader : public MultipleBarcodeReader {
public:
GenericMultipleBarcodeReader(Reader& delegate);
virtual ~GenericMultipleBarcodeReader();
virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image, DecodeHints hints);
virtual std::vector<QSharedPointer<Result> > decodeMultiple(QSharedPointer<BinaryBitmap> image, DecodeHints hints);
};
}

View File

@ -21,7 +21,7 @@ namespace multi {
MultipleBarcodeReader::~MultipleBarcodeReader() { }
std::vector<Ref<Result> > MultipleBarcodeReader::decodeMultiple(Ref<BinaryBitmap> image) {
std::vector<QSharedPointer<Result> > MultipleBarcodeReader::decodeMultiple(QSharedPointer<BinaryBitmap> image) {
return decodeMultiple(image, DecodeHints::DEFAULT_HINT);
}

View File

@ -26,12 +26,12 @@
namespace zxing {
namespace multi {
class MultipleBarcodeReader : public Counted {
class MultipleBarcodeReader {
protected:
MultipleBarcodeReader() {}
public:
virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image);
virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
virtual std::vector<QSharedPointer<Result> > decodeMultiple(QSharedPointer<BinaryBitmap> image);
virtual std::vector<QSharedPointer<Result> > decodeMultiple(QSharedPointer<BinaryBitmap> image, DecodeHints hints) = 0;
virtual ~MultipleBarcodeReader();
};

View File

@ -26,18 +26,18 @@ QRCodeMultiReader::QRCodeMultiReader(){}
QRCodeMultiReader::~QRCodeMultiReader(){}
std::vector<Ref<Result> > QRCodeMultiReader::decodeMultiple(Ref<BinaryBitmap> image,
std::vector<QSharedPointer<Result> > QRCodeMultiReader::decodeMultiple(QSharedPointer<BinaryBitmap> image,
DecodeHints hints)
{
std::vector<Ref<Result> > results;
std::vector<QSharedPointer<Result> > results;
MultiDetector detector(image->getBlackMatrix());
std::vector<Ref<DetectorResult> > detectorResult = detector.detectMulti(hints);
std::vector<QSharedPointer<DetectorResult> > detectorResult = detector.detectMulti(hints);
for (unsigned int i = 0; i < detectorResult.size(); i++) {
try {
Ref<DecoderResult> decoderResult = getDecoder().decode(detectorResult[i]->getBits());
QSharedPointer<std::vector<Ref<ResultPoint>> > points = detectorResult[i]->getPoints();
Ref<Result> result = Ref<Result>(new Result(decoderResult->getText(),
QSharedPointer<DecoderResult> decoderResult = getDecoder().decode(detectorResult[i]->getBits());
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points = detectorResult[i]->getPoints();
QSharedPointer<Result> result = QSharedPointer<Result>(new Result(decoderResult->getText(),
decoderResult->getRawBytes(),
points, BarcodeFormat::QR_CODE));
// result->putMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult->getByteSegments());

View File

@ -27,7 +27,7 @@ class QRCodeMultiReader: public zxing::qrcode::QRCodeReader, public MultipleBarc
public:
QRCodeMultiReader();
virtual ~QRCodeMultiReader();
virtual std::vector<Ref<Result> > decodeMultiple(Ref<BinaryBitmap> image, DecodeHints hints);
virtual std::vector<QSharedPointer<Result> > decodeMultiple(QSharedPointer<BinaryBitmap> image, DecodeHints hints);
};
}

View File

@ -22,15 +22,15 @@ namespace zxing {
namespace multi {
using namespace zxing::qrcode;
MultiDetector::MultiDetector(Ref<BitMatrix> image) : Detector(image) {}
MultiDetector::MultiDetector(QSharedPointer<BitMatrix> image) : Detector(image) {}
MultiDetector::~MultiDetector(){}
std::vector<Ref<DetectorResult> > MultiDetector::detectMulti(DecodeHints hints){
Ref<BitMatrix> image = getImage();
std::vector<QSharedPointer<DetectorResult> > MultiDetector::detectMulti(DecodeHints hints){
QSharedPointer<BitMatrix> image = getImage();
MultiFinderPatternFinder finder = MultiFinderPatternFinder(image, hints.getResultPointCallback());
std::vector<Ref<FinderPatternInfo> > info = finder.findMulti(hints);
std::vector<Ref<DetectorResult> > result;
std::vector<QSharedPointer<FinderPatternInfo> > info = finder.findMulti(hints);
std::vector<QSharedPointer<DetectorResult> > result;
for(unsigned int i = 0; i < info.size(); i++){
try{
result.push_back(processFinderPatternInfo(info[i]));

View File

@ -26,9 +26,9 @@ namespace multi {
class MultiDetector : public zxing::qrcode::Detector {
public:
MultiDetector(Ref<BitMatrix> image);
MultiDetector(QSharedPointer<BitMatrix> image);
virtual ~MultiDetector();
virtual std::vector<Ref<DetectorResult> > detectMulti(DecodeHints hints);
virtual std::vector<QSharedPointer<DetectorResult> > detectMulti(DecodeHints hints);
};
}

View File

@ -45,24 +45,24 @@ const float MultiFinderPatternFinder::DIFF_MODSIZE_CUTOFF = 0.5f;
namespace {
bool compareModuleSize(Ref<FinderPattern> a, Ref<FinderPattern> b){
bool compareModuleSize(QSharedPointer<FinderPattern> a, QSharedPointer<FinderPattern> b){
float value = a->getEstimatedModuleSize() - b->getEstimatedModuleSize();
return value < 0.0;
}
}
MultiFinderPatternFinder::MultiFinderPatternFinder(Ref<BitMatrix> image,
Ref<ResultPointCallback> resultPointCallback)
MultiFinderPatternFinder::MultiFinderPatternFinder(QSharedPointer<BitMatrix> image,
QSharedPointer<ResultPointCallback> resultPointCallback)
: FinderPatternFinder(image, resultPointCallback)
{
}
MultiFinderPatternFinder::~MultiFinderPatternFinder(){}
vector<Ref<FinderPatternInfo> > MultiFinderPatternFinder::findMulti(DecodeHints const& hints){
vector<QSharedPointer<FinderPatternInfo> > MultiFinderPatternFinder::findMulti(DecodeHints const& hints){
bool tryHarder = hints.getTryHarder();
Ref<BitMatrix> image = image_; // Protected member
QSharedPointer<BitMatrix> image = image_; // Protected member
int maxI = image->getHeight();
int maxJ = image->getWidth();
// We are looking for black/white/black/white/black modules in
@ -125,18 +125,18 @@ vector<Ref<FinderPatternInfo> > MultiFinderPatternFinder::findMulti(DecodeHints
handlePossibleCenter(stateCount, i, maxJ);
} // end if foundPatternCross
} // for i=iSkip-1 ...
vector<vector<Ref<FinderPattern> > > patternInfo = selectBestPatterns();
vector<Ref<FinderPatternInfo> > result;
vector<vector<QSharedPointer<FinderPattern> > > patternInfo = selectBestPatterns();
vector<QSharedPointer<FinderPatternInfo> > result;
for (unsigned int i = 0; i < patternInfo.size(); i++) {
vector<Ref<FinderPattern> > pattern = patternInfo[i];
vector<QSharedPointer<FinderPattern> > pattern = patternInfo[i];
pattern = FinderPatternFinder::orderBestPatterns(pattern);
result.push_back(Ref<FinderPatternInfo>(new FinderPatternInfo(pattern)));
result.push_back(QSharedPointer<FinderPatternInfo>(new FinderPatternInfo(pattern)));
}
return result;
}
vector<vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectBestPatterns(){
vector<Ref<FinderPattern> > possibleCenters = possibleCenters_;
vector<vector<QSharedPointer<FinderPattern> > > MultiFinderPatternFinder::selectBestPatterns(){
vector<QSharedPointer<FinderPattern> > possibleCenters = possibleCenters_;
int size = int(possibleCenters.size());
@ -145,7 +145,7 @@ vector<vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectBestPattern
throw ReaderException("No code detected");
}
vector<vector<Ref<FinderPattern> > > results;
vector<vector<QSharedPointer<FinderPattern> > > results;
/*
* Begin HE modifications to safely detect multiple codes of equal size
@ -175,9 +175,9 @@ vector<vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectBestPattern
*/
for (int i1 = 0; i1 < (size - 2); i1++) {
Ref<FinderPattern> p1 = possibleCenters[i1];
QSharedPointer<FinderPattern> p1 = possibleCenters[i1];
for (int i2 = i1 + 1; i2 < (size - 1); i2++) {
Ref<FinderPattern> p2 = possibleCenters[i2];
QSharedPointer<FinderPattern> p2 = possibleCenters[i2];
// Compare the expected module sizes; if they are really off, skip
float vModSize12 = (p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize()) / min(p1->getEstimatedModuleSize(), p2->getEstimatedModuleSize());
float vModSize12A = abs(p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize());
@ -187,7 +187,7 @@ vector<vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectBestPattern
break;
}
for (int i3 = i2 + 1; i3 < size; i3++) {
Ref<FinderPattern> p3 = possibleCenters[i3];
QSharedPointer<FinderPattern> p3 = possibleCenters[i3];
// Compare the expected module sizes; if they are really off, skip
float vModSize23 = (p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize()) / min(p2->getEstimatedModuleSize(), p3->getEstimatedModuleSize());
float vModSize23A = abs(p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize());
@ -196,13 +196,13 @@ vector<vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectBestPattern
// any more interesting elements for the given p1.
break;
}
vector<Ref<FinderPattern> > test;
vector<QSharedPointer<FinderPattern> > test;
test.push_back(p1);
test.push_back(p2);
test.push_back(p3);
test = FinderPatternFinder::orderBestPatterns(test);
// Calculate the distances: a = topleft-bottomleft, b=topleft-topright, c = diagonal
Ref<FinderPatternInfo> info = Ref<FinderPatternInfo>(new FinderPatternInfo(test));
QSharedPointer<FinderPatternInfo> info = QSharedPointer<FinderPatternInfo>(new FinderPatternInfo(test));
float dA = FinderPatternFinder::distance(info->getTopLeft(), info->getBottomLeft());
float dC = FinderPatternFinder::distance(info->getTopRight(), info->getBottomLeft());
float dB = FinderPatternFinder::distance(info->getTopLeft(), info->getTopRight());

View File

@ -26,7 +26,7 @@ namespace multi {
class MultiFinderPatternFinder : zxing::qrcode::FinderPatternFinder {
private:
std::vector<std::vector<Ref<zxing::qrcode::FinderPattern> > > selectBestPatterns();
std::vector<std::vector<QSharedPointer<zxing::qrcode::FinderPattern> > > selectBestPatterns();
static const float MAX_MODULE_COUNT_PER_EDGE;
static const float MIN_MODULE_COUNT_PER_EDGE;
@ -34,9 +34,9 @@ class MultiFinderPatternFinder : zxing::qrcode::FinderPatternFinder {
static const float DIFF_MODSIZE_CUTOFF;
public:
MultiFinderPatternFinder(Ref<BitMatrix> image, Ref<ResultPointCallback> resultPointCallback);
MultiFinderPatternFinder(QSharedPointer<BitMatrix> image, QSharedPointer<ResultPointCallback> resultPointCallback);
virtual ~MultiFinderPatternFinder();
virtual std::vector<Ref<zxing::qrcode::FinderPatternInfo> > findMulti(DecodeHints const& hints);
virtual std::vector<QSharedPointer<zxing::qrcode::FinderPatternInfo> > findMulti(DecodeHints const& hints);
};

View File

@ -76,7 +76,7 @@ const int CodaBarReader::PADDING =
CodaBarReader::CodaBarReader()
: counters(80, 0), counterLength(0) {}
Ref<Result> CodaBarReader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::DecodeHints /*hints*/) {
QSharedPointer<Result> CodaBarReader::decodeRow(int rowNumber, QSharedPointer<BitArray> row, zxing::DecodeHints /*hints*/) {
{ // Arrays.fill(counters, 0);
int size = int(counters.size());
@ -154,13 +154,13 @@ Ref<Result> CodaBarReader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
}
float right = (float) runningCount;
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints(2);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints(2);
resultPoints[0] =
Ref<OneDResultPoint>(new OneDResultPoint(left, (float) rowNumber));
QSharedPointer<OneDResultPoint>(new OneDResultPoint(left, (float) rowNumber));
resultPoints[1] =
Ref<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
QSharedPointer<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
return Ref<Result>(new Result(Ref<String>(new String(decodeRowResult)),
return QSharedPointer<Result>(new Result(QSharedPointer<String>(new String(decodeRowResult)),
QSharedPointer<std::vector<zxing::byte>>(),
resultPoints,
BarcodeFormat::CODABAR));
@ -233,7 +233,7 @@ void CodaBarReader::validatePattern(int start) {
* uses our builtin "counters" member for storage.
* @param row row to count from
*/
void CodaBarReader::setCounters(Ref<BitArray> row) {
void CodaBarReader::setCounters(QSharedPointer<BitArray> row) {
counterLength = 0;
// Start from the first white bit.
int i = row->getNextUnset(0);

View File

@ -37,12 +37,12 @@ private:
public:
CodaBarReader();
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row, DecodeHints hints);
QSharedPointer<Result> decodeRow(int rowNumber, QSharedPointer<BitArray> row, DecodeHints hints);
void validatePattern(int start);
private:
void setCounters(Ref<BitArray> row);
void setCounters(QSharedPointer<BitArray> row);
void counterAppend(int e);
int findStartPattern();

View File

@ -179,7 +179,7 @@ const int CODE_PATTERNS[CODE_PATTERNS_LENGTH][6] = {
Code128Reader::Code128Reader(){}
vector<int> Code128Reader::findStartPattern(Ref<BitArray> row){
vector<int> Code128Reader::findStartPattern(QSharedPointer<BitArray> row){
int width = row->getSize();
int rowOffset = row->getNextSet(0);
@ -229,7 +229,7 @@ vector<int> Code128Reader::findStartPattern(Ref<BitArray> row){
throw NotFoundException();
}
int Code128Reader::decodeCode(Ref<BitArray> row, vector<int>& counters, int rowOffset) {
int Code128Reader::decodeCode(QSharedPointer<BitArray> row, vector<int>& counters, int rowOffset) {
recordPattern(row, rowOffset, counters);
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
int bestMatch = -1;
@ -249,7 +249,7 @@ int Code128Reader::decodeCode(Ref<BitArray> row, vector<int>& counters, int rowO
}
}
Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::DecodeHints hints) {
QSharedPointer<Result> Code128Reader::decodeRow(int rowNumber, QSharedPointer<BitArray> row, zxing::DecodeHints hints) {
bool convertFNC1 = hints.containsFormat(zxing::BarcodeFormat(zxing::BarcodeFormat::Value::ASSUME_GS1));
vector<int> startPatternInfo (findStartPattern(row));
@ -537,13 +537,13 @@ Ref<Result> Code128Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::De
rawBytes[i] = rawCodes[i];
}
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints(2);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints(2);
resultPoints[0] =
Ref<OneDResultPoint>(new OneDResultPoint(left, (float) rowNumber));
QSharedPointer<OneDResultPoint>(new OneDResultPoint(left, (float) rowNumber));
resultPoints[1] =
Ref<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
QSharedPointer<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
return Ref<Result>(new Result(Ref<String>(new String(result)), rawBytes, resultPoints,
return QSharedPointer<Result>(new Result(QSharedPointer<String>(new String(result)), rawBytes, resultPoints,
BarcodeFormat::CODE_128));
}

View File

@ -29,13 +29,13 @@ private:
static const int MAX_AVG_VARIANCE;
static const int MAX_INDIVIDUAL_VARIANCE;
static std::vector<int> findStartPattern(Ref<BitArray> row);
static int decodeCode(Ref<BitArray> row,
static std::vector<int> findStartPattern(QSharedPointer<BitArray> row);
static int decodeCode(QSharedPointer<BitArray> row,
std::vector<int>& counters,
int rowOffset);
public:
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row, DecodeHints hints);
QSharedPointer<Result> decodeRow(int rowNumber, QSharedPointer<BitArray> row, DecodeHints hints);
Code128Reader();
~Code128Reader();

View File

@ -92,7 +92,7 @@ Code39Reader::Code39Reader(bool usingCheckDigit_, bool extendedMode_) {
init(usingCheckDigit_, extendedMode_);
}
Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::DecodeHints /*hints*/) {
QSharedPointer<Result> Code39Reader::decodeRow(int rowNumber, QSharedPointer<BitArray> row, zxing::DecodeHints /*hints*/) {
std::vector<int>& theCounters (counters);
{ // Arrays.fill(counters, 0);
int size = int(theCounters.size());
@ -154,28 +154,28 @@ Ref<Result> Code39Reader::decodeRow(int rowNumber, Ref<BitArray> row, zxing::Dec
throw NotFoundException();
}
Ref<String> resultString;
QSharedPointer<String> resultString;
if (extendedMode) {
resultString = decodeExtended(result);
} else {
resultString = Ref<String>(new String(result));
resultString = QSharedPointer<String>(new String(result));
}
float left = (float) (start[1] + start[0]) / 2.0f;
float right = lastStart + lastPatternSize / 2.0f;
QSharedPointer<std::vector<Ref<ResultPoint>> > resultPoints (2);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > resultPoints (2);
resultPoints[0] =
Ref<OneDResultPoint>(new OneDResultPoint(left, (float) rowNumber));
QSharedPointer<OneDResultPoint>(new OneDResultPoint(left, (float) rowNumber));
resultPoints[1] =
Ref<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
QSharedPointer<OneDResultPoint>(new OneDResultPoint(right, (float) rowNumber));
return Ref<Result>(
return QSharedPointer<Result>(
new Result(resultString, QSharedPointer<std::vector<zxing::byte>>(), resultPoints, BarcodeFormat::CODE_39)
);
}
vector<int> Code39Reader::findAsteriskPattern(Ref<BitArray> row, vector<int>& counters){
vector<int> Code39Reader::findAsteriskPattern(QSharedPointer<BitArray> row, vector<int>& counters){
int width = row->getSize();
int rowOffset = row->getNextSet(0);
@ -271,7 +271,7 @@ char Code39Reader::patternToChar(int pattern){
throw ReaderException("");
}
Ref<String> Code39Reader::decodeExtended(std::string encoded){
QSharedPointer<String> Code39Reader::decodeExtended(std::string encoded){
int length = int(encoded.length());
std::string tmpDecoded;
for (int i = 0; i < length; i++) {
@ -324,6 +324,6 @@ Ref<String> Code39Reader::decodeExtended(std::string encoded){
tmpDecoded.append(1, c);
}
}
Ref<String> decoded(new String(tmpDecoded));
QSharedPointer<String> decoded(new String(tmpDecoded));
return decoded;
}

View File

@ -41,11 +41,11 @@ private:
void init(bool usingCheckDigit = false, bool extendedMode = false);
static std::vector<int> findAsteriskPattern(Ref<BitArray> row,
static std::vector<int> findAsteriskPattern(QSharedPointer<BitArray> row,
std::vector<int>& counters);
static int toNarrowWidePattern(std::vector<int>& counters);
static char patternToChar(int pattern);
static Ref<String> decodeExtended(std::string encoded);
static QSharedPointer<String> decodeExtended(std::string encoded);
void append(char* s, char c);
@ -54,7 +54,7 @@ public:
Code39Reader(bool usingCheckDigit_);
Code39Reader(bool usingCheckDigit_, bool extendedMode_);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row, DecodeHints hints);
QSharedPointer<Result> decodeRow(int rowNumber, QSharedPointer<BitArray> row, DecodeHints hints);
};
}

Some files were not shown because too many files have changed in this diff Show More