Search in sources :

Example 16 with EllipseRotated_F64

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

the class TestDetectCircleHexagonalGrid method putGridIntoCanonical_vertical.

private void putGridIntoCanonical_vertical(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.putGridIntoCanonical(TestDetectCircleGrid.flipVertical(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)

Example 17 with EllipseRotated_F64

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

the class TestDetectCircleRegularGrid method checkCounterClockWise.

static void checkCounterClockWise(Grid g) {
    EllipseRotated_F64 a = g.get(0, 0);
    EllipseRotated_F64 b = g.get(0, 1);
    EllipseRotated_F64 c = g.get(1, 0);
    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 18 with EllipseRotated_F64

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

the class TestDetectCircleRegularGrid method putGridIntoCanonical_flip.

private void putGridIntoCanonical_flip(int numRows, int numCols) {
    DetectCircleRegularGrid<?> alg = new DetectCircleRegularGrid(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);
    g = TestDetectCircleGrid.flipVertical(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)

Example 19 with EllipseRotated_F64

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

the class TestEllipseClustersIntoGrid method computeNodeInfo.

/**
 * This test just checks to see if a node info is created for each node passed in and that
 * the ellipse is assinged to it.  The inner functions are tested elsewhere
 */
@Test
public void computeNodeInfo() {
    List<Node> nodes = new ArrayList<>();
    nodes.add(createNode(0, 1, 2, 3));
    nodes.add(createNode(1, 0, 2, 4));
    nodes.add(createNode(2, 0, 1));
    nodes.add(createNode(3, 0));
    nodes.add(createNode(4));
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    for (int i = 0; i < nodes.size(); i++) {
        ellipses.add(new EllipseRotated_F64());
    }
    EllipseClustersIntoGrid alg = new HelperAlg();
    alg.computeNodeInfo(ellipses, nodes);
    assertEquals(nodes.size(), alg.listInfo.size);
    for (int i = 0; i < nodes.size(); i++) {
        assertTrue(ellipses.get(i) == alg.listInfo.get(i).ellipse);
    }
}
Also used : EllipseRotated_F64(georegression.struct.curve.EllipseRotated_F64) Node(boofcv.alg.fiducial.calib.circle.EllipsesIntoClusters.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with EllipseRotated_F64

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

the class TestEllipseClustersIntoHexagonalGrid method bottomTwoColumns_case0.

/**
 * There's a longer row to add
 */
@Test
public void bottomTwoColumns_case0() {
    List<EllipseRotated_F64> ellipses = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        ellipses.add(new EllipseRotated_F64(i, 0, 1, 1, 0));
        ellipses.add(new EllipseRotated_F64(i + 0.5, hexY, 1, 1, 0));
        ellipses.add(new EllipseRotated_F64(i, hexY * 2, 1, 1, 0));
    }
    Tuple2<List<Node>, List<EllipseRotated_F64>> input = connectEllipses(ellipses, hexY * 2.1);
    EllipseClustersIntoHexagonalGrid alg = new EllipseClustersIntoHexagonalGrid();
    alg.computeNodeInfo(input.data1, input.data0);
    alg.findContour(true);
    List<NodeInfo> column0 = new ArrayList<>();
    List<NodeInfo> column1 = new ArrayList<>();
    // first two on top row
    NodeInfo corner = alg.listInfo.get(2);
    NodeInfo next = alg.listInfo.get(5);
    corner.marked = next.marked = true;
    alg.bottomTwoColumns(corner, next, column0, column1);
    assertEquals(3, column0.size());
    assertEquals(3, column1.size());
    for (int i = 0; i < 3; i++) {
        assertTrue(column0.get(i).ellipse.center.distance(i, hexY * 2) < 1e-4);
        assertTrue(column1.get(i).ellipse.center.distance(i + 0.5, hexY) < 1e-4);
        assertTrue(column0.get(i).marked);
        assertTrue(column1.get(i).marked);
    }
}
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)

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