mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Adjust tolerance of method that decides whether a finder/alignment pattern has been crossed so that it passes on low resolution images more correctly -- just a matter of resorting to some floating point math.
git-svn-id: https://zxing.googlecode.com/svn/trunk@18 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
149c7f1b8a
commit
f0a299ec80
|
@ -164,8 +164,9 @@ final class AlignmentPatternFinder {
|
|||
*/
|
||||
private boolean foundPatternCross(int[] stateCount) {
|
||||
float moduleSize = this.moduleSize;
|
||||
float maxVariance = moduleSize / 2.5f;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (2.0f * Math.abs(moduleSize - stateCount[i]) >= moduleSize) {
|
||||
if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,13 +178,14 @@ final class FinderPatternFinder {
|
|||
if (totalModuleSize < 7) {
|
||||
return false;
|
||||
}
|
||||
int moduleSize = totalModuleSize / 7;
|
||||
// Allow less than 50% deviance from 1-1-3-1-1 pattern
|
||||
return Math.abs(moduleSize - stateCount[0]) << 1 <= moduleSize &&
|
||||
Math.abs(moduleSize - stateCount[1]) << 1 <= moduleSize &&
|
||||
Math.abs(3 * moduleSize - stateCount[2]) << 1 <= 3 * moduleSize &&
|
||||
Math.abs(moduleSize - stateCount[3]) << 1 <= moduleSize &&
|
||||
Math.abs(moduleSize - stateCount[4]) << 1 <= moduleSize;
|
||||
float moduleSize = (float) totalModuleSize / 7.0f;
|
||||
float maxVariance = moduleSize / 2.5f;
|
||||
// Allow less than 40% variance from 1-1-3-1-1 proportions
|
||||
return Math.abs(moduleSize - stateCount[0]) < maxVariance &&
|
||||
Math.abs(moduleSize - stateCount[1]) < maxVariance &&
|
||||
Math.abs(3.0f * moduleSize - stateCount[2]) < 3.0f * maxVariance &&
|
||||
Math.abs(moduleSize - stateCount[3]) < maxVariance &&
|
||||
Math.abs(moduleSize - stateCount[4]) < maxVariance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue