Search in sources :

Example 6 with Polygon2D_F64

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

the class TestDetectChessboardSquarePoints method adjustBeforeOptimize_touchesBorder.

@Test
public void adjustBeforeOptimize_touchesBorder() {
    DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(2, 2, ConfigLength.fixed(0.01), null);
    GrowQueue_B touches = new GrowQueue_B();
    touches.add(true);
    touches.add(true);
    touches.add(false);
    touches.add(true);
    for (boolean clockwise : new boolean[] { true, false }) {
        Polygon2D_F64 polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
        if (clockwise)
            polygon.flip();
        alg.adjustBeforeOptimize(polygon, touches, clockwise);
        int[] table = clockwise ? new int[] { 0, 3, 2, 1 } : new int[] { 0, 1, 2, 3 };
        assertEquals(10, polygon.get(table[0]).x, UtilEjml.TEST_F64);
        assertEquals(12, polygon.get(table[0]).y, UtilEjml.TEST_F64);
        assertEquals(31.5, polygon.get(table[1]).x, UtilEjml.TEST_F64);
        assertEquals(12, polygon.get(table[1]).y, UtilEjml.TEST_F64);
        assertEquals(31.5, polygon.get(table[2]).x, UtilEjml.TEST_F64);
        assertEquals(41.5, polygon.get(table[2]).y, UtilEjml.TEST_F64);
        assertEquals(10, polygon.get(table[3]).x, UtilEjml.TEST_F64);
        assertEquals(41.5, polygon.get(table[3]).y, UtilEjml.TEST_F64);
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrowQueue_B(org.ddogleg.struct.GrowQueue_B) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 7 with Polygon2D_F64

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

the class TestDetectChessboardSquarePoints method adjustBeforeOptimize.

@Test
public void adjustBeforeOptimize() {
    DetectChessboardSquarePoints<GrayU8> alg = new DetectChessboardSquarePoints<>(2, 2, ConfigLength.fixed(0.01), null);
    Polygon2D_F64 polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
    alg.adjustBeforeOptimize(polygon, new GrowQueue_B(), false);
    assertEquals(8.5, polygon.get(0).x, UtilEjml.TEST_F64);
    assertEquals(10.5, polygon.get(0).y, UtilEjml.TEST_F64);
    assertEquals(31.5, polygon.get(1).x, UtilEjml.TEST_F64);
    assertEquals(10.5, polygon.get(1).y, UtilEjml.TEST_F64);
    assertEquals(31.5, polygon.get(2).x, UtilEjml.TEST_F64);
    assertEquals(41.5, polygon.get(2).y, UtilEjml.TEST_F64);
    assertEquals(8.5, polygon.get(3).x, UtilEjml.TEST_F64);
    assertEquals(41.5, polygon.get(3).y, UtilEjml.TEST_F64);
    polygon = new Polygon2D_F64(10, 12, 30, 12, 30, 40, 10, 40);
    polygon.flip();
    alg.adjustBeforeOptimize(polygon, new GrowQueue_B(), true);
    assertEquals(8.5, polygon.get(0).x, UtilEjml.TEST_F64);
    assertEquals(10.5, polygon.get(0).y, UtilEjml.TEST_F64);
    assertEquals(31.5, polygon.get(3).x, UtilEjml.TEST_F64);
    assertEquals(10.5, polygon.get(3).y, UtilEjml.TEST_F64);
    assertEquals(31.5, polygon.get(2).x, UtilEjml.TEST_F64);
    assertEquals(41.5, polygon.get(2).y, UtilEjml.TEST_F64);
    assertEquals(8.5, polygon.get(1).x, UtilEjml.TEST_F64);
    assertEquals(41.5, polygon.get(1).y, UtilEjml.TEST_F64);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) GrowQueue_B(org.ddogleg.struct.GrowQueue_B) Test(org.junit.Test)

Example 8 with Polygon2D_F64

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

the class TestQrCodePositionPatternDetector method squareNode.

public static SquareNode squareNode(int x0, int y0, int width) {
    Polygon2D_F64 square = square(x0, y0, width);
    SquareNode node = new SquareNode();
    node.square = square;
    node.largestSide = width;
    node.smallestSide = width;
    node.center.set(x0 + width / 2, y0 + width / 2);
    for (int i = 0; i < 4; i++) {
        node.sideLengths[i] = width;
    }
    return node;
}
Also used : SquareNode(boofcv.alg.fiducial.calib.squares.SquareNode) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 9 with Polygon2D_F64

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

the class TestQrCodePositionPatternDetector method square.

public static Polygon2D_F64 square(int x0, int y0, int width) {
    Polygon2D_F64 square = new Polygon2D_F64(4);
    square.get(0).set(x0, y0);
    square.get(1).set(x0 + width, y0);
    square.get(2).set(x0 + width, y0 + width);
    square.get(3).set(x0, y0 + width);
    return square;
}
Also used : Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 10 with Polygon2D_F64

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

the class TestSquareCrossClustersIntoGrids method createCluster.

/**
 * Creates a new two row graph.  Skip indicates if the first row skips the first column or not.  The
 * other two parameters specify how many nodes in each row
 */
private List<SquareNode> createCluster(boolean skip, int... levels) {
    int total = 0;
    for (int i = 0; i < levels.length; i++) {
        total += levels[i];
    }
    List<SquareNode> out = new ArrayList<>();
    for (int i = 0; i < total; i++) {
        out.add(new SquareNode());
        out.get(i).graph = SquareNode.RESET_GRAPH;
        out.get(i).square = new Polygon2D_F64(4);
    }
    int previous = 0;
    for (int i = 0; i < levels.length - 1; i++) {
        int current = previous + levels[i];
        int next = current + levels[i + 1];
        for (int a = 0; a < levels[i]; a++) {
            SquareNode n = out.get(previous + a);
            int right = skip ? current + a + 1 : current + a;
            int left = right - 1;
            if (right < next)
                connect(n, 2, out.get(right), 0);
            if (left >= current) {
                connect(n, 3, out.get(left), 1);
            }
        }
        previous = current;
        skip = !skip;
    }
    return out;
}
Also used : ArrayList(java.util.ArrayList) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

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