public final class WhiteRectangleDetector
extends java.lang.Object
Detects a candidate barcode-like rectangular region within an image. It starts around the center of the image, increases the size of the candidate region until it finds a white rectangular region. By keeping track of the last black points it encountered, it determines the corners of the barcode.
Modifier and Type | Field and Description |
---|---|
private static int |
CORR |
private int |
downInit |
private int |
height |
private BitMatrix |
image |
private static int |
INIT_SIZE |
private int |
leftInit |
private int |
rightInit |
private int |
upInit |
private int |
width |
Constructor and Description |
---|
WhiteRectangleDetector(BitMatrix image) |
WhiteRectangleDetector(BitMatrix image,
int initSize,
int x,
int y) |
Modifier and Type | Method and Description |
---|---|
private ResultPoint[] |
centerEdges(ResultPoint y,
ResultPoint z,
ResultPoint x,
ResultPoint t)
recenters the points of a constant distance towards the center
|
private boolean |
containsBlackPoint(int a,
int b,
int fixed,
boolean horizontal)
Determines whether a segment contains a black point
|
ResultPoint[] |
detect()
Detects a candidate barcode-like rectangular region within an image.
|
private ResultPoint |
getBlackPointOnSegment(float aX,
float aY,
float bX,
float bY) |
private static final int INIT_SIZE
private static final int CORR
private final BitMatrix image
private final int height
private final int width
private final int leftInit
private final int rightInit
private final int downInit
private final int upInit
public WhiteRectangleDetector(BitMatrix image) throws NotFoundException
NotFoundException
public WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) throws NotFoundException
image
- barcode image to find a rectangle ininitSize
- initial size of search area around centerx
- x position of search centery
- y position of search centerNotFoundException
- if image is too small to accommodate initSize
public ResultPoint[] detect() throws NotFoundException
Detects a candidate barcode-like rectangular region within an image. It starts around the center of the image, increases the size of the candidate region until it finds a white rectangular region.
ResultPoint
[] describing the corners of the rectangular
region. The first and last points are opposed on the diagonal, as
are the second and third. The first point will be the topmost
point and the last, the bottommost. The second point will be
leftmost and the third, the rightmostNotFoundException
- if no Data Matrix Code can be foundprivate ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY)
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, ResultPoint x, ResultPoint t)
y
- bottom most pointz
- left most pointx
- right most pointt
- top most pointResultPoint
[] describing the corners of the rectangular
region. The first and last points are opposed on the diagonal, as
are the second and third. The first point will be the topmost
point and the last, the bottommost. The second point will be
leftmost and the third, the rightmostprivate boolean containsBlackPoint(int a, int b, int fixed, boolean horizontal)
a
- min value of the scanned coordinateb
- max value of the scanned coordinatefixed
- value of fixed coordinatehorizontal
- set to true if scan must be horizontal, false if vertical