Class ChessboardCornerClusterToGrid

java.lang.Object
boofcv.alg.fiducial.calib.chess.ChessboardCornerClusterToGrid
All Implemented Interfaces:
VerbosePrint

public class ChessboardCornerClusterToGrid extends Object implements VerbosePrint
Given a chessboard corner cluster find the grid which it matches. A grid is an ordering of corners in a specific order and such that their edges are consistent and form a 4-neighborhood. The grid will be in "standard order". Depending on the chessboard pattern there might be multiple multiple configurations that are in standard order or a unique ordering. On a grid a "Corner" is defined as a corner point which has a black square attached to it which is not attached to any more corner points. These are useful in that they allow orientation to be uniquely defined under certain conditions. If the "allowNoCorner" flag is true then grid with no corners are allowed. The corner point at grid(0,0) will be set to a valid corner point with a "corner" that's closest to the (0,0) pixel coordinate. If there are no corner points then the corner which is closest to (0,0) pixel is selected. Edges will be ordered in CCW direction and the index of an edge which connects two adjacent corners to each other follows the (i+2)%4 relationship. If multiple corners can be (0,0) then the one closest to the top left corner will be selected. The largest rectangular grid is returned. The idea being that it's not uncommon for there to be noise which adds an extra stray element. This will remove those stray elements.
  • Field Details

    • findLargestGrid

      public boolean findLargestGrid
      If true then it will find the largest rectangular grid and return this. This will often remove stray noise
    • allowHoles

      public boolean allowHoles
      If false then a hole in the middle of the grid will be considered a failure
    • sparseCols

      protected int sparseCols
      Dimension of the sparse/dense grids
    • sparseRows

      protected int sparseRows
      Dimension of the sparse/dense grids
  • Constructor Details

    • ChessboardCornerClusterToGrid

      public ChessboardCornerClusterToGrid()
  • Method Details

    • clusterToSparse

      public boolean clusterToSparse(ChessboardCornerGraph cluster)
      Converts the graph into a sparse grid. This ensures that chessboard constraints are logically consistent in the grid
      Returns:
      true if no errors were detected
    • sparseToGrid

      public boolean sparseToGrid(ChessboardCornerClusterToGrid.GridInfo info)
      After the sparse grid has been found this function can then be called to extract a complete target. It will find the largest rectangular region with all the elements contained.
      Parameters:
      info - (Output) Found rectangular grid
      Returns:
      true if no errors were detected
    • sparseToDense

      public void sparseToDense()
      Converts the sparse into a dense grid
    • isWhiteSquareOrientation

      public boolean isWhiteSquareOrientation(ChessboardCornerGraph.Node a, ChessboardCornerGraph.Node c)
      Returns true of the candidate is the top-left corner in a white square.
      Parameters:
      a - Corner at top-left
      c - Corner at bottom-right
    • rotateCCW

      public void rotateCCW(ChessboardCornerClusterToGrid.GridInfo grid)
      Rotates the grid in the CCW direction
    • getDense

      @Nullable public @Nullable ChessboardCornerClusterToGrid.GridElement getDense(int row, int col)
      Used to access an element in the sparse grid
    • setVerbose

      public void setVerbose(@Nullable @Nullable PrintStream out, @Nullable @Nullable Set<String> configuration)
      Specified by:
      setVerbose in interface VerbosePrint