@Override public int compare(FinderPattern center1, FinderPattern center2) { if (center2.getCount() == center1.getCount()) { float dA = Math.abs(center2.getEstimatedModuleSize() - average); float dB = Math.abs(center1.getEstimatedModuleSize() - average); return dA < dB ? 1 : dA == dB ? 0 : -1; } else { return center2.getCount() - center1.getCount(); } }
public int compare(FinderPattern paramFinderPattern1, FinderPattern paramFinderPattern2) { if (paramFinderPattern2.getCount() == paramFinderPattern1.getCount()) { float f1 = Math.abs(paramFinderPattern2.getEstimatedModuleSize() - this.average); float f2 = Math.abs(paramFinderPattern1.getEstimatedModuleSize() - this.average); if (f1 < f2) { return 1; } if (f1 == f2) { return 0; } return -1; } return paramFinderPattern2.getCount() - paramFinderPattern1.getCount(); }
private boolean haveMultiplyConfirmedCenters() { int i = 0; float f1 = 0.0F; int j = this.possibleCenters.size(); Iterator localIterator1 = this.possibleCenters.iterator(); while (localIterator1.hasNext()) { FinderPattern localFinderPattern = (FinderPattern)localIterator1.next(); if (localFinderPattern.getCount() >= 2) { i++; f1 += localFinderPattern.getEstimatedModuleSize(); } } if (i < 3) {} float f3; do { return false; float f2 = f1 / j; f3 = 0.0F; Iterator localIterator2 = this.possibleCenters.iterator(); while (localIterator2.hasNext()) { f3 += Math.abs(((FinderPattern)localIterator2.next()).getEstimatedModuleSize() - f2); } } while (f3 > 0.05F * f1); return true; }
private int findRowSkip() { if (this.possibleCenters.size() <= 1) {} Object localObject; FinderPattern localFinderPattern; for (;;) { return 0; localObject = null; Iterator localIterator = this.possibleCenters.iterator(); while (localIterator.hasNext()) { localFinderPattern = (FinderPattern)localIterator.next(); if (localFinderPattern.getCount() >= 2) { if (localObject != null) { break label63; } localObject = localFinderPattern; } } } label63: this.hasSkipped = true; return (int)(Math.abs(localObject.getX() - localFinderPattern.getX()) - Math.abs(localObject.getY() - localFinderPattern.getY())) / 2; }
/** * @return number of rows we could safely skip during scanning, based on the first two finder * patterns that have been located. In some cases their position will allow us to infer that * the third pattern must lie below a certain point farther down in the image. */ private int findRowSkip() { int max = possibleCenters.size(); if (max <= 1) { return 0; } FinderPattern firstConfirmedCenter = null; for (FinderPattern center : possibleCenters) { if (center.getCount() >= CENTER_QUORUM) { if (firstConfirmedCenter == null) { firstConfirmedCenter = center; } else { // We have two confirmed centers // How far down can we skip before resuming looking for the next // pattern? In the worst case, only the difference between the // difference in the x / y coordinates of the two centers. // This is the case where you find top left last. hasSkipped = true; return (int) (Math.abs(firstConfirmedCenter.getX() - center.getX()) - Math.abs(firstConfirmedCenter.getY() - center.getY())) / 2; } } } return 0; }
/** * @return true iff we have found at least 3 finder patterns that have been detected at least * {@link #CENTER_QUORUM} times each, and, the estimated module size of the candidates is * "pretty similar" */ private boolean haveMultiplyConfirmedCenters() { int confirmedCount = 0; float totalModuleSize = 0.0f; int max = possibleCenters.size(); for (FinderPattern pattern : possibleCenters) { if (pattern.getCount() >= CENTER_QUORUM) { confirmedCount++; totalModuleSize += pattern.getEstimatedModuleSize(); } } if (confirmedCount < 3) { return false; } // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" // and that we need to keep looking. We detect this by asking if the estimated module sizes // vary too much. We arbitrarily say that when the total deviation from average exceeds // 5% of the total module size estimates, it's too much. float average = totalModuleSize / (float) max; float totalDeviation = 0.0f; for (FinderPattern pattern : possibleCenters) { totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average); } return totalDeviation <= 0.05f * totalModuleSize; }