use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestDetectCircleHexagonalGrid method putGridIntoCanonical_vertical.
private void putGridIntoCanonical_vertical(int numRows, int numCols) {
DetectCircleHexagonalGrid<?> alg = new DetectCircleHexagonalGrid(numRows, numCols, null, null, null);
Grid g = createGrid(numRows, numCols);
List<EllipseRotated_F64> original = new ArrayList<>();
original.addAll(g.ellipses);
alg.putGridIntoCanonical(g);
assertEquals(numRows, g.rows);
assertEquals(numCols, g.columns);
assertTrue(original.get(0) == g.get(0, 0));
checkCounterClockWise(g);
alg.putGridIntoCanonical(TestDetectCircleGrid.flipVertical(g));
assertEquals(numRows, g.rows);
assertEquals(numCols, g.columns);
assertTrue(original.get(0) == g.get(0, 0));
checkCounterClockWise(g);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestDetectCircleRegularGrid method checkCounterClockWise.
static void checkCounterClockWise(Grid g) {
EllipseRotated_F64 a = g.get(0, 0);
EllipseRotated_F64 b = g.get(0, 1);
EllipseRotated_F64 c = g.get(1, 0);
double dx0 = b.center.x - a.center.x;
double dy0 = b.center.y - a.center.y;
double dx1 = c.center.x - a.center.x;
double dy1 = c.center.y - a.center.y;
Vector3D_F64 v = new Vector3D_F64();
GeometryMath_F64.cross(dx0, dy0, 0, dx1, dy1, 0, v);
assertTrue(v.z > 0);
}
use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.
the class TestDetectCircleRegularGrid method putGridIntoCanonical_flip.
private void putGridIntoCanonical_flip(int numRows, int numCols) {
DetectCircleRegularGrid<?> alg = new DetectCircleRegularGrid(numRows, numCols, null, null, null);
Grid g = createGrid(numRows, numCols);
List<EllipseRotated_F64> original = new ArrayList<>();
original.addAll(g.ellipses);
alg.putGridIntoCanonical(g);
assertEquals(numRows, g.rows);
assertEquals(numCols, g.columns);
assertTrue(original.get(0) == g.get(0, 0));
checkCounterClockWise(g);
g = TestDetectCircleGrid.flipHorizontal(g);
alg.putGridIntoCanonical(g);
assertEquals(numRows, g.rows);
assertEquals(numCols, g.columns);
assertTrue(original.get(0) == g.get(0, 0));
checkCounterClockWise(g);
g = TestDetectCircleGrid.flipVertical(g);
alg.putGridIntoCanonical(g);
assertEquals(numRows, g.rows);
assertEquals(numCols, g.columns);
assertTrue(original.get(0) == g.get(0, 0));
checkCounterClockWise(g);
}
use of georegression.struct.curve.EllipseRotated_F64 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 georegression.struct.curve.EllipseRotated_F64 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);
}
}
Aggregations