Search in sources :

Example 21 with Polygon2D_F64

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

the class TestSquaresIntoRegularClusters method computeNodeInfo.

@Test
public void computeNodeInfo() {
    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);
    assertEquals(2, alg.nodes.size());
    SquareNode a = alg.nodes.get(0);
    SquareNode b = alg.nodes.get(1);
    assertTrue(a.center.distance(new Point2D_F64(0, 0)) <= 1e-8);
    assertTrue(b.center.distance(new Point2D_F64(3, 0)) <= 1e-8);
    assertEquals(0, a.getNumberOfConnections());
    assertEquals(0, b.getNumberOfConnections());
    assertEquals(2, a.largestSide, 1e-8);
    assertEquals(2, b.largestSide, 1e-8);
    assertEquals(SquareNode.RESET_GRAPH, a.graph);
    assertEquals(SquareNode.RESET_GRAPH, b.graph);
    for (int i = 0; i < 4; i++) {
        assertEquals(2, a.sideLengths[i], 1e-8);
        assertEquals(2, b.sideLengths[i], 1e-8);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 22 with Polygon2D_F64

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

the class TestQrCodeDecoderImage method computeBoundingBox.

@Test
public void computeBoundingBox() {
    QrCode qr = new QrCode();
    qr.ppCorner = new Polygon2D_F64(0, 0, 1, 0, 1, 1, 0, 1);
    qr.ppRight = new Polygon2D_F64(2, 0, 3, 0, 3, 1, 2, 1);
    qr.ppDown = new Polygon2D_F64(0, 2, 1, 2, 1, 3, 0, 3);
    QrCodeDecoderImage.computeBoundingBox(qr);
    assertTrue(qr.bounds.get(0).distance(0, 0) < UtilEjml.TEST_F64);
    assertTrue(qr.bounds.get(1).distance(3, 0) < UtilEjml.TEST_F64);
    assertTrue(qr.bounds.get(2).distance(3, 3) < UtilEjml.TEST_F64);
    assertTrue(qr.bounds.get(3).distance(0, 3) < UtilEjml.TEST_F64);
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 23 with Polygon2D_F64

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

the class TestQrCodeDecoderImage method setPositionPatterns.

@Test
public void setPositionPatterns() {
    Polygon2D_F64 corner = new Polygon2D_F64(0, 0, 2, 0, 2, 2, 0, 2);
    Polygon2D_F64 right = new Polygon2D_F64(5, 0, 7, 0, 7, 2, 5, 2);
    Polygon2D_F64 bottom = new Polygon2D_F64(0, 5, 2, 5, 2, 7, 0, 7);
    PositionPatternNode n_corner = new PositionPatternNode();
    PositionPatternNode n_right = new PositionPatternNode();
    PositionPatternNode n_bottom = new PositionPatternNode();
    n_corner.square = corner;
    n_right.square = right;
    n_bottom.square = bottom;
    connect(n_right, n_corner, 3, 1);
    connect(n_bottom, n_corner, 0, 2);
    QrCode qr = new QrCode();
    QrCodeDecoderImage.setPositionPatterns(n_corner, 1, 2, qr);
    assertTrue(qr.ppCorner.get(0).distance(0, 0) < UtilEjml.TEST_F64);
    assertTrue(qr.ppRight.get(0).distance(5, 0) < UtilEjml.TEST_F64);
    assertTrue(qr.ppDown.get(0).distance(0, 5) < UtilEjml.TEST_F64);
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 24 with Polygon2D_F64

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

the class TestDetectPolygonFromContour method checkDetected.

private void checkDetected(Class imageType, double tol) {
    renderDistortedRectangles(true, imageType);
    int numberOfSides = 4;
    DetectPolygonFromContour alg = createDetector(imageType, numberOfSides, numberOfSides);
    alg.process(image, binary);
    FastQueue<DetectPolygonFromContour.Info> found = alg.getFound();
    assertEquals(rectangles.size(), found.size);
    for (int i = 0; i < found.size; i++) {
        Polygon2D_F64 p = found.get(i).polygon;
        assertEquals(1, findMatches(p, tol));
        assertEquals(black, found.get(i).edgeInside, 4);
        assertEquals(white, found.get(i).edgeOutside, white * 0.1);
    }
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 25 with Polygon2D_F64

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

the class TestDetectPolygonFromContour method rejectShapes_concave.

/**
 * Configure the detector to reject concave shapes
 */
@Test
public void rejectShapes_concave() {
    List<Polygon2D_F64> polygons = new ArrayList<>();
    polygons.add(new Polygon2D_F64(20, 20, 80, 20, 80, 80, 40, 40, 20, 80));
    for (Class imageType : imageTypes) {
        renderPolygons(polygons, imageType);
        DetectPolygonFromContour alg = createDetector(imageType, 5, 5);
        alg.process(image, binary);
        assertEquals(0, alg.getFound().size());
    }
}
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