Search in sources :

Example 31 with EllipseRotated_F64

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

the class TestBinaryEllipseDetectorPixel method checkEquals_F64.

public static void checkEquals_F64(List<EllipseRotated_F64> expected, List<EllipseRotated_F64> found, double tol, double tolPhi) {
    assertEquals(expected.size(), found.size());
    boolean[] matched = new boolean[expected.size()];
    for (EllipseRotated_F64 f : found) {
        boolean foundMatch = false;
        for (int i = 0; i < expected.size(); i++) {
            EllipseRotated_F64 e = expected.get(i);
            if (Math.abs(f.a - e.a) <= tol && Math.abs(f.b - e.b) <= tol) {
                boolean angleMatch = true;
                // if it's a circle ignore the angle
                if (Math.abs(e.a - e.b) / Math.max(e.a, e.b) > 0.01) {
                    angleMatch = UtilAngle.distHalf(f.phi, e.phi) <= tolPhi;
                }
                if (angleMatch && e.center.distance(f.center) <= tol) {
                    foundMatch = matched[i] = true;
                }
            }
        }
        if (!foundMatch) {
            System.out.println("Found");
            System.out.println(f);
            System.out.println("\nExpected");
            for (int i = 0; i < expected.size(); i++) {
                System.out.println(expected.get(i));
            }
        }
        assertTrue(foundMatch);
    }
    for (int i = 0; i < matched.length; i++) {
        assertTrue(matched[i]);
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64)

Example 32 with EllipseRotated_F64

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

the class TestEdgeIntensityEllipse method check.

/**
 * Basic check to see if the score is higher when dead on.
 */
private void check(EllipseRotated_F64 ellipse) {
    List<EllipseRotated_F64> list = new ArrayList<>();
    list.add(ellipse);
    GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, list, 0);
    EdgeIntensityEllipse<GrayU8> alg = new EdgeIntensityEllipse<>(1.5, 20, 10.0, GrayU8.class);
    alg.setImage(image);
    assertTrue(alg.process(ellipse));
    double score0 = alg.getEdgeIntensity();
    // now try it again with it offset a little.  score should go down
    ellipse.center.x += 0.75;
    assertTrue(alg.process(ellipse));
    double score1 = alg.getEdgeIntensity();
    assertTrue(score1 < score0);
    assertTrue(score0 >= 0 && score0 <= 255);
    assertTrue(score1 >= 0 && score1 <= 255);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList) GrayU8(boofcv.struct.image.GrayU8)

Example 33 with EllipseRotated_F64

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

the class TestSnapToEllipseEdge method simpleNoChange_border.

/**
 * The ellipse touches the image border
 */
@Test
public void simpleNoChange_border() {
    EllipseRotated_F64 target = new EllipseRotated_F64(35, 85, 50, 40, 0);
    EllipseRotated_F64 found = new EllipseRotated_F64();
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    ellipses.add(target);
    GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 300, ellipses, 0);
    SnapToEllipseEdge<GrayU8> alg = new SnapToEllipseEdge<>(30, 1, GrayU8.class);
    alg.setImage(image);
    assertTrue(alg.process(target, found));
    TestBinaryEllipseDetectorPixel.checkEquals(target, found, 1.0, 0.01);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 34 with EllipseRotated_F64

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

the class TestSnapToEllipseEdge method simpleNoChange.

/**
 * Simple test case involving a fully rendered image and known result
 */
@Test
public void simpleNoChange() {
    EllipseRotated_F64 target = new EllipseRotated_F64(80, 85, 50, 40, 0);
    EllipseRotated_F64 found = new EllipseRotated_F64();
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    ellipses.add(target);
    GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 300, ellipses, 0);
    SnapToEllipseEdge<GrayU8> alg = new SnapToEllipseEdge<>(30, 1, GrayU8.class);
    alg.setImage(image);
    assertTrue(alg.process(target, found));
    TestBinaryEllipseDetectorPixel.checkEquals(target, found, 1.0, 0.01);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 35 with EllipseRotated_F64

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

the class TestShapeFittingOps method fitEllipse_F64.

/**
 * Check the found solution
 */
@Test
public void fitEllipse_F64() {
    EllipseRotated_F64 rotated = new EllipseRotated_F64(1, 2, 3, 2, -0.05);
    List<Point2D_F64> points = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        double theta = 2.0 * (double) Math.PI * i / 20;
        points.add(UtilEllipse_F64.computePoint(theta, rotated, null));
    }
    EllipseRotated_F64 found = ShapeFittingOps.fitEllipse_F64(points, 0, false, null).shape;
    assertEquals(rotated.center.x, found.center.x, 1e-8);
    assertEquals(rotated.center.y, found.center.y, 1e-8);
    assertEquals(rotated.a, found.a, 1e-8);
    assertEquals(rotated.b, found.b, 1e-8);
    assertEquals(rotated.phi, found.phi, 1e-8);
    // make sure refinement doesn't skew it up
    found = ShapeFittingOps.fitEllipse_F64(points, 20, false, null).shape;
    assertEquals(rotated.center.x, found.center.x, 1e-8);
    assertEquals(rotated.center.y, found.center.y, 1e-8);
    assertEquals(rotated.a, found.a, 1e-8);
    assertEquals(rotated.b, found.b, 1e-8);
    assertEquals(rotated.phi, found.phi, 1e-8);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Test(org.junit.Test)

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