mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Remove fixed sizes from C++ itf readers
Closes Issue 1672 git-svn-id: https://zxing.googlecode.com/svn/trunk@2684 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
57dc2ca742
commit
71a01f1558
|
@ -38,6 +38,9 @@ public:
|
||||||
Array(T const* ts, int n) :
|
Array(T const* ts, int n) :
|
||||||
Counted(), values_(ts, ts+n) {
|
Counted(), values_(ts, ts+n) {
|
||||||
}
|
}
|
||||||
|
Array(T const* ts, T const* te) :
|
||||||
|
Counted(), values_(ts, te) {
|
||||||
|
}
|
||||||
Array(T v, int n) :
|
Array(T v, int n) :
|
||||||
Counted(), values_(n, v) {
|
Counted(), values_(n, v) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,34 +40,29 @@ using zxing::BitArray;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const int W = 3; // Pixel width of a wide line
|
const int W = 3; // Pixel width of a wide line
|
||||||
const int N = 1; // Pixed width of a narrow line
|
const int N = 1; // Pixed width of a narrow line
|
||||||
|
|
||||||
const int DEFAULT_ALLOWED_LENGTHS_LEN = 10;
|
const int DEFAULT_ALLOWED_LENGTHS_[] =
|
||||||
const int DEFAULT_ALLOWED_LENGTHS_[DEFAULT_ALLOWED_LENGTHS_LEN] =
|
{ 48, 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 };
|
||||||
{ 48, 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 };
|
const ArrayRef<int> DEFAULT_ALLOWED_LENGTHS (new Array<int>(VECTOR_INIT(DEFAULT_ALLOWED_LENGTHS_)));
|
||||||
const ArrayRef<int> DEFAULT_ALLOWED_LENGTHS (new Array<int>(DEFAULT_ALLOWED_LENGTHS_,
|
|
||||||
DEFAULT_ALLOWED_LENGTHS_LEN ));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start/end guard pattern.
|
* Start/end guard pattern.
|
||||||
*
|
*
|
||||||
* Note: The end pattern is reversed because the row is reversed before
|
* Note: The end pattern is reversed because the row is reversed before
|
||||||
* searching for the END_PATTERN
|
* searching for the END_PATTERN
|
||||||
*/
|
*/
|
||||||
const int START_PATTERN_LEN = 4;
|
const int START_PATTERN_[] = {N, N, N, N};
|
||||||
const int START_PATTERN_[START_PATTERN_LEN] = {N, N, N, N};
|
const vector<int> START_PATTERN (VECTOR_INIT(START_PATTERN_));
|
||||||
const vector<int> START_PATTERN (VECTOR_INIT(START_PATTERN_));
|
|
||||||
|
|
||||||
const int END_PATTERN_REVERSED_LEN = 3;
|
const int END_PATTERN_REVERSED_[] = {N, N, W};
|
||||||
const int END_PATTERN_REVERSED_[END_PATTERN_REVERSED_LEN] = {N, N, W};
|
const vector<int> END_PATTERN_REVERSED (VECTOR_INIT(END_PATTERN_REVERSED_));
|
||||||
const vector<int> END_PATTERN_REVERSED (VECTOR_INIT(END_PATTERN_REVERSED_));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patterns of Wide / Narrow lines to indicate each digit
|
* Patterns of Wide / Narrow lines to indicate each digit
|
||||||
*/
|
*/
|
||||||
const int PATTERNS_LEN = 10;
|
const int PATTERNS[][5] = {
|
||||||
const int PATTERNS[PATTERNS_LEN][5] = {
|
|
||||||
{N, N, W, W, N}, // 0
|
{N, N, W, W, N}, // 0
|
||||||
{W, N, N, N, W}, // 1
|
{W, N, N, N, W}, // 1
|
||||||
{N, W, N, N, W}, // 2
|
{N, W, N, N, W}, // 2
|
||||||
|
@ -78,7 +73,7 @@ namespace {
|
||||||
{N, N, N, W, W}, // 7
|
{N, N, N, W, W}, // 7
|
||||||
{W, N, N, W, N}, // 8
|
{W, N, N, W, N}, // 8
|
||||||
{N, W, N, W, N} // 9
|
{N, W, N, W, N} // 9
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +318,7 @@ int ITFReader::decodeDigit(vector<int>& counters){
|
||||||
|
|
||||||
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
||||||
int bestMatch = -1;
|
int bestMatch = -1;
|
||||||
int max = PATTERNS_LEN;
|
int max = sizeof(PATTERNS)/sizeof(PATTERNS[0]);
|
||||||
for (int i = 0; i < max; i++) {
|
for (int i = 0; i < max; i++) {
|
||||||
int const* pattern = PATTERNS[i];
|
int const* pattern = PATTERNS[i];
|
||||||
int variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE);
|
int variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE);
|
||||||
|
|
Loading…
Reference in a new issue