use of boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph.Node in project BoofCV by lessthanoptimal.
the class TestChessboardCornerClusterToGrid method shuffle.
private void shuffle(Node[] edges) {
for (int i = 0; i < 4; i++) {
int src = rand.nextInt(4 - i);
Node a = edges[src];
Node b = edges[4 - i - 1];
edges[4 - i - 1] = a;
edges[src] = b;
}
}
use of boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph.Node in project BoofCV by lessthanoptimal.
the class TestChessboardCornerGraph method node_countEdges.
@Test
void node_countEdges() {
Node n = new Node();
assertEquals(0, n.countEdges());
n.edges[1] = new Node();
assertEquals(1, n.countEdges());
n.edges[3] = new Node();
assertEquals(2, n.countEdges());
n.edges[0] = new Node();
n.edges[2] = new Node();
assertEquals(4, n.countEdges());
}
use of boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph.Node in project BoofCV by lessthanoptimal.
the class TestChessboardCornerGraph method node_rotateEdgesDown.
@Test
void node_rotateEdgesDown() {
Node[] tmp = new Node[4];
tmp[1] = new Node();
tmp[2] = new Node();
tmp[3] = new Node();
Node n = new Node();
System.arraycopy(tmp, 0, n.edges, 0, 4);
n.rotateEdgesDown();
for (int i = 0; i < 4; i++) {
assertSame(tmp[(i + 1) % 4], n.edges[i]);
}
}
use of boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph.Node in project BoofCV by lessthanoptimal.
the class TestChessboardCornerClusterToGrid method convert_extra.
/**
* The input will be a rectangle, but with an extra corner that should be removed
*/
@Test
void convert_extra() {
ChessboardCornerClusterToGrid alg = new ChessboardCornerClusterToGrid();
alg.setRequireCornerSquares(true);
ChessboardCornerGraph graph = new ChessboardCornerGraph();
graph.corners = createGrid(4, 5, true);
// add an extra node to the graph
Node n = graph.corners.get(graph.corners.size - 1);
Node extra = graph.corners.grow();
extra.corner = new ChessboardCorner();
extra.corner.orientation = n.getOrientation() * -1;
extra.corner.x = n.getX() + 30;
extra.corner.y = n.getY();
extra.index = graph.corners.size - 1;
n.edges[0] = extra;
extra.edges[2] = n;
// See if it gets removed
GridInfo info = new GridInfo();
assertTrue(alg.clusterToSparse(graph));
assertTrue(alg.sparseToGrid(info));
assertTrue(info.hasCornerSquare);
assertEquals(5, info.cols);
assertEquals(4, info.rows);
assertEquals(5 * 4, info.nodes.size());
}
use of boofcv.alg.fiducial.calib.chess.ChessboardCornerGraph.Node in project BoofCV by lessthanoptimal.
the class TestChessboardCornerClusterToGrid method alignEdges.
@Test
void alignEdges() {
for (int rows = 2; rows <= 4; rows++) {
for (int cols = 2; cols <= 4; cols++) {
DogArray<Node> corners = createGrid(rows, cols, true);
// Shift the edges so that they won't be aligned
// They are already in order
Node[] tmp = new Node[4];
for (Node n : corners.toList()) {
int amount = rand.nextInt(3);
System.arraycopy(n.edges, 0, tmp, 0, 4);
for (int i = 0; i < 4; i++) {
n.edges[(i + amount) % 4] = tmp[i];
}
}
ChessboardCornerClusterToGrid alg = new ChessboardCornerClusterToGrid();
assertTrue(alg.alignEdges(corners));
// Check using (i+2)%4 rule
for (Node n : corners.toList()) {
for (int i = 0; i < 4; i++) {
if (n.edges[i] == null)
continue;
assertSame(n, n.edges[i].edges[(i + 2) % 4]);
}
}
}
}
}
Aggregations