Search in sources :

Example 61 with Polygon2D_F64

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

the class TestDetectPolygonFromContour method checkDetected_LensDistortion.

private void checkDetected_LensDistortion(Class imageType, double tol) {
    renderDistortedRectangles(true, imageType);
    Affine2D_F32 a = new Affine2D_F32();
    UtilAffine.convert(transform, a);
    PixelTransform2_F32 tranFrom = new PixelTransformAffine_F32(a);
    PixelTransform2_F32 tranTo = new PixelTransformAffine_F32(a.invert(null));
    int numberOfSides = 4;
    DetectPolygonFromContour alg = createDetector(imageType, numberOfSides, numberOfSides);
    alg.setLensDistortion(image.width, image.height, tranTo, tranFrom);
    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, findMatchesOriginal(p, tol));
        assertEquals(black, found.get(i).edgeInside, 3);
        assertEquals(white, found.get(i).edgeOutside, white * 0.05);
    }
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32)

Example 62 with Polygon2D_F64

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

the class TestDetectPolygonFromContour method checkDetectedMulti.

private void checkDetectedMulti(Class imageType, List<Polygon2D_F64> polygons, double tol) {
    renderPolygons(polygons, imageType);
    DetectPolygonFromContour alg = createDetector(imageType, 3, 4);
    alg.process(image, binary);
    FastQueue<DetectPolygonFromContour.Info> found = alg.getFound();
    assertEquals(polygons.size(), found.size);
    for (int i = 0; i < found.size; i++) {
        Polygon2D_F64 p = found.get(i).polygon;
        assertEquals(1, findMatches(p, tol));
    }
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 63 with Polygon2D_F64

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

the class TestDetectPolygonFromContour method detect_concave.

/**
 * Give it an easy to detect concave shape
 */
@Test
public void detect_concave() {
    List<Polygon2D_F64> polygons = new ArrayList<>();
    Polygon2D_F64 expected = new Polygon2D_F64(20, 20, 20, 80, 40, 40, 80, 80, 80, 20);
    polygons.add(expected);
    for (Class imageType : imageTypes) {
        renderPolygons(polygons, imageType);
        DetectPolygonFromContour alg = createDetector(imageType, 5, 5);
        alg.setConvex(false);
        alg.process(image, binary);
        assertEquals(1, alg.getFound().size());
        Polygon2D_F64 found = ((DetectPolygonFromContour.Info) alg.getFound().get(0)).polygon;
        assertEquals(1, findMatches(found, 3));
    }
}
Also used : ArrayList(java.util.ArrayList) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 64 with Polygon2D_F64

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

the class TestRefinePolygonToContour method reverseOrder.

@Test
public void reverseOrder() {
    RectangleLength2D_I32 rect = new RectangleLength2D_I32(0, 0, 10, 5);
    List<Point2D_I32> contour = rectToContour(rect);
    GrowQueue_I32 vertexes = computeContourVertexes(rect);
    flip(vertexes.data, vertexes.size);
    RefinePolygonToContour alg = new RefinePolygonToContour();
    Polygon2D_F64 found = new Polygon2D_F64();
    alg.process(contour, vertexes, found);
    assertTrue(checkPolygon(new double[] { 0, 0, 0, 4, 9, 4, 9, 0 }, found));
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 65 with Polygon2D_F64

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

the class TestRefinePolygonToContour method basic.

@Test
public void basic() {
    RectangleLength2D_I32 rect = new RectangleLength2D_I32(0, 0, 10, 5);
    List<Point2D_I32> contour = rectToContour(rect);
    GrowQueue_I32 vertexes = computeContourVertexes(rect);
    RefinePolygonToContour alg = new RefinePolygonToContour();
    Polygon2D_F64 found = new Polygon2D_F64();
    alg.process(contour, vertexes, found);
    assertTrue(checkPolygon(new double[] { 0, 0, 9, 0, 9, 4, 0, 4 }, found));
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) 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