Package com.google.zxing.common.detector
Class WhiteRectangleDetector
- java.lang.Object
-
- com.google.zxing.common.detector.WhiteRectangleDetector
-
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.
-
-
Constructor Summary
Constructors Constructor Description WhiteRectangleDetector(BitMatrix image)
WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ResultPoint[]
centerEdges(ResultPoint y, ResultPoint z, ResultPoint x, ResultPoint t)
recenters the points of a constant distance towards the centerprivate boolean
containsBlackPoint(int a, int b, int fixed, boolean horizontal)
Determines whether a segment contains a black pointResultPoint[]
detect()
Detects a candidate barcode-like rectangular region within an image.private ResultPoint
getBlackPointOnSegment(float aX, float aY, float bX, float bY)
-
-
-
Field Detail
-
INIT_SIZE
private static final int INIT_SIZE
- See Also:
- Constant Field Values
-
CORR
private static final int CORR
- See Also:
- Constant Field Values
-
image
private final BitMatrix image
-
height
private final int height
-
width
private final int width
-
leftInit
private final int leftInit
-
rightInit
private final int rightInit
-
downInit
private final int downInit
-
upInit
private final int upInit
-
-
Constructor Detail
-
WhiteRectangleDetector
public WhiteRectangleDetector(BitMatrix image) throws NotFoundException
- Throws:
NotFoundException
-
WhiteRectangleDetector
public WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) throws NotFoundException
- Parameters:
image
- barcode image to find a rectangle ininitSize
- initial size of search area around centerx
- x position of search centery
- y position of search center- Throws:
NotFoundException
- if image is too small to accommodateinitSize
-
-
Method Detail
-
detect
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.
- Returns:
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 rightmost- Throws:
NotFoundException
- if no Data Matrix Code can be found
-
getBlackPointOnSegment
private ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY)
-
centerEdges
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, ResultPoint x, ResultPoint t)
recenters the points of a constant distance towards the center- Parameters:
y
- bottom most pointz
- left most pointx
- right most pointt
- top most point- Returns:
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 rightmost
-
containsBlackPoint
private boolean containsBlackPoint(int a, int b, int fixed, boolean horizontal)
Determines whether a segment contains a black point- Parameters:
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- Returns:
- true if a black point has been found, else false.
-
-