Search in sources :

Example 21 with EllipseRotated_F64

use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.

the class TestEllipseClustersIntoHexagonalGrid method process_affine.

private void process_affine(int rows, int cols, Affine2D_F64 affine) {
    // create a grid in the expected format
    EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
    Tuple2<List<Node>, List<EllipseRotated_F64>> grid = createHexagonalGrid(rows, cols, 0.5, 1);
    for (EllipseRotated_F64 e : grid.data1) {
        AffinePointOps_F64.transform(affine, e.center, e.center);
    }
    List<List<Node>> nodes = new ArrayList<>();
    nodes.add(grid.data0);
    processAndCheck(rows, cols, alg, grid, nodes);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 22 with EllipseRotated_F64

use of georegression.struct.curve.EllipseRotated_F64 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 23 with EllipseRotated_F64

use of georegression.struct.curve.EllipseRotated_F64 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)

Example 24 with EllipseRotated_F64

use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.

the class TestEllipsesIntoClusters method axisAdjustedDistance.

@Test
public void axisAdjustedDistance() {
    EllipseRotated_F64 a = new EllipseRotated_F64(2, 3, 3, 3, 0);
    EllipseRotated_F64 b = new EllipseRotated_F64(6, 3, 3, 3, 0);
    // it's circular so it should be the usual euclidean distance squared
    assertEquals(4 * 4, EllipsesIntoClusters.axisAdjustedDistanceSq(a, b), 1e-6);
    a.phi = Math.PI / 2.0;
    assertEquals(4 * 4, EllipsesIntoClusters.axisAdjustedDistanceSq(a, b), 1e-6);
    // not a circle any more.  First test it lies along the major axis, should still be euclidean
    a.a = 6;
    a.phi = 0;
    assertEquals(4 * 4, EllipsesIntoClusters.axisAdjustedDistanceSq(a, b), 1e-6);
    // now rotate it.  Distance should double
    a.phi = Math.PI / 2.0;
    assertEquals(8 * 8, EllipsesIntoClusters.axisAdjustedDistanceSq(a, b), 1e-6);
    // Now do a rigorous test across all angles
    for (int i = 0; i < 60; i++) {
        a.phi = 2.0 * Math.PI * i / 60;
        double dd = Math.pow(4 * Math.cos(a.phi), 2) + Math.pow(2 * 4 * Math.sin(a.phi), 2);
        assertEquals(dd, EllipsesIntoClusters.axisAdjustedDistanceSq(a, b), 1e-6);
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Test(org.junit.Test)

Example 25 with EllipseRotated_F64

use of georegression.struct.curve.EllipseRotated_F64 in project BoofCV by lessthanoptimal.

the class TestEllipsesIntoClusters method create.

private EllipseInfo create(double x0, double y0, double a, double b, double phi) {
    EllipseInfo out = new EllipseInfo();
    out.ellipse = new EllipseRotated_F64(x0, y0, a, b, phi);
    out.averageInside = 10;
    out.averageOutside = 200;
    out.contour = new ArrayList<>();
    return out;
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) EllipseInfo(boofcv.alg.shapes.ellipse.BinaryEllipseDetector.EllipseInfo)

Aggregations

EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)62 ArrayList (java.util.ArrayList)34 Test (org.junit.Test)25 Grid (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)18 GrayU8 (boofcv.struct.image.GrayU8)15 Point2D_F64 (georegression.struct.point.Point2D_F64)9 List (java.util.List)9 NodeInfo (boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.NodeInfo)5 Node (boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node)5 EllipsesIntoClusters (boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters)2 TestDetectCircleHexagonalGrid.createGrid (boofcv.alg.fiducial.calib.circle.TestDetectCircleHexagonalGrid.createGrid)2 SquareGrid (boofcv.alg.fiducial.calib.squares.SquareGrid)2 SquareNode (boofcv.alg.fiducial.calib.squares.SquareNode)2 EllipseInfo (boofcv.alg.shapes.ellipse.BinaryEllipseDetector.EllipseInfo)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 Vector3D_F64 (georegression.struct.point.Vector3D_F64)2 AffineTransform (java.awt.geom.AffineTransform)2 BufferedImage (java.awt.image.BufferedImage)2 CalibrationDetectorCircleHexagonalGrid (boofcv.abst.fiducial.calib.CalibrationDetectorCircleHexagonalGrid)1 CalibrationDetectorCircleRegularGrid (boofcv.abst.fiducial.calib.CalibrationDetectorCircleRegularGrid)1