Search in sources :

Example 1 with Node

use of boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoGrid method createNode.

static Node createNode(int which, int... connections) {
    Node n = new Node();
    n.which = which;
    n.connections.addAll(connections, 0, connections.length);
    return n;
}
Also used : Node(boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node)

Example 2 with Node

use of boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoGrid method computeNodeInfo.

/**
 * This test just checks to see if a node info is created for each node passed in and that
 * the ellipse is assinged to it.  The inner functions are tested elsewhere
 */
@Test
public void computeNodeInfo() {
    List<Node> nodes = new ArrayList<>();
    nodes.add(createNode(0, 1, 2, 3));
    nodes.add(createNode(1, 0, 2, 4));
    nodes.add(createNode(2, 0, 1));
    nodes.add(createNode(3, 0));
    nodes.add(createNode(4));
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    for (int i = 0; i < nodes.size(); i++) {
        ellipses.add(new EllipseRotated_F64());
    }
    EllipseClustersIntoGrid alg = new HelperAlg();
    alg.computeNodeInfo(ellipses, nodes);
    assertEquals(nodes.size(), alg.listInfo.size);
    for (int i = 0; i < nodes.size(); i++) {
        assertTrue(ellipses.get(i) == alg.listInfo.get(i).ellipse);
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Node(boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with Node

use of boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoGrid method connectEllipses.

static Tuple2<List<Node>, List<EllipseRotated_F64>> connectEllipses(List<EllipseRotated_F64> ellipses, double distance) {
    List<Node> cluster = new ArrayList<>();
    for (int i = 0; i < ellipses.size(); i++) {
        cluster.add(new Node());
        cluster.get(i).which = i;
    }
    for (int i = 0; i < ellipses.size(); i++) {
        Node n0 = cluster.get(i);
        EllipseRotated_F64 e0 = ellipses.get(i);
        for (int j = i + 1; j < ellipses.size(); j++) {
            Node n1 = cluster.get(j);
            EllipseRotated_F64 e1 = ellipses.get(j);
            if (e1.center.distance(e0.center) <= distance) {
                n0.connections.add(j);
                n1.connections.add(i);
            }
        }
    }
    return new Tuple2<>(cluster, ellipses);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Tuple2(org.ddogleg.struct.Tuple2) Node(boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node) ArrayList(java.util.ArrayList)

Example 4 with Node

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

use of boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node in project BoofCV by lessthanoptimal.

the class EllipseClustersIntoGrid method computeNodeInfo.

/**
 * For each cluster create a {@link NodeInfo} and compute different properties
 */
void computeNodeInfo(List<EllipseRotated_F64> ellipses, List<Node> cluster) {
    // create an info object for each member inside of the cluster
    listInfo.reset();
    for (int i = 0; i < cluster.size(); i++) {
        Node n = cluster.get(i);
        EllipseRotated_F64 t = ellipses.get(n.which);
        NodeInfo info = listInfo.grow();
        info.reset();
        info.ellipse = t;
    }
    addEdgesToInfo(cluster);
    pruneNearlyIdenticalAngles();
    findLargestAnglesForAllNodes();
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Node(boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node)

Aggregations

Node (boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node)6 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)5 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)2 Grid (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)1 List (java.util.List)1 Tuple2 (org.ddogleg.struct.Tuple2)1