Search in sources :

Example 16 with Polygon2D_F64

use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.

the class TestSquareGridTools method boundingPolygonCCW_row.

@Test
public void boundingPolygonCCW_row() {
    SquareGridTools alg = new SquareGridTools();
    SquareGrid grid = createGrid(1, 3);
    Polygon2D_F64 poly = new Polygon2D_F64(4);
    alg.boundingPolygonCCW(grid, poly);
    double w = TestSquareRegularClustersIntoGrids.DEFAULT_WIDTH;
    assertTrue(poly.get(0).distance(-w / 2, -w / 2) <= 1e-8);
    assertTrue(poly.get(1).distance(w * 4 + w / 2, -w / 2) <= 1e-8);
    assertTrue(poly.get(2).distance(w * 4 + w / 2, w / 2) <= 1e-8);
    assertTrue(poly.get(3).distance(-w / 2, w / 2) <= 1e-8);
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 17 with Polygon2D_F64

use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.

the class TestSquareNode method distanceSqCorner.

@Test
public void distanceSqCorner() {
    SquareNode a = new SquareNode();
    a.square = new Polygon2D_F64(4);
    a.square.get(0).set(-2, -2);
    a.square.get(1).set(2, -2);
    a.square.get(2).set(2, 2);
    a.square.get(3).set(-2, 2);
    assertEquals(0, a.distanceSqCorner(new Point2D_F64(-2, -2)), 1e-8);
    assertEquals(0, a.distanceSqCorner(new Point2D_F64(2, 2)), 1e-8);
    assertEquals(1, a.distanceSqCorner(new Point2D_F64(-3, 2)), 1e-8);
    assertEquals(4, a.distanceSqCorner(new Point2D_F64(-4, 2)), 1e-8);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 18 with Polygon2D_F64

use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.

the class TestSquareNode method getNumberOfConnections.

@Test
public void getNumberOfConnections() {
    SquareNode a = new SquareNode();
    a.square = new Polygon2D_F64(4);
    assertEquals(0, a.getNumberOfConnections());
    a.edges[2] = new SquareEdge();
    assertEquals(1, a.getNumberOfConnections());
    a.edges[0] = new SquareEdge();
    assertEquals(2, a.getNumberOfConnections());
    a.edges[3] = new SquareEdge();
    assertEquals(3, a.getNumberOfConnections());
    a.edges[1] = new SquareEdge();
    assertEquals(4, a.getNumberOfConnections());
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 19 with Polygon2D_F64

use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.

the class TestSquaresIntoCrossClusters method createSquare.

private DetectPolygonFromContour.Info createSquare(double x, double y) {
    DetectPolygonFromContour.Info info = new DetectPolygonFromContour.Info();
    info.reset();
    info.polygon = new Polygon2D_F64(4);
    info.polygon.get(0).set(x, y);
    info.polygon.get(1).set(x + 1, y);
    info.polygon.get(2).set(x + 1, y - 1);
    info.polygon.get(3).set(x, y - 1);
    return info;
}
Also used : DetectPolygonFromContour(boofcv.alg.shapes.polygon.DetectPolygonFromContour) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 20 with Polygon2D_F64

use of georegression.struct.shapes.Polygon2D_F64 in project BoofCV by lessthanoptimal.

the class TestSquaresIntoRegularClusters method disconnectSingleConnections.

@Test
public void disconnectSingleConnections() {
    SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(0.1, 6, 1.35);
    alg.nodes.resize(4);
    for (int i = 0; i < 4; i++) {
        alg.nodes.get(i).square = new Polygon2D_F64(4);
    }
    SquareNode a = alg.nodes.get(1);
    SquareNode b = alg.nodes.get(2);
    SquareNode c = alg.nodes.get(3);
    SquareNode d = alg.nodes.get(0);
    // these will all have two connections
    alg.graph.connect(a, 0, b, 0, 2);
    alg.graph.connect(a, 1, c, 1, 2);
    alg.graph.connect(b, 2, c, 2, 2);
    // just one connection
    alg.graph.connect(b, 3, d, 2, 2);
    alg.disconnectSingleConnections();
    for (int i = 1; i < 4; i++) {
        assertEquals(2, alg.nodes.get(i).getNumberOfConnections());
    }
    assertEquals(0, alg.nodes.get(0).getNumberOfConnections());
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Aggregations

Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)79 Test (org.junit.Test)40 Point2D_F64 (georegression.struct.point.Point2D_F64)13 ArrayList (java.util.ArrayList)9 GrayU8 (boofcv.struct.image.GrayU8)6 Rectangle2D_I32 (georegression.struct.shapes.Rectangle2D_I32)6 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)5 BufferedImage (java.awt.image.BufferedImage)5 GrowQueue_B (org.ddogleg.struct.GrowQueue_B)5 Point2D_I32 (georegression.struct.point.Point2D_I32)4 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)3 DetectPolygonFromContour (boofcv.alg.shapes.polygon.DetectPolygonFromContour)3 GrayF32 (boofcv.struct.image.GrayF32)3 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)3 Se3_F64 (georegression.struct.se.Se3_F64)3 Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)3 File (java.io.File)3 LensDistortionNarrowFOV (boofcv.alg.distort.LensDistortionNarrowFOV)2 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)2 SquareNode (boofcv.alg.fiducial.calib.squares.SquareNode)2