Search in sources :

Example 11 with EllipseRotated_F64

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

the class KeyPointsCircleRegularGrid method addTangents.

/**
 * Computes tangent points to the two ellipses specified by the grid coordinates
 */
private boolean addTangents(Grid grid, int rowA, int colA, int rowB, int colB) {
    EllipseRotated_F64 a = grid.get(rowA, colA);
    EllipseRotated_F64 b = grid.get(rowB, colB);
    if (!tangentFinder.process(a, b, A0, A1, A2, A3, B0, B1, B2, B3)) {
        return false;
    }
    Tangents ta = tangents.get(grid.getIndexOfRegEllipse(rowA, colA));
    Tangents tb = tangents.get(grid.getIndexOfRegEllipse(rowB, colB));
    // Which point is 0 or 3 is not defined and can swap arbitrarily.  To fix this problem
    // 0 will be defined as on the 'positive side' of the line connecting the ellipse centers
    double slopeX = b.center.x - a.center.x;
    double slopeY = b.center.y - a.center.y;
    double dx0 = A0.x - a.center.x;
    double dy0 = A0.y - a.center.y;
    double z = slopeX * dy0 - slopeY * dx0;
    if (z < 0 == (rowA == rowB)) {
        Point2D_F64 tmp = A0;
        A0 = A3;
        A3 = tmp;
        tmp = B0;
        B0 = B3;
        B3 = tmp;
    }
    // add tangent points from the two lines which do not cross the center line
    if (rowA == rowB) {
        ta.t[ta.countT++].set(A0);
        ta.b[ta.countB++].set(A3);
        tb.t[tb.countT++].set(B0);
        tb.b[tb.countB++].set(B3);
    } else {
        ta.r[ta.countL++].set(A0);
        ta.l[ta.countR++].set(A3);
        tb.r[tb.countL++].set(B0);
        tb.l[tb.countR++].set(B3);
    }
    return true;
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 12 with EllipseRotated_F64

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

the class TestDetectCircleGrid method rotateGridCCW.

@Test
public void rotateGridCCW() {
    Grid g = createGrid(3, 3);
    List<EllipseRotated_F64> original = new ArrayList<>();
    original.addAll(g.ellipses);
    DetectCircleGrid<?> alg = new HelperAlg(3, 3);
    alg.rotateGridCCW(g);
    assertEquals(9, g.ellipses.size());
    assertTrue(original.get(6) == g.get(0, 0));
    assertTrue(original.get(0) == g.get(0, 2));
    assertTrue(original.get(2) == g.get(2, 2));
    assertTrue(original.get(8) == g.get(2, 0));
}
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) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with EllipseRotated_F64

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

the class TestDetectCircleHexagonalGrid method performDetectionCheck.

private void performDetectionCheck(int expectedRows, int expectedCols, int actualRows, int actualCols, Affine2D_F64 affine) {
    int radius = 20;
    int centerDistances = 50;
    DetectCircleHexagonalGrid<GrayU8> alg = createAlg(expectedRows, expectedCols, radius, centerDistances);
    // alg.setVerbose(true);
    List<Point2D_F64> locations = new ArrayList<>();
    GrayU8 image = new GrayU8(400, 450);
    render(actualRows, actualCols, radius, centerDistances, affine, locations, 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);
    TestDetectCircleHexagonalGrid.checkCounterClockWise(g);
    int index = 0;
    for (int row = 0; row < g.rows; row++) {
        for (int col = 0; col < g.columns; col++) {
            boolean check = false;
            if (row % 2 == 1 && col % 2 == 1)
                check = true;
            else if (row % 2 == 0 && col % 2 == 0)
                check = true;
            if (check) {
                EllipseRotated_F64 f = g.get(row, col);
                Point2D_F64 e = locations.get(index++);
                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 14 with EllipseRotated_F64

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

the class TestDetectCircleHexagonalGrid method putGridIntoCanonical_rotate.

public void putGridIntoCanonical_rotate(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.rotateGridCCW(g);
    alg.putGridIntoCanonical(g);
    assertTrue(original.get(0) == g.get(0, 0));
    checkCounterClockWise(g);
    alg.rotateGridCCW(g);
    alg.rotateGridCCW(g);
    alg.putGridIntoCanonical(g);
    assertTrue(original.get(0) == g.get(0, 0));
    checkCounterClockWise(g);
    alg.rotateGridCCW(g);
    alg.rotateGridCCW(g);
    alg.rotateGridCCW(g);
    alg.putGridIntoCanonical(g);
    assertTrue(original.get(0) == g.get(0, 0));
    checkCounterClockWise(g);
    alg.flipVertical(g);
    alg.putGridIntoCanonical(g);
    assertTrue(original.get(0) == g.get(0, 0));
    checkCounterClockWise(g);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid) ArrayList(java.util.ArrayList)

Example 15 with EllipseRotated_F64

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

the class TestDetectCircleHexagonalGrid method putGridIntoCanonical_horizontal.

private void putGridIntoCanonical_horizontal(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);
    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);
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Grid(boofcv.alg.fiducial.calib.circle.EllipseClustersIntoGrid.Grid) ArrayList(java.util.ArrayList)

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