From 10c2f71671f62bc79e23266471cb9b897f62aa7c Mon Sep 17 00:00:00 2001 From: srowen Date: Thu, 19 Dec 2013 16:16:08 +0000 Subject: [PATCH] Handle smaller images in WhiteRectangleDetector git-svn-id: https://zxing.googlecode.com/svn/trunk@3000 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../detector/WhiteRectangleDetector.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java b/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java index ddc1a5c59..2dc8b0586 100644 --- a/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java +++ b/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java @@ -32,7 +32,7 @@ import com.google.zxing.common.BitMatrix; */ public final class WhiteRectangleDetector { - private static final int INIT_SIZE = 30; + private static final int INIT_SIZE = 10; private static final int CORR = 1; private final BitMatrix image; @@ -43,30 +43,18 @@ public final class WhiteRectangleDetector { private final int downInit; private final int upInit; - /** - * @throws NotFoundException if image is too small - */ public WhiteRectangleDetector(BitMatrix image) throws NotFoundException { - this.image = image; - height = image.getHeight(); - width = image.getWidth(); - leftInit = (width - INIT_SIZE) >> 1; - rightInit = (width + INIT_SIZE) >> 1; - upInit = (height - INIT_SIZE) >> 1; - downInit = (height + INIT_SIZE) >> 1; - if (upInit < 0 || leftInit < 0 || downInit >= height || rightInit >= width) { - throw NotFoundException.getNotFoundInstance(); - } + this(image, INIT_SIZE, image.getWidth() / 2, image.getHeight() / 2); } /** - * @throws NotFoundException if image is too small + * @throws NotFoundException if image is too small to accommodate {@code initSize} */ public WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) throws NotFoundException { this.image = image; height = image.getHeight(); width = image.getWidth(); - int halfsize = initSize >> 1; + int halfsize = initSize / 2; leftInit = x - halfsize; rightInit = x + halfsize; upInit = y - halfsize;