Search in sources :

Example 71 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestCannyEdge method checkNeighbor.

private void checkNeighbor(List<Point2D_I32> list) {
    for (int i = 1; i < list.size(); i++) {
        Point2D_I32 a = list.get(i - 1);
        Point2D_I32 b = list.get(i);
        int dx = Math.abs(a.x - b.x);
        int dy = Math.abs(a.y - b.y);
        assertTrue(dx <= 1 && dy <= 1);
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 72 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestDescribeDenseSiftAlg method computeDescriptor.

/**
 * Compute to the general descriptor algorithm.  They should produce the same results
 */
@Test
public void computeDescriptor() {
    GrayF32 derivX = new GrayF32(100, 102);
    GrayF32 derivY = new GrayF32(100, 102);
    GImageMiscOps.fillUniform(derivX, rand, 0, 200);
    GImageMiscOps.fillUniform(derivY, rand, 0, 200);
    DescribeDenseSiftAlg<GrayF32> alg = new DescribeDenseSiftAlg<>(4, 4, 8, 0.5, 0.2, 10, 10, GrayF32.class);
    DescribePointSift<GrayF32> algTest = new DescribePointSift<>(4, 4, 8, 1, 0.5, 0.2, GrayF32.class);
    alg.setImageGradient(derivX, derivY);
    algTest.setImageGradient(derivX, derivY);
    List<Point2D_I32> samplePoints = new ArrayList<>();
    samplePoints.add(new Point2D_I32(30, 35));
    samplePoints.add(new Point2D_I32(45, 10));
    samplePoints.add(new Point2D_I32(60, 12));
    samplePoints.add(new Point2D_I32(50, 50));
    TupleDesc_F64 found = new TupleDesc_F64(128);
    TupleDesc_F64 expected = new TupleDesc_F64(128);
    for (Point2D_I32 p : samplePoints) {
        alg.computeDescriptor(p.x, p.y, found);
        algTest.process(p.x, p.y, 1, 0, expected);
        for (int i = 0; i < 128; i++) {
            assertEquals(expected.value[i], found.value[i], 1e-8);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DescribePointSift(boofcv.alg.feature.describe.DescribePointSift) ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 73 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestDescribePointSift method process.

/**
 * Tests to see if it blows up and not much more.  Random image.  Compute descriptor along border and image
 * center.
 */
@Test
public void process() {
    GrayF32 derivX = new GrayF32(200, 200);
    GrayF32 derivY = new GrayF32(200, 200);
    GImageMiscOps.fillUniform(derivX, rand, -100, 100);
    GImageMiscOps.fillUniform(derivY, rand, -100, 100);
    DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
    alg.setImageGradient(derivX, derivY);
    List<Point2D_I32> testPoints = new ArrayList<>();
    testPoints.add(new Point2D_I32(100, 0));
    testPoints.add(new Point2D_I32(100, 199));
    testPoints.add(new Point2D_I32(0, 100));
    testPoints.add(new Point2D_I32(199, 100));
    testPoints.add(new Point2D_I32(100, 100));
    TupleDesc_F64 desc = new TupleDesc_F64(alg.getDescriptorLength());
    for (Point2D_I32 where : testPoints) {
        alg.process(where.x, where.y, 2, 0.5, desc);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 74 with Point2D_I32

use of georegression.struct.point.Point2D_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 75 with Point2D_I32

use of georegression.struct.point.Point2D_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

Point2D_I32 (georegression.struct.point.Point2D_I32)153 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)41 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)21 Point2D_F64 (georegression.struct.point.Point2D_F64)11 EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)8 GrayF32 (boofcv.struct.image.GrayF32)8 GrayS32 (boofcv.struct.image.GrayS32)7 Contour (boofcv.alg.filter.binary.Contour)6 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)6 GrayU8 (boofcv.struct.image.GrayU8)6 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)5 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)5 UtilPoint2D_I32 (georegression.geometry.UtilPoint2D_I32)4 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)4 EdgeSegment (boofcv.alg.feature.detect.edge.EdgeSegment)3 Corner (boofcv.alg.shapes.polyline.splitmerge.PolylineSplitMerge.Corner)3 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)3 PointIndex_I32 (boofcv.struct.PointIndex_I32)3 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)3