Class ECoCheckUtils
java.lang.Object
boofcv.alg.fiducial.calib.ecocheck.ECoCheckUtils
Common functions that are needed for encoding, decoding, and detecting. Terminology can be found in
ECoCheckGenerator
.
-
Field Summary
Modifier and TypeFieldDescriptionfinal DogArray_I32
How bits are ordered.protected int
Number of samples it will do for each bit.int
Length of the row/column in the grid it will sample when determining a cell's bit valuefinal ECoCheckCodec
Used to encode and decode bit streams with coordinate informationdouble
Fraction of a bit-cell's length that the black square is drawn indouble
Fraction length of the quite-zone around data bitsShape of all possible markers -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMarker
(int squareRows, int squareCols) Adds a new marker to the liststatic void
adjustTopLeft
(int orientation, GridCoordinate coordinate) Adjust the top left corner based on orientationvoid
bitRect
(int row, int col, Rectangle2D_F64 rect) Returns the rectangle in which a data-bit will be written to.void
cellIdToCornerCoordinate
(int markerID, int cellID, GridCoordinate coordinate) Given the markerID and cellID, compute the coordinate of the top left corner.void
boolean
computeGridToImage
(Point2D_F64 a, Point2D_F64 b, Point2D_F64 c, Point2D_F64 d) Finds the correspondence from data-region coordinates to image pixelsvoid
cornerToMarker3D
(int markerID, int cornerID, double squareLength, Point3D_F64 coordinate) void
cornerToMarker3D
(int markerID, int cornerID, Point3D_F64 coordinate) Converts a corner ID into a marker ID.int
countEncodedSquaresInMarker
(int markerID) Returns the number of encoded cells in the chessboardcreateCornerList
(int markerID, double squareLength) Creates a list of corners coordinates on the specified marker given the size of a full squarevoid
fixate()
Call after its done being configured so that it can precompute everything that's neededvoid
gridToPixel
(double x, double y, Point2D_F64 pixel) Convenience function to go from a point in grid coordinates to image pixelsboolean
isLegalCornerIds
(ECoCheckFound found) static int
maxCorners
(int rows, int cols) mergeAndRemoveUnknown
(List<ECoCheckFound> found) Merges detections with the same marker ID into a single detection and removes unknown markers.float
otsuThreshold
(DogArray_F32 values) Computes a threshold using Otsu.void
selectPixelsToSample
(DogArray<Point2D_F64> pixels) Selects pixels that it should sample for each bit.void
Assign all parameters from a config class as possible
-
Field Details
-
dataBitWidthFraction
public double dataBitWidthFractionFraction of a bit-cell's length that the black square is drawn in -
dataBorderFraction
public double dataBorderFractionFraction length of the quite-zone around data bits -
markers
Shape of all possible markers -
bitSampleGridSize
public int bitSampleGridSizeLength of the row/column in the grid it will sample when determining a cell's bit value -
bitSampleCount
protected int bitSampleCountNumber of samples it will do for each bit. Each sample is one vote. Dynamically computed frombitSampleGridSize
-
codec
Used to encode and decode bit streams with coordinate information -
bitOrder
How bits are ordered. This is done to make bits which are in the same word spatially close to each other
-
-
Constructor Details
-
ECoCheckUtils
public ECoCheckUtils()
-
-
Method Details
-
setParametersFromConfig
Assign all parameters from a config class as possible -
addMarker
public void addMarker(int squareRows, int squareCols) Adds a new marker to the list- Parameters:
squareRows
- Number of square rows in the chessboard patternsquareCols
- Number of square columns in the chessboard pattern
-
fixate
public void fixate()Call after its done being configured so that it can precompute everything that's needed -
checkFixate
public void checkFixate() -
bitRect
Returns the rectangle in which a data-bit will be written to. The rectangle will be in data-region coordinates.- Parameters:
row
- Bit's rowcol
- Bit's columnrect
- (Output) Rectangle containing the bit
-
computeGridToImage
Finds the correspondence from data-region coordinates to image pixels- Parameters:
a
- Pixel corresponding to (0,0)b
- Pixel corresponding to (w,0)c
- Pixel corresponding to (w,w)d
- Pixel corresponding to (0,w)
-
otsuThreshold
Computes a threshold using Otsu. Assumes that there are two clear peaks in the data. -
gridToPixel
Convenience function to go from a point in grid coordinates to image pixels -
selectPixelsToSample
Selects pixels that it should sample for each bit. The number of pixels per bit is specified by pixelsPerBit. The order of bits is in row-major format with a block of size bitSampleCount. Points are sampled in a grid pattern with one point in the center. This means there will be an odd number of points preventing a tie.- Parameters:
pixels
- (Output) Image pixels that correspond pixels in binary version of grid
-
cellIdToCornerCoordinate
Given the markerID and cellID, compute the coordinate of the top left corner.- Parameters:
markerID
- (Input) MarkercellID
- (Input) Encoded cell IDcoordinate
- (Output) Corner coordinate in corner grid of TL corner
-
adjustTopLeft
Adjust the top left corner based on orientation -
countEncodedSquaresInMarker
public int countEncodedSquaresInMarker(int markerID) Returns the number of encoded cells in the chessboard- Parameters:
markerID
- (Input) which marker
-
cornerToMarker3D
Converts a corner ID into a marker ID. The origin of the marker's coordinate system will be the marker's center. Coordinates will range from -0.5 to 0.5. The length of the longest side will be 1.0.- Parameters:
markerID
- Which markercornerID
- Which cornercoordinate
- (Output) Coordinate in the coordinate system described above
-
cornerToMarker3D
public void cornerToMarker3D(int markerID, int cornerID, double squareLength, Point3D_F64 coordinate) -
createCornerList
Creates a list of corners coordinates on the specified marker given the size of a full square- Parameters:
markerID
- Which markersquareLength
- Size of a full square- Returns:
- Location of corners in standard order
-
maxCorners
public static int maxCorners(int rows, int cols) -
isLegalCornerIds
-
mergeAndRemoveUnknown
Merges detections with the same marker ID into a single detection and removes unknown markers. A naive algorithm is used to merge markers together. First it checks to see if there's a conflict between two markers by them having the same cornerID. If that's good it will select the existing marker with the most corners. If there is no matching marker then a new marker is created.- Parameters:
found
- Original list of found markers.- Returns:
- New list of markers.
-