mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Issue 920 add ITF length 18, make C++ consistent with Java here
git-svn-id: https://zxing.googlecode.com/svn/trunk@1862 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
13fcdc4ffa
commit
7daf9dc760
|
@ -29,7 +29,8 @@ namespace zxing {
|
||||||
static const int W = 3; // Pixel width of a wide line
|
static const int W = 3; // Pixel width of a wide line
|
||||||
static const int N = 1; // Pixed width of a narrow line
|
static const int N = 1; // Pixed width of a narrow line
|
||||||
|
|
||||||
const int DEFAULT_ALLOWED_LENGTHS[4] = { 6, 10, 14, 44 };
|
const int DEFAULT_ALLOWED_LENGTHS_LEN = 10;
|
||||||
|
const int DEFAULT_ALLOWED_LENGTHS[DEFAULT_ALLOWED_LENGTHS_LEN] = { 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start/end guard pattern.
|
* Start/end guard pattern.
|
||||||
|
@ -77,11 +78,14 @@ namespace zxing {
|
||||||
decodeMiddle(row, startRange[1], endRange[0], tmpResult);
|
decodeMiddle(row, startRange[1], endRange[0], tmpResult);
|
||||||
|
|
||||||
// To avoid false positives with 2D barcodes (and other patterns), make
|
// To avoid false positives with 2D barcodes (and other patterns), make
|
||||||
// an assumption that the decoded string must be 6, 10 or 14 digits.
|
// an assumption that the decoded string must be a known length
|
||||||
int length = tmpResult.length();
|
int length = tmpResult.length();
|
||||||
bool lengthOK = false;
|
bool lengthOK = false;
|
||||||
if (length == 6 || length == 10 || length == 14) {
|
for (int i = 0; i < DEFAULT_ALLOWED_LENGTHS_LEN; i++) {
|
||||||
lengthOK = true;
|
if (length == DEFAULT_ALLOWED_LENGTHS[i]) {
|
||||||
|
lengthOK = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!lengthOK) {
|
if (!lengthOK) {
|
||||||
throw ReaderException("not enough characters count");
|
throw ReaderException("not enough characters count");
|
||||||
|
|
Loading…
Reference in a new issue