public final class Detector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Detector.CorrectedParameter |
(package private) static class |
Detector.Point |
Modifier and Type | Field and Description |
---|---|
private boolean |
compact |
private static int[] |
EXPECTED_CORNER_BITS |
private BitMatrix |
image |
private int |
nbCenterLayers |
private int |
nbDataBlocks |
private int |
nbLayers |
private int |
shift |
Modifier and Type | Method and Description |
---|---|
AztecDetectorResult |
detect() |
AztecDetectorResult |
detect(boolean isMirror)
Detects an Aztec Code in an image.
|
private static float |
distance(Detector.Point a,
Detector.Point b) |
private static float |
distance(ResultPoint a,
ResultPoint b) |
private static ResultPoint[] |
expandSquare(ResultPoint[] cornerPoints,
int oldSide,
int newSide)
Expand the square represented by the corner points by pushing out equally in all directions
|
private int |
extractParameters(ResultPoint[] bullsEyeCorners)
Extracts the number of data layers and data blocks from the layer around the bull's eye.
|
private ResultPoint[] |
getBullsEyeCorners(Detector.Point pCenter)
Finds the corners of a bull-eye centered on the passed point.
|
private int |
getColor(Detector.Point p1,
Detector.Point p2)
Gets the color of a segment
|
private static Detector.CorrectedParameter |
getCorrectedParameterData(long parameterData,
boolean compact)
Corrects the parameter bits using Reed-Solomon algorithm.
|
private int |
getDimension() |
private Detector.Point |
getFirstDifferent(Detector.Point init,
boolean color,
int dx,
int dy)
Gets the coordinate of the first point with a different color in the given direction
|
private Detector.Point |
getMatrixCenter()
Finds a candidate center point of an Aztec code from an image
|
private ResultPoint[] |
getMatrixCornerPoints(ResultPoint[] bullsEyeCorners)
Gets the Aztec code corners from the bull's eye corners and the parameters.
|
private static int |
getRotation(int[] sides,
int length) |
private boolean |
isValid(int x,
int y) |
private boolean |
isValid(ResultPoint point) |
private boolean |
isWhiteOrBlackRectangle(Detector.Point p1,
Detector.Point p2,
Detector.Point p3,
Detector.Point p4) |
private BitMatrix |
sampleGrid(BitMatrix image,
ResultPoint topLeft,
ResultPoint topRight,
ResultPoint bottomRight,
ResultPoint bottomLeft)
Creates a BitMatrix by sampling the provided image.
|
private int |
sampleLine(ResultPoint p1,
ResultPoint p2,
int size)
Samples a line.
|
private static final int[] EXPECTED_CORNER_BITS
private final BitMatrix image
private boolean compact
private int nbLayers
private int nbDataBlocks
private int nbCenterLayers
private int shift
public Detector(BitMatrix image)
public AztecDetectorResult detect() throws NotFoundException
NotFoundException
public AztecDetectorResult detect(boolean isMirror) throws NotFoundException
isMirror
- if true, image is a mirror-image of originalAztecDetectorResult
encapsulating results of detecting an Aztec CodeNotFoundException
- if no Aztec Code can be foundprivate int extractParameters(ResultPoint[] bullsEyeCorners) throws NotFoundException
bullsEyeCorners
- the array of bull's eye cornersNotFoundException
- in case of too many errors or invalid parametersprivate static int getRotation(int[] sides, int length) throws NotFoundException
NotFoundException
private static Detector.CorrectedParameter getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException
parameterData
- parameter bitscompact
- true if this is a compact Aztec codeNotFoundException
- if the array contains too many errorsprivate ResultPoint[] getBullsEyeCorners(Detector.Point pCenter) throws NotFoundException
pCenter
- Center pointNotFoundException
- If no valid bull-eye can be foundprivate Detector.Point getMatrixCenter()
private ResultPoint[] getMatrixCornerPoints(ResultPoint[] bullsEyeCorners)
bullsEyeCorners
- the array of bull's eye cornersprivate BitMatrix sampleGrid(BitMatrix image, ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomRight, ResultPoint bottomLeft) throws NotFoundException
NotFoundException
private int sampleLine(ResultPoint p1, ResultPoint p2, int size)
p1
- start point (inclusive)p2
- end point (exclusive)size
- number of bitsprivate boolean isWhiteOrBlackRectangle(Detector.Point p1, Detector.Point p2, Detector.Point p3, Detector.Point p4)
private int getColor(Detector.Point p1, Detector.Point p2)
private Detector.Point getFirstDifferent(Detector.Point init, boolean color, int dx, int dy)
private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, int oldSide, int newSide)
cornerPoints
- the corners of the square, which has the bull's eye at its centeroldSide
- the original length of the side of the square in the target bit matrixnewSide
- the new length of the size of the square in the target bit matrixprivate boolean isValid(int x, int y)
private boolean isValid(ResultPoint point)
private static float distance(Detector.Point a, Detector.Point b)
private static float distance(ResultPoint a, ResultPoint b)
private int getDimension()