Search in sources :

Example 36 with EllipseRotated_F64

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

the class TestDetectCircleGrid method closestCorner4.

@Test
public void closestCorner4() {
    Grid g = new Grid();
    g.rows = 3;
    g.columns = 3;
    g.ellipses.add(new EllipseRotated_F64(20, 20, 0, 0, 0));
    g.ellipses.add(null);
    g.ellipses.add(new EllipseRotated_F64(20, 100, 0, 0, 0));
    g.ellipses.add(null);
    g.ellipses.add(new EllipseRotated_F64());
    g.ellipses.add(null);
    g.ellipses.add(new EllipseRotated_F64(100, 20, 0, 0, 0));
    g.ellipses.add(null);
    g.ellipses.add(new EllipseRotated_F64(100, 100, 0, 0, 0));
    assertEquals(0, DetectCircleGrid.closestCorner4(g));
    g.ellipses.get(0).center.set(20, 100);
    g.ellipses.get(2).center.set(100, 20);
    g.ellipses.get(6).center.set(100, 100);
    g.ellipses.get(8).center.set(20, 20);
    assertEquals(2, DetectCircleGrid.closestCorner4(g));
    g.ellipses.get(0).center.set(100, 20);
    g.ellipses.get(2).center.set(100, 100);
    g.ellipses.get(6).center.set(20, 20);
    g.ellipses.get(8).center.set(20, 100);
    assertEquals(1, DetectCircleGrid.closestCorner4(g));
    g.ellipses.get(0).center.set(100, 100);
    g.ellipses.get(2).center.set(20, 20);
    g.ellipses.get(6).center.set(20, 100);
    g.ellipses.get(8).center.set(100, 20);
    assertEquals(3, DetectCircleGrid.closestCorner4(g));
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid) TestDetectCircleHexagonalGrid.createGrid(boofcv.alg.fiducial.calib.circle.TestDetectCircleHexagonalGrid.createGrid) Test(org.junit.Test)

Example 37 with EllipseRotated_F64

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

the class TestDetectCircleHexagonalGrid method checkCounterClockWise.

static void checkCounterClockWise(Grid g) {
    EllipseRotated_F64 a = g.get(0, 0);
    EllipseRotated_F64 b = g.columns >= 3 ? g.get(0, 2) : g.get(1, 1);
    EllipseRotated_F64 c = g.rows >= 3 ? g.get(2, 0) : g.get(1, 1);
    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);
}
Also used : Vector3D_F64(georegression.struct.point.Vector3D_F64) EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64)

Example 38 with EllipseRotated_F64

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

the class TestDetectCircleHexagonalGrid method createGrid.

static Grid createGrid(int numRows, int numCols) {
    Grid g = new Grid();
    g.rows = numRows;
    g.columns = numCols;
    for (int i = 0; i < numRows; i++) {
        for (int j = 0; j < numCols; j++) {
            if (i % 2 == 0) {
                if (j % 2 == 0)
                    g.ellipses.add(new EllipseRotated_F64(j * 20, i * 20, 0, 0, 0));
                else
                    g.ellipses.add(null);
            } else {
                if (j % 2 == 0)
                    g.ellipses.add(null);
                else
                    g.ellipses.add(new EllipseRotated_F64(j * 20, i * 20, 0, 0, 0));
            }
        }
    }
    return g;
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)

Example 39 with EllipseRotated_F64

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

the class TestDetectCircleRegularGrid method performDetectionCheck.

private void performDetectionCheck(int expectedRows, int expectedCols, int actualRows, int actualCols, Affine2D_F64 affine) {
    int diameter = 40;
    int centerDistances = 120;
    DetectCircleRegularGrid<GrayU8> alg = createAlg(expectedRows, expectedCols, diameter, centerDistances);
    // alg.setVerbose(true);
    List<Point2D_F64> keypoints = new ArrayList<>();
    List<Point2D_F64> centers = new ArrayList<>();
    GrayU8 image = new GrayU8(500, 550);
    render(actualRows, actualCols, diameter / 2.0, centerDistances, affine, keypoints, centers, image);
    alg.process(image);
    List<Grid> found = alg.getGrids();
    if (expectedRows != actualRows || expectedCols != actualCols) {
        assertEquals(0, found.size());
        return;
    } else {
        assertEquals(1, found.size());
    }
    Grid g = found.get(0);
    assertEquals(actualRows, g.rows);
    assertEquals(actualCols, g.columns);
    TestDetectCircleRegularGrid.checkCounterClockWise(g);
    for (int row = 0; row < g.rows; row++) {
        for (int col = 0; col < g.columns; col++) {
            EllipseRotated_F64 f = g.get(row, col);
            Point2D_F64 e = centers.get(row * g.columns + col);
            assertEquals(e.x, f.center.x, 1.5);
            assertEquals(e.y, f.center.y, 1.5);
            assertEquals(20, f.a, 1.0);
            assertEquals(20, f.b, 1.0);
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid) ArrayList(java.util.ArrayList) GrayU8(boofcv.struct.image.GrayU8)

Example 40 with EllipseRotated_F64

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

the class TestDetectCircleRegularGrid method createGrid.

static Grid createGrid(int numRows, int numCols) {
    Grid g = new Grid();
    g.rows = numRows;
    g.columns = numCols;
    for (int i = 0; i < numRows; i++) {
        for (int j = 0; j < numCols; j++) {
            g.ellipses.add(new EllipseRotated_F64(j * 20, i * 20, 0, 0, 0));
        }
    }
    return g;
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid)

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