Search in sources :

Example 41 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestFitLinesToContour method fitAnchored_perfect_input.

/**
 * Easy case were the corners are all in perfect location.  Try all permutations of first anchor and second anchor.
 */
@Test
public void fitAnchored_perfect_input() {
    FitLinesToContour alg = new FitLinesToContour();
    alg.setContour(createSquare(10, 12, 30, 40));
    GrowQueue_I32 corners = createSquareCorners(10, 12, 30, 40);
    GrowQueue_I32 found = new GrowQueue_I32();
    for (int anchor0 = 0; anchor0 < 4; anchor0++) {
        for (int j = 0; j < 4; j++) {
            // this case it can't optimize
            if (j == 1)
                continue;
            int anchor1 = (anchor0 + j) % 4;
            alg.fitAnchored(anchor0, anchor1, corners, found);
            assertEquals(4, found.size());
            for (int i = 0; i < found.size(); i++) {
                assertEquals(corners.get(i), found.get(i));
            }
        }
    }
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 42 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestFitLinesToContour method createSquareCorners.

private GrowQueue_I32 createSquareCorners(int x0, int y0, int x1, int y1) {
    GrowQueue_I32 corners = new GrowQueue_I32();
    int c0 = 0;
    int c1 = c0 + x1 - x0;
    int c2 = c1 + y1 - y0;
    int c3 = c2 + x1 - x0;
    corners.add(c0);
    corners.add(c1);
    corners.add(c2);
    corners.add(c3);
    return corners;
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 43 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestFitLinesToContour method fitAnchored_easy_optimization.

/**
 * Have only one corner off by a few pixels with extremely clean input data
 */
@Test
public void fitAnchored_easy_optimization() {
    FitLinesToContour alg = new FitLinesToContour();
    alg.setContour(createSquare(10, 12, 30, 40));
    GrowQueue_I32 expected = createSquareCorners(10, 12, 30, 40);
    GrowQueue_I32 input = createSquareCorners(10, 12, 30, 40);
    GrowQueue_I32 found = new GrowQueue_I32();
    input.set(2, input.get(2) + 3);
    alg.fitAnchored(1, 3, input, found);
    for (int i = 0; i < found.size(); i++) {
        assertEquals(expected.get(i), found.get(i));
    }
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 44 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestMinimizeEnergyPrune method prine_no_change.

/**
 * Perfect case.  See if it does nothing
 */
@Test
public void prine_no_change() {
    List<Point2D_I32> contours = createSquare(10, 12, 20, 30);
    GrowQueue_I32 corners = createSquareCorners(10, 12, 20, 30);
    MinimizeEnergyPrune alg = new MinimizeEnergyPrune(1);
    GrowQueue_I32 output = new GrowQueue_I32();
    alg.prune(contours, corners, output);
    assertEquals(corners.size(), output.size());
    for (int i = 0; i < corners.size(); i++) {
        assertEquals(corners.get(i), output.get(i));
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 45 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestMinimizeEnergyPrune method removeDuplicates.

@Test
public void removeDuplicates() {
    List<Point2D_I32> contours = createSquare(10, 12, 20, 30);
    GrowQueue_I32 corners = createSquareCorners(10, 12, 20, 30);
    corners.add(corners.get(0));
    corners.add(corners.get(2));
    MinimizeEnergyPrune alg = new MinimizeEnergyPrune(4);
    alg.contour = contours;
    alg.removeDuplicates(corners);
    checkMatched(createSquareCorners(10, 12, 20, 30), corners);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Aggregations

GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)60 Test (org.junit.Test)35 Point2D_I32 (georegression.struct.point.Point2D_I32)21 GrayS32 (boofcv.struct.image.GrayS32)10 ArrayList (java.util.ArrayList)7 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)6 Point2D_F64 (georegression.struct.point.Point2D_F64)5 FastQueue (org.ddogleg.struct.FastQueue)5 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)3 ColorQueue_F32 (boofcv.struct.feature.ColorQueue_F32)3 GrayF32 (boofcv.struct.image.GrayF32)3 GrowQueue_I8 (org.ddogleg.struct.GrowQueue_I8)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 BrightFeature (boofcv.struct.feature.BrightFeature)2 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)2 BufferedImage (java.awt.image.BufferedImage)2