mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
C++ port: Hints infrastructure was added in r1499. This changeset implements reader selection support.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1505 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
8f5201949e
commit
c3b1380ad8
|
@ -21,6 +21,33 @@
|
||||||
#include <zxing/common/IllegalArgumentException.h>
|
#include <zxing/common/IllegalArgumentException.h>
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
|
|
||||||
|
const DecodeHints DecodeHints::PRODUCT_HINT(
|
||||||
|
BARCODEFORMAT_UPC_E_HINT |
|
||||||
|
BARCODEFORMAT_UPC_A_HINT |
|
||||||
|
BARCODEFORMAT_EAN_8_HINT |
|
||||||
|
BARCODEFORMAT_EAN_13_HINT);
|
||||||
|
|
||||||
|
const DecodeHints DecodeHints::ONED_HINT(
|
||||||
|
BARCODEFORMAT_UPC_E_HINT |
|
||||||
|
BARCODEFORMAT_UPC_A_HINT |
|
||||||
|
BARCODEFORMAT_EAN_8_HINT |
|
||||||
|
BARCODEFORMAT_EAN_13_HINT |
|
||||||
|
BARCODEFORMAT_CODE_128_HINT |
|
||||||
|
BARCODEFORMAT_CODE_39_HINT |
|
||||||
|
BARCODEFORMAT_ITF_HINT);
|
||||||
|
|
||||||
|
const DecodeHints DecodeHints::DEFAULT_HINT(
|
||||||
|
BARCODEFORMAT_UPC_E_HINT |
|
||||||
|
BARCODEFORMAT_UPC_A_HINT |
|
||||||
|
BARCODEFORMAT_EAN_8_HINT |
|
||||||
|
BARCODEFORMAT_EAN_13_HINT |
|
||||||
|
BARCODEFORMAT_CODE_128_HINT |
|
||||||
|
BARCODEFORMAT_CODE_39_HINT |
|
||||||
|
BARCODEFORMAT_ITF_HINT |
|
||||||
|
// TODO: uncomment once this passes QA
|
||||||
|
// BARCODEFORMAT_DATA_MATRIX_HINT |
|
||||||
|
BARCODEFORMAT_QR_CODE_HINT);
|
||||||
|
|
||||||
DecodeHints::DecodeHints() {
|
DecodeHints::DecodeHints() {
|
||||||
hints = 0;
|
hints = 0;
|
||||||
}
|
}
|
||||||
|
@ -29,10 +56,6 @@ DecodeHints::DecodeHints(DecodeHintType init) {
|
||||||
hints = init;
|
hints = init;
|
||||||
}
|
}
|
||||||
|
|
||||||
DecodeHints::~DecodeHints() {
|
|
||||||
// if DecodeHintType requires a destructor in the future, call it here
|
|
||||||
}
|
|
||||||
|
|
||||||
void DecodeHints::addFormat(BarcodeFormat toadd) {
|
void DecodeHints::addFormat(BarcodeFormat toadd) {
|
||||||
switch (toadd) {
|
switch (toadd) {
|
||||||
case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break;
|
case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifndef __DECODEHINTS_H_
|
||||||
|
#define __DECODEHINTS_H_
|
||||||
/*
|
/*
|
||||||
* DecodeHintType.h
|
* DecodeHintType.h
|
||||||
* zxing
|
* zxing
|
||||||
|
@ -16,8 +18,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifndef DECODEHINTS_H_
|
|
||||||
#define DECODEHINTS_H_
|
|
||||||
|
|
||||||
#include <zxing/BarcodeFormat.h>
|
#include <zxing/BarcodeFormat.h>
|
||||||
|
|
||||||
|
@ -44,29 +44,13 @@ class DecodeHints {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const DecodeHintType BARCODEFORMAT_PRODUCT_HINT =
|
static const DecodeHints PRODUCT_HINT;
|
||||||
BARCODEFORMAT_UPC_E_HINT |
|
static const DecodeHints ONED_HINT;
|
||||||
BARCODEFORMAT_UPC_A_HINT |
|
static const DecodeHints DEFAULT_HINT;
|
||||||
BARCODEFORMAT_EAN_8_HINT |
|
|
||||||
BARCODEFORMAT_EAN_13_HINT;
|
|
||||||
|
|
||||||
static const DecodeHintType BARCODEFORMAT_ONED_HINT =
|
|
||||||
BARCODEFORMAT_PRODUCT_HINT |
|
|
||||||
BARCODEFORMAT_CODE_128_HINT |
|
|
||||||
BARCODEFORMAT_CODE_39_HINT |
|
|
||||||
BARCODEFORMAT_ITF_HINT;
|
|
||||||
|
|
||||||
static const DecodeHintType BARCODEFORMAT_ANY_HINT =
|
|
||||||
BARCODEFORMAT_ONED_HINT |
|
|
||||||
// TODO: uncomment once this passes QA
|
|
||||||
// BARCODEFORMAT_DATA_MATRIX_HINT |
|
|
||||||
BARCODEFORMAT_QR_CODE_HINT;
|
|
||||||
|
|
||||||
static const DecodeHintType DEFAULT_HINTS = BARCODEFORMAT_ANY_HINT;
|
|
||||||
|
|
||||||
DecodeHints();
|
DecodeHints();
|
||||||
DecodeHints(DecodeHintType init);
|
DecodeHints(DecodeHintType init);
|
||||||
~DecodeHints();
|
|
||||||
void addFormat(BarcodeFormat toadd);
|
void addFormat(BarcodeFormat toadd);
|
||||||
bool containsFormat(BarcodeFormat tocheck) const;
|
bool containsFormat(BarcodeFormat tocheck) const;
|
||||||
void setTryHarder(bool toset);
|
void setTryHarder(bool toset);
|
||||||
|
|
|
@ -28,16 +28,67 @@
|
||||||
|
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
MultiFormatReader::MultiFormatReader() {
|
MultiFormatReader::MultiFormatReader() {
|
||||||
readers.push_back(new zxing::qrcode::QRCodeReader());
|
|
||||||
readers.push_back(new zxing::datamatrix::DataMatrixReader());
|
|
||||||
readers.push_back(new zxing::oned::MultiFormatUPCEANReader());
|
|
||||||
readers.push_back(new zxing::oned::MultiFormatOneDReader());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image, DecodeHints hints){
|
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image) {
|
||||||
for (unsigned int i = 0; i < readers.size(); i++) {
|
setHints(DecodeHints::DEFAULT_HINT);
|
||||||
|
return decodeInternal(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
|
||||||
|
setHints(hints);
|
||||||
|
return decodeInternal(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Result> MultiFormatReader::decodeWithState(Ref<BinaryBitmap> image) {
|
||||||
|
// Make sure to set up the default state so we don't crash
|
||||||
|
if (readers_.size() == 0) {
|
||||||
|
setHints(DecodeHints::DEFAULT_HINT);
|
||||||
|
}
|
||||||
|
return decodeInternal(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiFormatReader::setHints(DecodeHints hints) {
|
||||||
|
hints_ = hints;
|
||||||
|
readers_.clear();
|
||||||
|
bool tryHarder = hints.getTryHarder();
|
||||||
|
|
||||||
|
bool addOneDReader = hints.containsFormat(BarcodeFormat_UPC_E) ||
|
||||||
|
hints.containsFormat(BarcodeFormat_UPC_A) ||
|
||||||
|
hints.containsFormat(BarcodeFormat_EAN_8) ||
|
||||||
|
hints.containsFormat(BarcodeFormat_EAN_13) ||
|
||||||
|
hints.containsFormat(BarcodeFormat_CODE_128) ||
|
||||||
|
hints.containsFormat(BarcodeFormat_CODE_39) ||
|
||||||
|
hints.containsFormat(BarcodeFormat_ITF);
|
||||||
|
if (addOneDReader && !tryHarder) {
|
||||||
|
readers_.push_back(new zxing::oned::MultiFormatOneDReader(hints));
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_QR_CODE)) {
|
||||||
|
readers_.push_back(new zxing::qrcode::QRCodeReader());
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_DATA_MATRIX)) {
|
||||||
|
readers_.push_back(new zxing::datamatrix::DataMatrixReader());
|
||||||
|
}
|
||||||
|
//TODO: add PDF417 here once PDF417 reader is implemented
|
||||||
|
if (addOneDReader && tryHarder) {
|
||||||
|
readers_.push_back(new zxing::oned::MultiFormatOneDReader(hints));
|
||||||
|
}
|
||||||
|
if (readers_.size() == 0) {
|
||||||
|
if (!tryHarder) {
|
||||||
|
readers_.push_back(new zxing::oned::MultiFormatOneDReader(hints));
|
||||||
|
}
|
||||||
|
readers_.push_back(new zxing::qrcode::QRCodeReader());
|
||||||
|
if (tryHarder) {
|
||||||
|
readers_.push_back(new zxing::oned::MultiFormatOneDReader(hints));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Result> MultiFormatReader::decodeInternal(Ref<BinaryBitmap> image) {
|
||||||
|
for (unsigned int i = 0; i < readers_.size(); i++) {
|
||||||
try {
|
try {
|
||||||
return readers[i]->decode(image, hints);
|
return readers_[i]->decode(image, hints_);
|
||||||
} catch (ReaderException re) {
|
} catch (ReaderException re) {
|
||||||
// continue
|
// continue
|
||||||
}
|
}
|
||||||
|
@ -46,8 +97,8 @@ namespace zxing {
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiFormatReader::~MultiFormatReader(){
|
MultiFormatReader::~MultiFormatReader(){
|
||||||
for (unsigned int i = 0; i < readers.size(); i++) {
|
for (unsigned int i = 0; i < readers_.size(); i++) {
|
||||||
delete readers[i];
|
delete readers_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
#ifndef __MULTI_FORMAT_READER_H__
|
||||||
|
#define __MULTI_FORMAT_READER_H__
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MultiFormatBarcodeReader.h
|
* MultiFormatBarcodeReader.h
|
||||||
* ZXing
|
* ZXing
|
||||||
*
|
*
|
||||||
* Created by Lukasz Warchol on 10-01-26.
|
|
||||||
* Modified by Luiz Silva on 09/02/2010.
|
|
||||||
* Copyright 2010 ZXing authors All rights reserved.
|
* Copyright 2010 ZXing authors All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -29,12 +30,20 @@ namespace zxing {
|
||||||
class MultiFormatReader : public Reader {
|
class MultiFormatReader : public Reader {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Reader*>readers;
|
Ref<Result> decodeInternal(Ref<BinaryBitmap> image);
|
||||||
|
|
||||||
|
std::vector<Reader*> readers_;
|
||||||
|
DecodeHints hints_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiFormatReader();
|
MultiFormatReader();
|
||||||
|
|
||||||
|
Ref<Result> decode(Ref<BinaryBitmap> image);
|
||||||
Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
|
Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
|
||||||
|
Ref<Result> decodeWithState(Ref<BinaryBitmap> image);
|
||||||
|
void setHints(DecodeHints hints);
|
||||||
~MultiFormatReader();
|
~MultiFormatReader();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -25,8 +25,7 @@ namespace zxing {
|
||||||
Reader::~Reader() { }
|
Reader::~Reader() { }
|
||||||
|
|
||||||
Ref<Result> Reader::decode(Ref<BinaryBitmap> image) {
|
Ref<Result> Reader::decode(Ref<BinaryBitmap> image) {
|
||||||
DecodeHints hints(hints.DEFAULT_HINTS);
|
return decode(image, DecodeHints::DEFAULT_HINT);
|
||||||
return decode(image, hints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
* Reader.h
|
* Reader.h
|
||||||
* zxing
|
* zxing
|
||||||
*
|
*
|
||||||
* Created by Christian Brunschen on 13/05/2008.
|
* Copyright 2010 ZXing authors All rights reserved.
|
||||||
* Copyright 2008 ZXing authors All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -31,7 +30,7 @@ namespace zxing {
|
||||||
protected:
|
protected:
|
||||||
Reader() {}
|
Reader() {}
|
||||||
public:
|
public:
|
||||||
Ref<Result> decode(Ref<BinaryBitmap> image);
|
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
|
||||||
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
|
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
|
||||||
virtual ~Reader();
|
virtual ~Reader();
|
||||||
};
|
};
|
||||||
|
|
|
@ -214,6 +214,7 @@ namespace zxing {
|
||||||
endPattern[0] = row->getSize() - endPattern[1];
|
endPattern[0] = row->getSize() - endPattern[1];
|
||||||
endPattern[1] = row->getSize() - temp;
|
endPattern[1] = row->getSize() - temp;
|
||||||
|
|
||||||
|
row->reverse();
|
||||||
return endPattern;
|
return endPattern;
|
||||||
} catch (ReaderException re) {
|
} catch (ReaderException re) {
|
||||||
row->reverse();
|
row->reverse();
|
||||||
|
|
|
@ -28,11 +28,28 @@
|
||||||
|
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
namespace oned {
|
namespace oned {
|
||||||
MultiFormatOneDReader::MultiFormatOneDReader() : readers() {
|
MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() {
|
||||||
readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader()));
|
if (hints.containsFormat(BarcodeFormat_EAN_13) ||
|
||||||
readers.push_back(Ref<OneDReader>(new Code39Reader()));
|
hints.containsFormat(BarcodeFormat_EAN_8) ||
|
||||||
readers.push_back(Ref<OneDReader>(new Code128Reader()));
|
hints.containsFormat(BarcodeFormat_UPC_A) ||
|
||||||
readers.push_back(Ref<OneDReader>(new ITFReader()));
|
hints.containsFormat(BarcodeFormat_UPC_E)) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_CODE_39)) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new Code39Reader()));
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_CODE_128)) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new Code128Reader()));
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_ITF)) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new ITFReader()));
|
||||||
|
}
|
||||||
|
if (readers.size() == 0) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
|
||||||
|
readers.push_back(Ref<OneDReader>(new Code39Reader()));
|
||||||
|
readers.push_back(Ref<OneDReader>(new Code128Reader()));
|
||||||
|
readers.push_back(Ref<OneDReader>(new ITFReader()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Result> MultiFormatOneDReader::decodeRow(int rowNumber, Ref<BitArray> row){
|
Ref<Result> MultiFormatOneDReader::decodeRow(int rowNumber, Ref<BitArray> row){
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
#ifndef __MULTI_FORMAT_ONED_READER_H__
|
||||||
|
#define __MULTI_FORMAT_ONED_READER_H__
|
||||||
/*
|
/*
|
||||||
* MultiFormatOneDReader.h
|
* MultiFormatOneDReader.h
|
||||||
* ZXing
|
* ZXing
|
||||||
*
|
*
|
||||||
* Created by Lukasz Warchol on 10-01-25.
|
* Copyright 2010 ZXing authors All rights reserved.
|
||||||
* Copyright 2010 ZXing authors All rights reserved.
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,8 +20,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zxing/oned/OneDReader.h>
|
#include <zxing/oned/OneDReader.h>
|
||||||
#include <zxing/common/BitArray.h>
|
|
||||||
#include <zxing/Result.h>
|
|
||||||
|
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
namespace oned {
|
namespace oned {
|
||||||
|
@ -29,9 +28,11 @@ namespace zxing {
|
||||||
private:
|
private:
|
||||||
std::vector<Ref<OneDReader> > readers;
|
std::vector<Ref<OneDReader> > readers;
|
||||||
public:
|
public:
|
||||||
MultiFormatOneDReader();
|
MultiFormatOneDReader(DecodeHints hints);
|
||||||
|
|
||||||
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
|
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <zxing/oned/EAN13Reader.h>
|
#include <zxing/oned/EAN13Reader.h>
|
||||||
#include <zxing/oned/EAN8Reader.h>
|
#include <zxing/oned/EAN8Reader.h>
|
||||||
#include <zxing/oned/UPCEReader.h>
|
#include <zxing/oned/UPCEReader.h>
|
||||||
|
#include <zxing/oned/UPCAReader.h>
|
||||||
#include <zxing/oned/OneDResultPoint.h>
|
#include <zxing/oned/OneDResultPoint.h>
|
||||||
#include <zxing/common/Array.h>
|
#include <zxing/common/Array.h>
|
||||||
#include <zxing/ReaderException.h>
|
#include <zxing/ReaderException.h>
|
||||||
|
@ -30,13 +31,26 @@
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
namespace oned {
|
namespace oned {
|
||||||
|
|
||||||
MultiFormatUPCEANReader::MultiFormatUPCEANReader() : readers() {
|
MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() {
|
||||||
readers.push_back(Ref<OneDReader>(new EAN13Reader()));
|
if (hints.containsFormat(BarcodeFormat_EAN_13)) {
|
||||||
// UPC-A is covered by EAN-13
|
readers.push_back(Ref<OneDReader>(new EAN13Reader()));
|
||||||
readers.push_back(Ref<OneDReader>(new EAN8Reader()));
|
} else if (hints.containsFormat(BarcodeFormat_UPC_A)) {
|
||||||
readers.push_back(Ref<OneDReader>(new UPCEReader()));
|
readers.push_back(Ref<OneDReader>(new UPCAReader()));
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_EAN_8)) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new EAN8Reader()));
|
||||||
|
}
|
||||||
|
if (hints.containsFormat(BarcodeFormat_UPC_E)) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new UPCEReader()));
|
||||||
|
}
|
||||||
|
if (readers.size() == 0) {
|
||||||
|
readers.push_back(Ref<OneDReader>(new EAN13Reader()));
|
||||||
|
// UPC-A is covered by EAN-13
|
||||||
|
readers.push_back(Ref<OneDReader>(new EAN8Reader()));
|
||||||
|
readers.push_back(Ref<OneDReader>(new UPCEReader()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Result> MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref<BitArray> row){
|
Ref<Result> MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref<BitArray> row){
|
||||||
// Compute this location once and reuse it on multiple implementations
|
// Compute this location once and reuse it on multiple implementations
|
||||||
int size = readers.size();
|
int size = readers.size();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
#ifndef __MULTI_FORMAT_UPC_EAN_READER_H__
|
||||||
|
#define __MULTI_FORMAT_UPC_EAN_READER_H__
|
||||||
/*
|
/*
|
||||||
* MultiFormatUPCEANReader.h
|
* MultiFormatUPCEANReader.h
|
||||||
* ZXing
|
* ZXing
|
||||||
*
|
*
|
||||||
* Created by Lukasz Warchol on 10-01-25.
|
|
||||||
* Copyright 2010 ZXing authors All rights reserved.
|
* Copyright 2010 ZXing authors All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -18,11 +19,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <zxing/oned/OneDReader.h>
|
#include <zxing/oned/OneDReader.h>
|
||||||
#include <zxing/common/BitArray.h>
|
|
||||||
#include <zxing/Result.h>
|
|
||||||
|
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
namespace oned {
|
namespace oned {
|
||||||
|
@ -31,9 +28,11 @@ namespace zxing {
|
||||||
private:
|
private:
|
||||||
std::vector<Ref<OneDReader> > readers;
|
std::vector<Ref<OneDReader> > readers;
|
||||||
public:
|
public:
|
||||||
MultiFormatUPCEANReader();
|
MultiFormatUPCEANReader(DecodeHints hints);
|
||||||
|
|
||||||
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
|
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -76,7 +76,7 @@ int test_image(Image& image, bool hybrid, string expected = "") {
|
||||||
binarizer = new GlobalHistogramBinarizer(source);
|
binarizer = new GlobalHistogramBinarizer(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
DecodeHints hints(hints.DEFAULT_HINTS);
|
DecodeHints hints(DecodeHints::DEFAULT_HINT);
|
||||||
hints.setTryHarder(tryHarder);
|
hints.setTryHarder(tryHarder);
|
||||||
Ref<BinaryBitmap> binary(new BinaryBitmap(binarizer));
|
Ref<BinaryBitmap> binary(new BinaryBitmap(binarizer));
|
||||||
Ref<Result> result(decode(binary, hints));
|
Ref<Result> result(decode(binary, hints));
|
||||||
|
@ -134,7 +134,11 @@ string get_expected(string imagefilename) {
|
||||||
textfilename.replace(dotpos+1, textfilename.length() - dotpos - 1, "txt");
|
textfilename.replace(dotpos+1, textfilename.length() - dotpos - 1, "txt");
|
||||||
char data[MAX_EXPECTED];
|
char data[MAX_EXPECTED];
|
||||||
FILE *fp = fopen(textfilename.data(), "rb");
|
FILE *fp = fopen(textfilename.data(), "rb");
|
||||||
|
|
||||||
|
if (!fp) {
|
||||||
|
// could not open file
|
||||||
|
return "";
|
||||||
|
}
|
||||||
// get file size
|
// get file size
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
int toread = ftell(fp);
|
int toread = ftell(fp);
|
||||||
|
|
Loading…
Reference in a new issue