Search in sources :

Example 46 with EllipseRotated_F64

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

the class TestEllipseClustersIntoHexagonalGrid method createHexagonalGrid.

private Tuple2<List<Node>, List<EllipseRotated_F64>> createHexagonalGrid(int rows, int cols, double diameter, double distance) {
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    double spaceX = distance / 2.0;
    double spaceY = spaceX * hexY;
    double r = diameter / 2.0;
    for (int row = 0; row < rows; row++) {
        double y = row * spaceY;
        for (int col = row % 2; col < cols; col += 2) {
            double x = col * spaceX;
            ellipses.add(new EllipseRotated_F64(x, y, r, r, 0));
        }
    }
    return connectEllipses(ellipses, distance * 2);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList)

Example 47 with EllipseRotated_F64

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

the class DetectCalibrationCircleHexagonalApp method drawGraph.

private void drawGraph(Graphics2D g2, Grid g, int row0, int col0, double scale) {
    for (int row = row0; row < g.rows; row += 2) {
        for (int col = col0; col < g.columns; col += 2) {
            EllipseRotated_F64 a = g.get(row, col);
            line.x1 = scale * a.center.x;
            line.y1 = scale * a.center.y;
            if (col + 2 < g.columns) {
                EllipseRotated_F64 b = g.get(row, col + 2);
                line.x2 = scale * b.center.x;
                line.y2 = scale * b.center.y;
                g2.draw(line);
            }
            if (row + 2 < g.rows) {
                EllipseRotated_F64 b = g.get(row + 2, col);
                line.x2 = scale * b.center.x;
                line.y2 = scale * b.center.y;
                g2.draw(line);
            }
        }
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64)

Example 48 with EllipseRotated_F64

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

the class TestBinaryEllipseDetector method filterByEdge.

/**
 * Handle a situation where a shape should be filtered out based on its edge intensity
 */
@Test
public void filterByEdge() {
    List<EllipseRotated_F64> expected = new ArrayList<>();
    expected.add(new EllipseRotated_F64(50, 65, 20, 10, 0.5));
    GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, expected, 0);
    GrayU8 binary = image.createSameShape();
    ThresholdImageOps.threshold(image, binary, 30, true);
    BinaryEllipseDetector<GrayU8> alg = create();
    // pass once with it being a clear edge
    alg.process(image, binary);
    List<EllipseRotated_F64> found = alg.getFoundEllipses(null);
    TestBinaryEllipseDetectorPixel.checkEquals_F64(expected, found, 1.0, 0.1);
    // now make the ellipse more dim so it shouldn't pass
    image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, expected, 255 - THRESHOLD + 5);
    alg.process(image, binary);
    assertEquals(0, alg.getFound().size());
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 49 with EllipseRotated_F64

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

the class TestBinaryEllipseDetector method simpleCase.

/**
 * Simple test case with unambiguous detections
 */
@Test
public void simpleCase() {
    List<EllipseRotated_F64> expected = new ArrayList<>();
    expected.add(new EllipseRotated_F64(50, 65, 20, 10, 0.5));
    expected.add(new EllipseRotated_F64(90, 100, 25, 25, 0));
    GrayU8 image = TestBinaryEllipseDetectorPixel.renderEllipses_F64(200, 210, expected, 0);
    GrayU8 binary = image.createSameShape();
    ThresholdImageOps.threshold(image, binary, 30, true);
    BinaryEllipseDetector<GrayU8> alg = create();
    alg.process(image, binary);
    List<EllipseRotated_F64> found = alg.getFoundEllipses(null);
    TestBinaryEllipseDetectorPixel.checkEquals_F64(expected, found, 1.0, 0.1);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) ArrayList(java.util.ArrayList) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 50 with EllipseRotated_F64

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

the class TestBinaryEllipseDetectorPixel method isApproximatelyElliptical_large.

/**
 * Test to see if it is approximately elliptical when the number of pixels is larger
 * than the threshold
 */
@Test
public void isApproximatelyElliptical_large() {
    EllipseRotated_F64 ellipse = new EllipseRotated_F64(5, 3, 10, 6, 0);
    List<Point2D_F64> negative = TestShapeFittingOps.createRectangle_F64(20, 10, 60 - 4);
    List<Point2D_F64> positive = TestShapeFittingOps.createEllipse_F64(ellipse, 60 - 4);
    BinaryEllipseDetectorPixel alg = new BinaryEllipseDetectorPixel();
    alg.setMaxDistanceFromEllipse(1.5);
    assertFalse(alg.isApproximatelyElliptical(ellipse, negative, 20));
    assertTrue(alg.isApproximatelyElliptical(ellipse, positive, 20));
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Point2D_F64(georegression.struct.point.Point2D_F64) 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