public final class Detector
extends java.lang.Object
Encapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code is rotated or skewed, or partially obscured.
Modifier and Type | Field and Description |
---|---|
private BitMatrix |
image |
private WhiteRectangleDetector |
rectangleDetector |
Modifier and Type | Method and Description |
---|---|
private ResultPoint |
correctTopRight(ResultPoint[] points)
Calculates the corner position of the white top right module.
|
DetectorResult |
detect()
Detects a Data Matrix Code in an image.
|
private ResultPoint[] |
detectSolid1(ResultPoint[] cornerPoints)
Detect a solid side which has minimum transition.
|
private ResultPoint[] |
detectSolid2(ResultPoint[] points)
Detect a second solid side next to first solid side.
|
private boolean |
isValid(ResultPoint p) |
private static ResultPoint |
moveAway(ResultPoint point,
float fromX,
float fromY) |
private static BitMatrix |
sampleGrid(BitMatrix image,
ResultPoint topLeft,
ResultPoint bottomLeft,
ResultPoint bottomRight,
ResultPoint topRight,
int dimensionX,
int dimensionY) |
private static ResultPoint |
shiftPoint(ResultPoint point,
ResultPoint to,
int div) |
private ResultPoint[] |
shiftToModuleCenter(ResultPoint[] points)
Shift the edge points to the module center.
|
private int |
transitionsBetween(ResultPoint from,
ResultPoint to)
Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
|
private final BitMatrix image
private final WhiteRectangleDetector rectangleDetector
public Detector(BitMatrix image) throws NotFoundException
NotFoundException
public DetectorResult detect() throws NotFoundException
Detects a Data Matrix Code in an image.
DetectorResult
encapsulating results of detecting a Data Matrix CodeNotFoundException
- if no Data Matrix Code can be foundprivate static ResultPoint shiftPoint(ResultPoint point, ResultPoint to, int div)
private static ResultPoint moveAway(ResultPoint point, float fromX, float fromY)
private ResultPoint[] detectSolid1(ResultPoint[] cornerPoints)
private ResultPoint[] detectSolid2(ResultPoint[] points)
private ResultPoint correctTopRight(ResultPoint[] points)
private ResultPoint[] shiftToModuleCenter(ResultPoint[] points)
private boolean isValid(ResultPoint p)
private static BitMatrix sampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint bottomRight, ResultPoint topRight, int dimensionX, int dimensionY) throws NotFoundException
NotFoundException
private int transitionsBetween(ResultPoint from, ResultPoint to)