use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestEllipseClustersIntoHexagonalGrid method saveResults.
@Test
public void saveResults() {
// construct a dummy graph
List<List<NodeInfo>> graph = new ArrayList<>();
for (int i = 0; i < 3; i++) {
graph.add(new ArrayList<NodeInfo>());
}
for (int i = 0; i < 2; i++) {
graph.get(0).add(new NodeInfo());
graph.get(2).add(new NodeInfo());
}
graph.get(1).add(new NodeInfo());
for (List<NodeInfo> row : graph) {
for (NodeInfo n : row) {
n.ellipse = new EllipseRotated_F64();
}
}
EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
alg.saveResults(graph);
Grid g = alg.getGrids().get(0);
assertEquals(3, g.columns);
assertEquals(3, g.rows);
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
if (row % 2 == col % 2) {
assertTrue(g.get(row, col) != null);
} else {
assertTrue(g.get(row, col) == null);
}
}
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestEllipseClustersIntoRegularGrid method process.
public void process(int rows, int cols, boolean fail) {
Tuple2<List<Node>, List<EllipseRotated_F64>> grid = TestEllipseClustersIntoGrid.createRegularGrid(rows, cols);
List<List<Node>> clusters = new ArrayList<>();
clusters.add(grid.data0);
EllipseClustersIntoRegularGrid alg = new EllipseClustersIntoRegularGrid();
alg.process(grid.data1, clusters);
FastQueue<Grid> found = alg.getGrids();
if (fail) {
assertEquals(0, found.size);
} else {
assertEquals(1, found.size);
Grid g = found.get(0);
assertTrue((g.rows == rows && g.columns == cols) || (g.rows == cols && g.columns == rows));
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestKeyPointsCircleHexagonalGrid method diagonalLR.
private void diagonalLR(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.diagonalLR(grid);
for (int row = 0; row < grid.rows; row++) {
for (int col = 0; col < grid.columns; col++) {
if (row % 2 == 0 && col % 2 == 1)
continue;
if (row % 2 == 1 && col % 2 == 0)
continue;
int index = grid.getIndexOfHexEllipse(row, col);
int expectedNumber = 0;
if (col >= 1 && row >= 1)
expectedNumber += 2;
if (col < grid.columns - 1 && row < grid.rows - 1)
expectedNumber += 2;
assertEquals(expectedNumber, alg.tangents.get(index).size);
}
}
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestKeyPointsCircleHexagonalGrid method createGrid.
public static Grid createGrid(int numRows, int numCols, double space, double radius) {
Grid grid = new Grid();
grid.rows = numRows;
grid.columns = numCols;
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
if (row % 2 == 0 && col % 2 == 1)
grid.ellipses.add(null);
else if (row % 2 == 1 && col % 2 == 0)
grid.ellipses.add(null);
else {
double x = col * space;
double y = row * space;
grid.ellipses.add(new EllipseRotated_F64(x, y, radius, radius, 0));
}
}
}
return grid;
}
use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid in project BoofCV by lessthanoptimal.
the class TestKeyPointsCircleRegularGrid method createGrid.
public static Grid createGrid(int numRows, int numCols, double space, double radius) {
Grid grid = new Grid();
grid.rows = numRows;
grid.columns = numCols;
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
double x = col * space;
double y = row * space;
grid.ellipses.add(new EllipseRotated_F64(x, y, radius, radius, 0));
}
}
return grid;
}
Aggregations