Handle smaller images in WhiteRectangleDetector

git-svn-id: https://zxing.googlecode.com/svn/trunk@3000 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2013-12-19 16:16:08 +00:00
parent de6e4bca32
commit 10c2f71671

View file

@ -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;