Search in sources :

Example 6 with NodeInfo

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

the class TestEllipseClustersIntoGrid method selectSeedNext.

@Test
public void selectSeedNext() {
    // create a grid from which a known solution can be easily extracted
    int rows = 5;
    int cols = 4;
    Tuple2<List<Node>, List<EllipseRotated_F64>> grid = createRegularGrid(rows, cols);
    EllipseClustersIntoGrid alg = new HelperAlg();
    alg.computeNodeInfo(grid.data1, grid.data0);
    alg.listInfo.get(0).marked = true;
    alg.listInfo.get(1).marked = true;
    NodeInfo found = EllipseClustersIntoGrid.selectSeedNext(alg.listInfo.get(0), alg.listInfo.get(1), alg.listInfo.get(cols), true);
    assertTrue(found == alg.listInfo.get(cols + 1));
}
Also used : NodeInfo(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 7 with NodeInfo

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

the class TestEllipseClustersIntoHexagonalGrid method selectClosestSide.

@Test
public void selectClosestSide() {
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    ellipses.add(new EllipseRotated_F64(0, 0, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(1, 0, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(0.5, 0.866, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(0, 0.866 * 2, 1, 1, 0));
    ellipses.add(new EllipseRotated_F64(1, 0.866 * 2, 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.selectClosestSide(alg.listInfo.get(2), alg.listInfo.get(0));
    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)

Example 8 with NodeInfo

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

the class TestEllipseClustersIntoHexagonalGrid method bottomTwoColumns_case1.

/**
 * The second column has only one element
 */
@Test
public void bottomTwoColumns_case1() {
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    for (int i = 0; i < 2; i++) {
        ellipses.add(new EllipseRotated_F64(i, 0, 1, 1, 0));
        ellipses.add(new EllipseRotated_F64(i, hexY * 2, 1, 1, 0));
        if (i == 0) {
            ellipses.add(new EllipseRotated_F64(i + 0.5, hexY, 1, 1, 0));
            ellipses.add(new EllipseRotated_F64(i + 0.5, 1.732, 1, 1, 0));
        }
    }
    Tuple2<List<Node>, List<EllipseRotated_F64>> input = connectEllipses(ellipses, 1.1);
    EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
    alg.computeNodeInfo(input.data1, input.data0);
    alg.findContour(true);
    List<NodeInfo> column0 = new ArrayList<>();
    List<NodeInfo> column1 = new ArrayList<>();
    NodeInfo corner = alg.listInfo.get(4);
    NodeInfo next = alg.listInfo.get(0);
    corner.marked = next.marked = true;
    alg.bottomTwoColumns(corner, next, column0, column1);
    assertEquals(2, column0.size());
    assertEquals(1, column1.size());
    assertTrue(column0.get(0).ellipse.center.distance(1, 0) < 1e-4);
    assertTrue(column0.get(1).ellipse.center.distance(0, 0) < 1e-4);
    assertTrue(column1.get(0).ellipse.center.distance(0.5, hexY) < 1e-4);
}
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