*/\r
private boolean foundPatternCross(int[] stateCount) {\r
float moduleSize = this.moduleSize;\r
+ float maxVariance = moduleSize / 2.5f;\r
for (int i = 0; i < 3; i++) {\r
- if (2.0f * Math.abs(moduleSize - stateCount[i]) >= moduleSize) {\r
+ if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) {\r
return false;\r
}\r
}\r
if (totalModuleSize < 7) {\r
return false;\r
}\r
- int moduleSize = totalModuleSize / 7;\r
- // Allow less than 50% deviance from 1-1-3-1-1 pattern\r
- return Math.abs(moduleSize - stateCount[0]) << 1 <= moduleSize &&\r
- Math.abs(moduleSize - stateCount[1]) << 1 <= moduleSize &&\r
- Math.abs(3 * moduleSize - stateCount[2]) << 1 <= 3 * moduleSize &&\r
- Math.abs(moduleSize - stateCount[3]) << 1 <= moduleSize &&\r
- Math.abs(moduleSize - stateCount[4]) << 1 <= moduleSize;\r
+ float moduleSize = (float) totalModuleSize / 7.0f;\r
+ float maxVariance = moduleSize / 2.5f;\r
+ // Allow less than 40% variance from 1-1-3-1-1 proportions\r
+ return Math.abs(moduleSize - stateCount[0]) < maxVariance &&\r
+ Math.abs(moduleSize - stateCount[1]) < maxVariance &&\r
+ Math.abs(3.0f * moduleSize - stateCount[2]) < 3.0f * maxVariance &&\r
+ Math.abs(moduleSize - stateCount[3]) < maxVariance &&\r
+ Math.abs(moduleSize - stateCount[4]) < maxVariance;\r
}\r
\r
/**\r