foundPatternDiagonal static method
@param stateCount count of black/white/black/white/black pixels just read @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios used by finder patterns to be considered a match
Implementation
//@protected
static bool foundPatternDiagonal(List<int> stateCount) {
int totalModuleSize = 0;
for (int i = 0; i < 5; i++) {
final count = stateCount[i];
if (count == 0) {
return false;
}
totalModuleSize += count;
}
if (totalModuleSize < 7) {
return false;
}
final moduleSize = totalModuleSize / 7.0;
final maxVariance = moduleSize / 1.333;
// Allow less than 75% variance from 1-1-3-1-1 proportions
return (moduleSize - stateCount[0]).abs() < maxVariance &&
(moduleSize - stateCount[1]).abs() < maxVariance &&
(3.0 * moduleSize - stateCount[2]).abs() < 3 * maxVariance &&
(moduleSize - stateCount[3]).abs() < maxVariance &&
(moduleSize - stateCount[4]).abs() < maxVariance;
}