Search in sources :

Example 26 with GrowQueue_I32

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

the class TestImageSegmentationOps method regionPixelId_to_Compact.

private void regionPixelId_to_Compact(GrayS32 graph, GrayS32 output) {
    GrayS32 input = new GrayS32(4, 5);
    input.data = new int[] { 2, 2, 2, 5, 5, 5, 5, 5, 2, 2, 2, 2, 15, 15, 15, 15, 15, 15, 15, 15 };
    // graph might be a sub-image
    for (int y = 0; y < graph.height; y++) {
        for (int x = 0; x < graph.width; x++) {
            graph.set(x, y, adjust(input.get(x, y), graph));
        }
    }
    GrowQueue_I32 rootNodes = new GrowQueue_I32();
    rootNodes.add(adjust(2, graph));
    rootNodes.add(adjust(5, graph));
    rootNodes.add(adjust(15, graph));
    ImageSegmentationOps.regionPixelId_to_Compact(graph, rootNodes, output);
    GrayS32 expected = new GrayS32(4, 5);
    expected.data = new int[] { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2 };
    BoofTesting.assertEquals(expected, output, 1e-4);
}
Also used : GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 27 with GrowQueue_I32

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

the class TestSegmentFelzenszwalbHuttenlocher04 method computeOutput.

@Test
public void computeOutput() {
    SegmentFelzenszwalbHuttenlocher04 alg = new SegmentFelzenszwalbHuttenlocher04(300, 20, null);
    alg.graph = new GrayS32(4, 5);
    alg.graph.data = new int[] { 2, 0, 2, 5, 3, 5, 4, 6, 2, 2, 2, 1, 15, 15, 15, 15, 15, 15, 15, 15 };
    for (int i = 0; i < alg.graph.data.length; i++) alg.regionSize.add(i + 1);
    alg.computeOutput();
    GrowQueue_I32 regionId = alg.getRegionId();
    assertEquals(3, regionId.size);
    assertEquals(2, regionId.get(0));
    assertEquals(5, regionId.get(1));
    assertEquals(15, regionId.get(2));
    GrowQueue_I32 outputRegionSize = alg.getRegionSizes();
    assertEquals(3, outputRegionSize.size);
    assertEquals(3, outputRegionSize.get(0));
    assertEquals(6, outputRegionSize.get(1));
    assertEquals(16, outputRegionSize.get(2));
    GrayS32 expected = new GrayS32(4, 5);
    expected.data = new int[] { 2, 2, 2, 5, 5, 5, 5, 5, 2, 2, 2, 2, 15, 15, 15, 15, 15, 15, 15, 15 };
    BoofTesting.assertEquals(expected, alg.graph, 1e-4);
}
Also used : GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 28 with GrowQueue_I32

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

the class TestAssociateSurfBasic method basicAssociation.

@Test
public void basicAssociation() {
    FastQueue<BrightFeature> src = new FastQueue<>(10, BrightFeature.class, false);
    FastQueue<BrightFeature> dst = new FastQueue<>(10, BrightFeature.class, false);
    // create a list where some should be matched and others not
    src.add(createDesc(true, 10));
    src.add(createDesc(true, 12));
    src.add(createDesc(false, 5));
    src.add(createDesc(false, 2344));
    src.add(createDesc(false, 1000));
    dst.add(createDesc(true, 0));
    dst.add(createDesc(true, 10.1));
    dst.add(createDesc(true, 13));
    dst.add(createDesc(false, 0.1));
    dst.add(createDesc(false, 7));
    alg.setSrc(src);
    alg.setDst(dst);
    alg.associate();
    FastQueue<AssociatedIndex> matches = alg.getMatches();
    assertEquals(3, matches.size());
    assertTrue(matches.get(0).fitScore != 0);
    assertEquals(0, matches.get(0).src);
    assertEquals(1, matches.get(0).dst);
    assertTrue(matches.get(1).fitScore != 0);
    assertEquals(1, matches.get(1).src);
    assertEquals(2, matches.get(1).dst);
    assertTrue(matches.get(2).fitScore != 0);
    assertEquals(2, matches.get(2).src);
    assertEquals(4, matches.get(2).dst);
    // see if the expected number of features are in the unassociated list
    GrowQueue_I32 unassoc = alg.unassociatedSrc;
    assertEquals(2, unassoc.size);
    // make sure none of the unassociated are contained in the associated list
    for (int i = 0; i < unassoc.size; i++) {
        int index = unassoc.data[i];
        for (int j = 0; j < matches.size(); j++) {
            if (matches.get(j).src == index)
                fail("match found");
        }
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) FastQueue(org.ddogleg.struct.FastQueue) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 29 with GrowQueue_I32

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

the class ChecksGenericPointsToPolyline method checkMinVertexes_sequence.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
public void checkMinVertexes_sequence() {
    PointsToPolyline alg = createAlg(false);
    alg.setConvex(false);
    alg.setMinimumSides(10);
    List<Point2D_I32> contour = line(0, 0, 30, 0);
    contour.addAll(line(30, 0, 30, 10));
    contour.addAll(line(30, 10, 20, 10));
    contour.addAll(line(20, 10, 20, 30));
    contour.addAll(line(20, 30, 0, 30));
    GrowQueue_I32 found = new GrowQueue_I32();
    if (alg.process(contour, found)) {
        assertEquals(9, found.size);
    }
    alg.setMinimumSides(3);
    assertTrue(alg.process(contour, found));
    check(found, 0, 30, 40, 50, 70, 89);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 30 with GrowQueue_I32

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

the class ChecksGenericPointsToPolyline method checkMinVertexes_loop.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
public void checkMinVertexes_loop() {
    PointsToPolyline alg = createAlg(true);
    alg.setConvex(false);
    alg.setMinimumSides(10);
    List<Point2D_I32> contour = line(0, 0, 30, 0);
    contour.addAll(line(30, 0, 30, 10));
    contour.addAll(line(30, 10, 20, 10));
    contour.addAll(line(20, 10, 20, 30));
    contour.addAll(line(20, 30, 0, 30));
    contour.addAll(line(0, 30, 0, 0));
    GrowQueue_I32 found = new GrowQueue_I32();
    if (alg.process(contour, found)) {
        assertEquals(10, found.size);
    }
    alg.setMinimumSides(3);
    assertTrue(alg.process(contour, found));
    check(found, 0, 30, 40, 50, 70, 90);
}
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