use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestEllipseClustersIntoHexagonalGrid method process_multiple_grids.
/**
* Multiple grids in view at the same time
*/
@Test
public void process_multiple_grids() {
// create two grids
int rows = 4;
int cols = 3;
Tuple2<List<Node>, List<EllipseRotated_F64>> grid0 = createHexagonalGrid(rows, cols, 0.5, 1);
Tuple2<List<Node>, List<EllipseRotated_F64>> grid1 = createHexagonalGrid(rows, cols, 0.5, 1);
List<List<Node>> nodes = new ArrayList<>();
List<EllipseRotated_F64> ellipses = new ArrayList<>();
nodes.add(grid0.data0);
nodes.add(grid1.data0);
ellipses.addAll(grid0.data1);
ellipses.addAll(grid1.data1);
// adjust indexing for second grid
for (Node n : grid1.data0) {
n.cluster = 1;
n.which += grid0.data1.size();
for (int i = 0; i < n.connections.size(); i++) {
n.connections.data[i] += grid0.data1.size();
}
}
EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
alg.process(ellipses, nodes);
FastQueue<Grid> found = alg.getGrids();
assertEquals(2, found.size());
checkShape(rows, cols, found.get(0));
checkShape(rows, cols, found.get(1));
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestEllipseClustersIntoRegularGrid method createRegularGrid.
@Test
public void createRegularGrid() {
// create a grid in the expected format
int rows = 4;
int cols = 3;
Tuple2<List<Node>, List<EllipseRotated_F64>> grid = TestEllipseClustersIntoGrid.createRegularGrid(rows, cols);
EllipseClustersIntoRegularGrid alg = new EllipseClustersIntoRegularGrid();
alg.computeNodeInfo(grid.data1, grid.data0);
// split into the two grids
List<List<NodeInfo>> input = convertIntoGridOfLists(0, rows, cols, alg);
Grid g = new Grid();
alg.createRegularGrid(input, g);
assertEquals(rows, g.rows);
assertEquals(cols, g.columns);
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
assertTrue(input.get(row).get(col).ellipse == g.get(row, col));
}
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestKeyPointsCircleHexagonalGrid method all.
public void all(int numRows, int numCols) {
KeyPointsCircleHexagonalGrid alg = new KeyPointsCircleHexagonalGrid();
double r = 0.5;
double s = 2.0;
Grid grid = createGrid(numRows, numCols, s, r);
alg.process(grid);
int idx = 0;
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
if (row % 2 == 0 && col % 2 == 1)
continue;
if (row % 2 == 1 && col % 2 == 0)
continue;
Point2D_F64 p = alg.getKeyPoints().get(idx++);
assertEquals(col * s, p.x, GrlConstants.TEST_F64);
assertEquals(row * s, p.y, GrlConstants.TEST_F64);
}
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestKeyPointsCircleHexagonalGrid method horizontal.
private void horizontal(int numRows, int numCols) {
KeyPointsCircleHexagonalGrid alg = new KeyPointsCircleHexagonalGrid();
double r = 0.5;
double s = 2.0;
Grid grid = createGrid(numRows, numCols, s, r);
alg.init(grid);
alg.horizontal(grid);
for (int row = 0; row < grid.rows; row++) {
for (int col = 0; col < grid.columns; col++) {
int index = grid.getIndexOfHexEllipse(row, col);
if (row % 2 == 0 && col % 2 == 0) {
if (col == 0 || col == grid.columns - 1 - (1 - grid.columns % 2))
assertEquals(2, alg.tangents.get(index).size);
else
assertEquals(row + " " + col, 4, alg.tangents.get(index).size);
} else if (row % 2 == 1 && col % 2 == 1) {
if (col == 1 || col == grid.columns - 1 - (grid.columns % 2))
assertEquals(2, alg.tangents.get(index).size);
else
assertEquals(4, alg.tangents.get(index).size);
}
}
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestKeyPointsCircleHexagonalGrid method vertical.
private void vertical(int numRows, int numCols) {
KeyPointsCircleHexagonalGrid alg = new KeyPointsCircleHexagonalGrid();
double r = 0.5;
double s = 2.0;
Grid grid = createGrid(numRows, numCols, s, r);
alg.init(grid);
alg.vertical(grid);
for (int row = 0; row < grid.rows; row++) {
for (int col = 0; col < grid.columns; col++) {
int index = grid.getIndexOfHexEllipse(row, col);
if (row % 2 == 0 && col % 2 == 0) {
if (row == 0 || row == grid.rows - 1 - (1 - grid.rows % 2))
assertEquals(2, alg.tangents.get(index).size);
else
assertEquals(4, alg.tangents.get(index).size);
} else if (row % 2 == 1 && col % 2 == 1) {
if (row == 1 || row == grid.rows - 1 - (grid.rows % 2))
assertEquals(2, alg.tangents.get(index).size);
else
assertEquals(4, alg.tangents.get(index).size);
}
}
}
}
Aggregations