mirror of
https://github.com/zxing/zxing.git
synced 2025-02-21 02:55:27 -08:00
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:
parent
de6e4bca32
commit
10c2f71671
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue