Search in sources :

Example 11 with Grid

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);
            }
        }
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) NodeInfo(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 12 with Grid

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));
    }
}
Also used : Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 13 with Grid

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);
        }
    }
}
Also used : Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)

Example 14 with Grid

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;
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)

Example 15 with 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;
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)

Aggregations

Grid (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)33 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)18 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)7 Point2D_F64 (georegression.struct.point.Point2D_F64)6 TestDetectCircleHexagonalGrid.createGrid (boofcv.alg.fiducial.calib.circle.TestDetectCircleHexagonalGrid.createGrid)4 List (java.util.List)4 SquareGrid (boofcv.alg.fiducial.calib.squares.SquareGrid)3 CalibrationDetectorCircleHexagonalGrid (boofcv.abst.fiducial.calib.CalibrationDetectorCircleHexagonalGrid)2 ConfigCircleHexagonalGrid (boofcv.abst.fiducial.calib.ConfigCircleHexagonalGrid)2 Tangents (boofcv.alg.fiducial.calib.circle.KeyPointsCircleRegularGrid.Tangents)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2 GrayU8 (boofcv.struct.image.GrayU8)2 CalibrationDetectorCircleRegularGrid (boofcv.abst.fiducial.calib.CalibrationDetectorCircleRegularGrid)1 ConfigCircleRegularGrid (boofcv.abst.fiducial.calib.ConfigCircleRegularGrid)1 DetectCircleHexagonalGrid (boofcv.alg.fiducial.calib.circle.DetectCircleHexagonalGrid)1 DetectCircleRegularGrid (boofcv.alg.fiducial.calib.circle.DetectCircleRegularGrid)1 NodeInfo (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo)1 Node (boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node)1 KeyPointsCircleHexagonalGrid (boofcv.alg.fiducial.calib.circle.KeyPointsCircleHexagonalGrid)1