Search in sources :

Example 51 with Polygon2D_F64

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

the class TestSquaresIntoCrossClusters method getCornerIndex.

@Test
public void getCornerIndex() {
    SquareNode node = new SquareNode();
    node.square = new Polygon2D_F64(4);
    node.square.get(0).set(5, 6);
    node.square.get(1).set(6, 7);
    node.square.get(2).set(7, 8);
    node.square.get(3).set(8, 9);
    SquaresIntoCrossClusters alg = new SquaresIntoCrossClusters(5, -1);
    assertEquals(0, alg.getCornerIndex(node, 5, 6));
    assertEquals(1, alg.getCornerIndex(node, 6, 7));
    assertEquals(2, alg.getCornerIndex(node, 7, 8));
    assertEquals(3, alg.getCornerIndex(node, 8, 9));
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 52 with Polygon2D_F64

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

the class TestSquaresIntoRegularClusters method createSquare.

private Polygon2D_F64 createSquare(double x, double y, double yaw, double width) {
    Se2_F64 motion = new Se2_F64(x, y, yaw);
    double r = width / 2;
    Polygon2D_F64 poly = new Polygon2D_F64(4);
    poly.get(0).set(-r, r);
    poly.get(1).set(r, r);
    poly.get(2).set(r, -r);
    poly.get(3).set(-r, -r);
    for (int i = 0; i < 4; i++) {
        SePointOps_F64.transform(motion, poly.get(i), poly.get(i));
    }
    return poly;
}
Also used : Se2_F64(georegression.struct.se.Se2_F64) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 53 with Polygon2D_F64

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

the class TestSquaresIntoRegularClusters method considerConnect_shape_offset.

/**
 * Everything is good, but they are offset from each other by too much
 */
@Test
public void considerConnect_shape_offset() {
    List<Polygon2D_F64> squares = new ArrayList<>();
    squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
    squares.add(new Polygon2D_F64(3, 2, 5, 1, 5, -1, 3, -2));
    SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
    alg.computeNodeInfo(squares);
    SquareNode a = alg.nodes.get(0);
    SquareNode b = alg.nodes.get(1);
    alg.considerConnect(a, b);
    assertNotConnected(a, b);
}
Also used : ArrayList(java.util.ArrayList) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 54 with Polygon2D_F64

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

the class TestSquaresIntoRegularClusters method considerConnect_nominal.

/**
 * The usual case.  They should attach
 */
@Test
public void considerConnect_nominal() {
    List<Polygon2D_F64> squares = new ArrayList<>();
    squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
    squares.add(new Polygon2D_F64(2, 1, 4, 1, 4, -1, 2, -1));
    SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
    alg.computeNodeInfo(squares);
    SquareNode a = alg.nodes.get(0);
    SquareNode b = alg.nodes.get(1);
    alg.considerConnect(a, b);
    // distance is the space between the sides
    assertConnected(a, 1, b, 3, 1);
}
Also used : ArrayList(java.util.ArrayList) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 55 with Polygon2D_F64

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

the class TestSquaresIntoRegularClusters method considerConnect_shape_size.

/**
 * Every thing's good, but the size difference of the squares is too much
 */
@Test
public void considerConnect_shape_size() {
    List<Polygon2D_F64> squares = new ArrayList<>();
    squares.add(new Polygon2D_F64(-1, 1, 1, 1, 1, -1, -1, -1));
    squares.add(new Polygon2D_F64(2, 4, 10, 4, 10, -4, 2, -4));
    SquaresIntoRegularClusters alg = new SquaresIntoRegularClusters(2, 6, 1.35);
    alg.computeNodeInfo(squares);
    SquareNode a = alg.nodes.get(0);
    SquareNode b = alg.nodes.get(1);
    alg.considerConnect(a, b);
    assertNotConnected(a, b);
}
Also used : ArrayList(java.util.ArrayList) 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