Search in sources :

Example 1 with NodeInfo

use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoGrid method findClosestEdge_.

@Test
public void findClosestEdge_() {
    NodeInfo n = setNodeInfo(null, -2, 0);
    n.edges.grow().target = setNodeInfo(null, 2, 2);
    n.edges.grow().target = setNodeInfo(null, 2, 0);
    n.edges.grow().target = setNodeInfo(null, -2, -2);
    assertTrue(n.edges.get(0).target == findClosestEdge(n, new Point2D_F64(2, 1.5)));
    assertTrue(n.edges.get(1).target == findClosestEdge(n, new Point2D_F64(1.9, 0)));
    assertTrue(n.edges.get(2).target == findClosestEdge(n, new Point2D_F64(-2, -1)));
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) NodeInfo(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo) Test(org.junit.Test)

Example 2 with NodeInfo

use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoGrid method selectSeedCorner.

@Test
public void selectSeedCorner() {
    EllipseClustersIntoGrid alg = new HelperAlg();
    NodeInfo best = new NodeInfo();
    best.angleBetween = 3.0 * Math.PI / 2.0;
    for (int i = 0; i < 10; i++) {
        NodeInfo n = new NodeInfo();
        n.angleBetween = best.angleBetween * (i / 10.0);
        alg.contour.add(n);
        if (i == 4)
            alg.contour.add(best);
    }
    NodeInfo found = alg.selectSeedCorner();
    assertTrue(found == best);
}
Also used : NodeInfo(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo) Test(org.junit.Test)

Example 3 with NodeInfo

use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoHexagonalGrid method bottomTwoColumns_case0.

/**
 * There's a longer row to add
 */
@Test
public void bottomTwoColumns_case0() {
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        ellipses.add(new EllipseRotated_F64(i, 0, 1, 1, 0));
        ellipses.add(new EllipseRotated_F64(i + 0.5, hexY, 1, 1, 0));
        ellipses.add(new EllipseRotated_F64(i, hexY * 2, 1, 1, 0));
    }
    Tuple2<List<Node>, List<EllipseRotated_F64>> input = connectEllipses(ellipses, hexY * 2.1);
    EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
    alg.computeNodeInfo(input.data1, input.data0);
    alg.findContour(true);
    List<NodeInfo> column0 = new ArrayList<>();
    List<NodeInfo> column1 = new ArrayList<>();
    // first two on top row
    NodeInfo corner = alg.listInfo.get(2);
    NodeInfo next = alg.listInfo.get(5);
    corner.marked = next.marked = true;
    alg.bottomTwoColumns(corner, next, column0, column1);
    assertEquals(3, column0.size());
    assertEquals(3, column1.size());
    for (int i = 0; i < 3; i++) {
        assertTrue(column0.get(i).ellipse.center.distance(i, hexY * 2) < 1e-4);
        assertTrue(column1.get(i).ellipse.center.distance(i + 0.5, hexY) < 1e-4);
        assertTrue(column0.get(i).marked);
        assertTrue(column1.get(i).marked);
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) NodeInfo(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 4 with NodeInfo

use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo 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 5 with NodeInfo

use of boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoHexagonalGrid method selectClosest.

@Test
public void selectClosest() {
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    ellipses.add(new EllipseRotated_F64(0, 0, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(0.5, 0.866, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(0.5, 1.2, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(1, 0, 1, 1, 0));
    Tuple2<List<Node>, List<EllipseRotated_F64>> input = connectEllipses(ellipses, 2);
    EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
    alg.computeNodeInfo(input.data1, input.data0);
    NodeInfo found = EllipseClustersIntoHexagonalGrid.selectClosestN(alg.listInfo.get(0), alg.listInfo.get(1));
    assertTrue(found != null);
    assertTrue(found.ellipse == ellipses.get(3));
    // move the node out of range it nothing should be accepted
    alg.listInfo.get(3).ellipse.set(0, 1, 1, 1, 0);
    input = connectEllipses(ellipses, 1.1);
    alg.computeNodeInfo(input.data1, input.data0);
    found = EllipseClustersIntoHexagonalGrid.selectClosestN(alg.listInfo.get(0), alg.listInfo.get(1));
    assertTrue(found == null);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) NodeInfo(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

NodeInfo (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)6 List (java.util.List)6 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)5 Grid (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1