mirror of
https://github.com/zxing/zxing.git
synced 2025-02-21 02:55:27 -08:00
Detector is now a little more skeptical once it has found 3 confirmed finder patterns -- one may be a false positive, so it also checks to see if the estimated module sizes are "pretty similar". If not, keeps looking.
git-svn-id: https://zxing.googlecode.com/svn/trunk@394 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
dbf5629def
commit
8d31073968
|
@ -419,19 +419,34 @@ final class FinderPatternFinder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true iff we have found at least 3 finder patterns that have been detected
|
* @return true iff we have found at least 3 finder patterns that have been detected
|
||||||
* at least {@link #CENTER_QUORUM} times each
|
* at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the
|
||||||
|
* candidates is "pretty similar"
|
||||||
*/
|
*/
|
||||||
private boolean haveMulitplyConfirmedCenters() {
|
private boolean haveMulitplyConfirmedCenters() {
|
||||||
int count = 0;
|
int confirmedCount = 0;
|
||||||
|
float totalModuleSize = 0.0f;
|
||||||
int max = possibleCenters.size();
|
int max = possibleCenters.size();
|
||||||
for (int i = 0; i < max; i++) {
|
for (int i = 0; i < max; i++) {
|
||||||
if (((FinderPattern) possibleCenters.elementAt(i)).getCount() >= CENTER_QUORUM) {
|
FinderPattern pattern = (FinderPattern) possibleCenters.elementAt(i);
|
||||||
if (++count == 3) {
|
if (pattern.getCount() >= CENTER_QUORUM) {
|
||||||
return true;
|
confirmedCount++;
|
||||||
}
|
totalModuleSize += pattern.getEstimatedModuleSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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
|
||||||
|
// 15% of the total module size estimates, it's too much.
|
||||||
|
float average = totalModuleSize / max;
|
||||||
|
float totalDeviation = 0.0f;
|
||||||
|
for (int i = 0; i < max; i++) {
|
||||||
|
FinderPattern pattern = (FinderPattern) possibleCenters.elementAt(i);
|
||||||
|
totalDeviation += Math.abs(pattern.getEstimatedModuleSize() - average);
|
||||||
|
}
|
||||||
|
return totalDeviation <= 0.15f * totalModuleSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue