mirror of https://github.com/status-im/qzxing.git
code cleanup in QZXing.cpp to properly respect 'tryHarder' operation and avoid executing extra decoding operations unless instacted. #151
This commit is contained in:
parent
6e14a1167f
commit
f0a78867d6
|
@ -417,20 +417,12 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
|||
lastDecodeOperationSucceded_ = true;
|
||||
} catch(zxing::Exception &/*e*/){}
|
||||
|
||||
if(!lastDecodeOperationSucceded_)
|
||||
if(!lastDecodeOperationSucceded_ && tryHarder_)
|
||||
{
|
||||
hints.setTryHarder(true);
|
||||
|
||||
try {
|
||||
res = decoder->decode(bb, hints);
|
||||
processingTime = t.elapsed();
|
||||
lastDecodeOperationSucceded_ = true;
|
||||
} catch(zxing::Exception &/*e*/) {}
|
||||
|
||||
if (!lastDecodeOperationSucceded_ &&
|
||||
hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION) &&
|
||||
if(hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION) &&
|
||||
!allowedExtensions_.empty() &&
|
||||
!(hints & DecodeHints::PRODUCT_HINT).isEmpty() ) {
|
||||
!(hints & DecodeHints::PRODUCT_HINT).isEmpty() )
|
||||
hints.setAllowedEanExtensions(std::set<int>());
|
||||
|
||||
try {
|
||||
|
@ -440,7 +432,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
|||
} catch(zxing::Exception &/*e*/) {}
|
||||
}
|
||||
|
||||
if (tryHarder_ && bb->isRotateSupported()) {
|
||||
if (!lastDecodeOperationSucceded_&& tryHarder_ && bb->isRotateSupported()) {
|
||||
Ref<BinaryBitmap> bbTmp = bb;
|
||||
|
||||
for (int i=0; (i<3 && !lastDecodeOperationSucceded_); i++) {
|
||||
|
@ -454,7 +446,6 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo
|
|||
} catch(zxing::Exception &/*e*/) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastDecodeOperationSucceded_) {
|
||||
QString string = QString(res->getText()->getText().c_str());
|
||||
|
|
Loading…
Reference in New Issue