mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Changed how many rows we scan while detecting QR finder patterns. The mobile case dynamically calculates this based on the height of the image, and ranges from a small speedup to a big difference for large inputs. Also changed the try harder case to scan every 3rd line for a 3x speedup. The unit tests have the same success rate as before: 16/20 on qr1, 10/10 on qr2.
git-svn-id: https://zxing.googlecode.com/svn/trunk@354 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
d9fc77b9e2
commit
ae54d7a937
|
@ -38,7 +38,8 @@ import java.util.Vector;
|
||||||
final class FinderPatternFinder {
|
final class FinderPatternFinder {
|
||||||
|
|
||||||
private static final int CENTER_QUORUM = 2;
|
private static final int CENTER_QUORUM = 2;
|
||||||
private static final int BIG_SKIP = 3;
|
private static final int MIN_SKIP = 3; // 1 pixel/module times 3 modules/center
|
||||||
|
private static final int MAX_MODULES = 57; // support up to version 10 for mobile clients
|
||||||
|
|
||||||
private final MonochromeBitmapSource image;
|
private final MonochromeBitmapSource image;
|
||||||
private final Vector possibleCenters;
|
private final Vector possibleCenters;
|
||||||
|
@ -62,9 +63,16 @@ final class FinderPatternFinder {
|
||||||
// 1:1:3:1:1 ratio; this tracks the number of such modules seen so far
|
// 1:1:3:1:1 ratio; this tracks the number of such modules seen so far
|
||||||
int[] stateCount = new int[5];
|
int[] stateCount = new int[5];
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
// We can afford to examine every few lines until we've started finding
|
|
||||||
// the patterns
|
// Let's assume that the maximum version QR Code we support takes up 1/4 the height of the
|
||||||
int iSkip = tryHarder ? 1 : BIG_SKIP;
|
// image, and then account for the center being 3 modules in size. This gives the smallest
|
||||||
|
// number of pixels the center could be, so skip this often. When trying harder, look for all
|
||||||
|
// QR versions regardless of how dense they are.
|
||||||
|
int iSkip = (int) (maxI / (MAX_MODULES * 4.0f) * 3);
|
||||||
|
if (iSkip < MIN_SKIP || tryHarder) {
|
||||||
|
iSkip = MIN_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = iSkip - 1; i < maxI && !done; i += iSkip) {
|
for (int i = iSkip - 1; i < maxI && !done; i += iSkip) {
|
||||||
// Get a row of black/white values
|
// Get a row of black/white values
|
||||||
BitArray blackRow = image.getBlackRow(i, null, 0, maxJ);
|
BitArray blackRow = image.getBlackRow(i, null, 0, maxJ);
|
||||||
|
|
Loading…
Reference in a new issue