Search in sources :

Example 41 with Polygon2D_F64

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

the class AssistedCalibration method captureFiducialPoints.

/**
 * Record the area covered in the image by the fiducial, update the quality calculation, and see if it should
 * enable the save button.
 */
private void captureFiducialPoints() {
    Polygon2D_F64 p = regions.grow();
    p.vertexes.resize(sidesCollision.size());
    for (int i = 0; i < sidesCollision.size(); i++) {
        p.get(i).set(sidesCollision.get(i));
    }
    quality.addObservations(detector.getDetectedPoints());
    gui.getInfoPanel().updateGeometry(quality.getScore());
    // once the user has sufficient geometric variation enable save
    geometryTrigger |= quality.getScore() >= 1.0;
    if (geometryTrigger && magnets.isEmpty()) {
        gui.getInfoPanel().enabledFinishedButton();
    }
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 42 with Polygon2D_F64

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

the class TestQrCodePositionPatternDetector method checkPositionPatternAppearance.

@Test
public void checkPositionPatternAppearance() {
    GrayF32 image = render(null, new PP(40, 60, 70));
    QrCodePositionPatternDetector<GrayF32> alg = createAlg();
    Polygon2D_F64 square = square(40, 60, 70);
    alg.interpolate.setImage(image);
    assertTrue(alg.checkPositionPatternAppearance(square, 100));
    // fill in the inner "stone"
    ImageMiscOps.fillRectangle(image, 0, 40, 60, 70, 70);
    assertFalse(alg.checkPositionPatternAppearance(square, 100));
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 43 with Polygon2D_F64

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

the class TestDetectChessboardSquarePoints method createSquare.

public static SquareNode createSquare(double x, double y, double width) {
    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);
    SquareNode square = new SquareNode();
    for (int i = 0; i < 4; i++) {
        poly.get(i).x += x;
        poly.get(i).y += y;
    }
    square.square = poly;
    square.center.set(x, y);
    square.largestSide = width;
    return square;
}
Also used : SquareNode(boofcv.alg.fiducial.calib.squares.SquareNode) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 44 with Polygon2D_F64

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

the class GenericFiducialDetectorChecks method checkBounds.

public void checkBounds(FiducialDetector detector) {
    if (!supportsBounds)
        return;
    Polygon2D_F64 queue = new Polygon2D_F64();
    for (int i = 0; i < detector.totalFound(); i++) {
        // make sure it handles null correctly
        Polygon2D_F64 listA = detector.getBounds(i, null);
        Polygon2D_F64 listB = detector.getBounds(i, queue);
        assertTrue(listB == queue);
        assertEquals(listA.size(), listB.size());
        Polygon2D_F64 polygon = new Polygon2D_F64(listA.size());
        for (int j = 0; j < listA.size(); j++) {
            Point2D_F64 pa = listA.get(j);
            Point2D_F64 pb = listB.get(j);
            assertTrue(pa.x == pb.x);
            assertTrue(pa.y == pb.y);
            // very simple sanity check on the results
            assertFalse(UtilEjml.isUncountable(pa.x));
            assertFalse(UtilEjml.isUncountable(pa.y));
            polygon.get(j).set(pa);
        }
        // in almost all cases the center should be inside
        Point2D_F64 center = new Point2D_F64();
        detector.getCenter(i, center);
        Intersection2D_F64.containConvex(polygon, center);
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 45 with Polygon2D_F64

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

the class TestSquareCrossClustersIntoGrids method numberOfOpenEdges.

@Test
public void numberOfOpenEdges() {
    SquareNode a = new SquareNode();
    a.square = new Polygon2D_F64(4);
    assertEquals(0, SquareCrossClustersIntoGrids.numberOfOpenEdges(a));
    connect(a, 1, new SquareNode(), 0);
    assertEquals(0, SquareCrossClustersIntoGrids.numberOfOpenEdges(a));
    a.edges[1].b.graph = SquareNode.RESET_GRAPH;
    assertEquals(1, SquareCrossClustersIntoGrids.numberOfOpenEdges(a));
}
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