Class Detector
- java.lang.Object
-
- com.google.zxing.datamatrix.detector.Detector
-
public final class Detector extends java.lang.ObjectEncapsulates logic that can detect a Data Matrix Code in an image, even if the Data Matrix Code is rotated or skewed, or partially obscured.
-
-
Field Summary
Fields Modifier and Type Field Description private BitMatriximageprivate WhiteRectangleDetectorrectangleDetector
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ResultPointcorrectTopRight(ResultPoint[] points)Calculates the corner position of the white top right module.DetectorResultdetect()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 booleanisValid(ResultPoint p)private static ResultPointmoveAway(ResultPoint point, float fromX, float fromY)private static BitMatrixsampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint bottomRight, ResultPoint topRight, int dimensionX, int dimensionY)private static ResultPointshiftPoint(ResultPoint point, ResultPoint to, int div)private ResultPoint[]shiftToModuleCenter(ResultPoint[] points)Shift the edge points to the module center.private inttransitionsBetween(ResultPoint from, ResultPoint to)Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
-
-
-
Field Detail
-
image
private final BitMatrix image
-
rectangleDetector
private final WhiteRectangleDetector rectangleDetector
-
-
Constructor Detail
-
Detector
public Detector(BitMatrix image) throws NotFoundException
- Throws:
NotFoundException
-
-
Method Detail
-
detect
public DetectorResult detect() throws NotFoundException
Detects a Data Matrix Code in an image.
- Returns:
DetectorResultencapsulating results of detecting a Data Matrix Code- Throws:
NotFoundException- if no Data Matrix Code can be found
-
shiftPoint
private static ResultPoint shiftPoint(ResultPoint point, ResultPoint to, int div)
-
moveAway
private static ResultPoint moveAway(ResultPoint point, float fromX, float fromY)
-
detectSolid1
private ResultPoint[] detectSolid1(ResultPoint[] cornerPoints)
Detect a solid side which has minimum transition.
-
detectSolid2
private ResultPoint[] detectSolid2(ResultPoint[] points)
Detect a second solid side next to first solid side.
-
correctTopRight
private ResultPoint correctTopRight(ResultPoint[] points)
Calculates the corner position of the white top right module.
-
shiftToModuleCenter
private ResultPoint[] shiftToModuleCenter(ResultPoint[] points)
Shift the edge points to the module center.
-
isValid
private boolean isValid(ResultPoint p)
-
sampleGrid
private static BitMatrix sampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint bottomLeft, ResultPoint bottomRight, ResultPoint topRight, int dimensionX, int dimensionY) throws NotFoundException
- Throws:
NotFoundException
-
transitionsBetween
private int transitionsBetween(ResultPoint from, ResultPoint to)
Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
-
-