mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Small detector simplification that addresses issue 215 and picks up a net +4 more images decoded in tests
git-svn-id: https://zxing.googlecode.com/svn/trunk@1022 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
636c00e844
commit
9f475ac33e
|
@ -480,34 +480,25 @@ public class FinderPatternFinder {
|
|||
* @throws ReaderException if 3 such finder patterns do not exist
|
||||
*/
|
||||
private FinderPattern[] selectBestPatterns() throws ReaderException {
|
||||
Collections.insertionSort(possibleCenters, new CenterComparator());
|
||||
int size = 0;
|
||||
int max = possibleCenters.size();
|
||||
while (size < max) {
|
||||
if (((FinderPattern) possibleCenters.elementAt(size)).getCount() < CENTER_QUORUM) {
|
||||
break;
|
||||
}
|
||||
size++;
|
||||
}
|
||||
|
||||
if (size < 3) {
|
||||
if (possibleCenters.size() < 3) {
|
||||
// Couldn't find enough finder patterns
|
||||
throw ReaderException.getInstance();
|
||||
}
|
||||
Collections.insertionSort(possibleCenters, new CenterComparator());
|
||||
|
||||
if (size > 3) {
|
||||
if (possibleCenters.size() > 3) {
|
||||
// Throw away all but those first size candidate points we found.
|
||||
possibleCenters.setSize(size);
|
||||
// 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));
|
||||
possibleCenters.setSize(3);
|
||||
}
|
||||
// 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 < 3; i++) {
|
||||
averageModuleSize += ((FinderPattern) possibleCenters.elementAt(i)).getEstimatedModuleSize();
|
||||
}
|
||||
averageModuleSize /= 3.0f;
|
||||
// We don't have java.util.Collections in J2ME
|
||||
Collections.insertionSort(possibleCenters, new ClosestToAverageComparator(averageModuleSize));
|
||||
|
||||
return new FinderPattern[]{
|
||||
(FinderPattern) possibleCenters.elementAt(0),
|
||||
|
|
|
@ -29,8 +29,8 @@ public final class QRCodeBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
|||
super("test/data/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||
addTest(19, 19, 0.0f);
|
||||
addTest(15, 15, 90.0f);
|
||||
addTest(16, 16, 180.0f);
|
||||
addTest(13, 14, 270.0f);
|
||||
addTest(17, 17, 180.0f);
|
||||
addTest(14, 14, 270.0f);
|
||||
}
|
||||
|
||||
}
|
|
@ -27,10 +27,10 @@ public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
|||
|
||||
public QRCodeBlackBox2TestCase() {
|
||||
super("test/data/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||
addTest(24, 24, 0.0f);
|
||||
addTest(21, 21, 90.0f);
|
||||
addTest(22, 22, 180.0f);
|
||||
addTest(17, 18, 270.0f);
|
||||
addTest(23, 23, 0.0f);
|
||||
addTest(20, 20, 90.0f);
|
||||
addTest(21, 21, 180.0f);
|
||||
addTest(19, 19, 270.0f);
|
||||
}
|
||||
|
||||
}
|
|
@ -29,8 +29,8 @@ public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
|||
super("test/data/blackbox/qrcode-3", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||
addTest(33, 33, 0.0f);
|
||||
addTest(33, 33, 90.0f);
|
||||
addTest(32, 32, 180.0f);
|
||||
addTest(34, 34, 270.0f);
|
||||
addTest(33, 33, 180.0f);
|
||||
addTest(35, 35, 270.0f);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue