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;
}
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);
}
}
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);
}
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));
}
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();
}
Aggregations