mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Quick shortening of a method in FinderPatternFinder that I just noticed
git-svn-id: https://zxing.googlecode.com/svn/trunk@523 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
5c8b0558e1
commit
a79fad4b9c
|
@ -473,29 +473,20 @@ final class FinderPatternFinder {
|
||||||
throw new ReaderException("Could not find three finder patterns");
|
throw new ReaderException("Could not find three finder patterns");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size == 3) {
|
if (size > 3) {
|
||||||
// Found just enough -- hope these are good!
|
// Throw away all but those first size candidate points we found.
|
||||||
return new FinderPattern[]{
|
possibleCenters.setSize(size);
|
||||||
(FinderPattern) possibleCenters.elementAt(0),
|
// We need to pick the best three. Find the most
|
||||||
(FinderPattern) possibleCenters.elementAt(1),
|
// popular ones whose module size is nearest the average
|
||||||
(FinderPattern) possibleCenters.elementAt(2)
|
float averageModuleSize = 0.0f;
|
||||||
};
|
for (int i = 0; i < size; i++) {
|
||||||
|
averageModuleSize += ((FinderPattern) possibleCenters.elementAt(i)).getEstimatedModuleSize();
|
||||||
|
}
|
||||||
|
averageModuleSize /= (float) size;
|
||||||
|
// We don't have java.util.Collections in J2ME
|
||||||
|
Collections.insertionSort(possibleCenters, new ClosestToAverageComparator(averageModuleSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
possibleCenters.setSize(size);
|
|
||||||
|
|
||||||
// Hmm, multiple found. We need to pick the best three. Find the most
|
|
||||||
// popular ones whose module size is nearest the average
|
|
||||||
|
|
||||||
float averageModuleSize = 0.0f;
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
averageModuleSize += ((FinderPattern) possibleCenters.elementAt(i)).getEstimatedModuleSize();
|
|
||||||
}
|
|
||||||
averageModuleSize /= (float) size;
|
|
||||||
|
|
||||||
// We don't have java.util.Collections in J2ME
|
|
||||||
Collections.insertionSort(possibleCenters, new ClosestToAverageComparator(averageModuleSize));
|
|
||||||
|
|
||||||
return new FinderPattern[]{
|
return new FinderPattern[]{
|
||||||
(FinderPattern) possibleCenters.elementAt(0),
|
(FinderPattern) possibleCenters.elementAt(0),
|
||||||
(FinderPattern) possibleCenters.elementAt(1),
|
(FinderPattern) possibleCenters.elementAt(1),
|
||||||
|
|
Loading…
Reference in a new issue