Search in sources :

Example 81 with Point2D_I32

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

the class HysteresisEdgeTracePoints method addFirstSegment.

/**
 * Starts a new segment at the first point in the contour
 */
private void addFirstSegment(int x, int y) {
    Point2D_I32 p = queuePoints.grow();
    p.set(x, y);
    EdgeSegment s = new EdgeSegment();
    s.points.add(p);
    s.index = 0;
    s.parent = s.parentPixel = -1;
    e.segments.add(s);
    open.add(s);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 82 with Point2D_I32

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

the class HysteresisEdgeTracePoints method check.

/**
 * Checks to see if the given coordinate is above the lower threshold.  If it is the point will be
 * added to the current segment or be the start of a new segment.
 *
 * @param parent The edge segment which is being checked
 * @param match Has a match to the current segment already been found?
 * @return true if a match was found at this point
 */
private boolean check(int x, int y, EdgeSegment parent, boolean match) {
    if (intensity.isInBounds(x, y)) {
        int index = intensity.getIndex(x, y);
        if (intensity.data[index] >= lower) {
            intensity.data[index] = MARK_TRAVERSED;
            if (!match) {
                Point2D_I32 p = queuePoints.grow();
                p.set(x, y);
                parent.points.add(p);
            } else {
                // a match was found so it can't just be added to the current edge
                startNewSegment(x, y, parent);
            }
            return true;
        }
    }
    return false;
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 83 with Point2D_I32

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

the class TestDescribePointBriefSO method testManualCheck.

/**
 * Compute the BRIEF descriptor manually and see if it gets the same answer
 */
@Test
public void testManualCheck() {
    GrayF32 input = createImage(width, height);
    GrayF32 blurred = input.createNew(width, height);
    filterBlur.process(input, blurred);
    GImageGray a = FactoryGImageGray.wrap(blurred);
    DescribePointBriefSO<GrayF32> alg = createAlg();
    alg.setImage(input);
    int c_x = input.width / 2;
    int c_y = input.height / 2;
    TupleDesc_B desc = alg.createFeature();
    alg.process(c_x, c_y, 0, briefRadius, desc);
    double s = briefRadius / BoofDefaults.BRIEF_SCALE_TO_RADIUS;
    for (int i = 0; i < def.compare.length; i++) {
        Point2D_I32 c = def.compare[i];
        Point2D_I32 p0 = def.samplePoints[c.x];
        Point2D_I32 p1 = def.samplePoints[c.y];
        boolean expected = a.get((int) Math.round(c_x + p0.x * s), (int) Math.round(c_y + p0.y * s)).doubleValue() < a.get((int) Math.round(c_x + p1.x * s), (int) Math.round(c_y + p1.y * s)).doubleValue();
        assertTrue(expected == desc.isBitTrue(i));
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) GrayF32(boofcv.struct.image.GrayF32) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 84 with Point2D_I32

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

the class TestDescribeDenseHogFastAlg method computeDescriptor.

@Test
public void computeDescriptor() {
    DescribeDenseHogFastAlg<GrayF32> helper = new DescribeDenseHogFastAlg<>(10, 8, 2, 2, 1, imageType);
    helper.growCellArray(imgWidth, imgHeight);
    int stride = helper.cellCols;
    // manually build a simple histogram for input and manually construct the expected resulting descriptor
    TupleDesc_F64 expected = new TupleDesc_F64(40);
    setHistogram(helper.cells[2].histogram, 2, 3, expected.value, 0);
    setHistogram(helper.cells[3].histogram, 2, 3, expected.value, 10);
    setHistogram(helper.cells[stride + 2].histogram, 5, 0, expected.value, 20);
    setHistogram(helper.cells[stride + 3].histogram, 7, 8, expected.value, 30);
    DescribeSiftCommon.normalizeDescriptor(expected, 0.2);
    helper.computeDescriptor(0, 2);
    Point2D_I32 where = helper.locations.get(0);
    TupleDesc_F64 found = helper.descriptions.get(0);
    assertEquals(8 * 2, where.x);
    assertEquals(0, where.y);
    assertEquals(40, found.size());
    assertTrue(DescriptorDistance.euclidean(expected, found) < 1e-8);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 85 with Point2D_I32

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

the class BaseTestDescribePointBinaryCompare method testManualCheck.

/**
 * Compute the descriptor manually and see if it gets the same answer
 */
@Test
public void testManualCheck() {
    T input = createImage(width, height);
    GImageGray a = FactoryGImageGray.wrap(input);
    DescribePointBinaryCompare<T> alg = createAlg(def);
    alg.setImage(input);
    int c_x = input.width / 2;
    int c_y = input.height / 2;
    TupleDesc_B desc = createFeature();
    alg.process(c_x, c_y, desc);
    for (int i = 0; i < def.compare.length; i++) {
        Point2D_I32 c = def.compare[i];
        Point2D_I32 p0 = def.samplePoints[c.x];
        Point2D_I32 p1 = def.samplePoints[c.y];
        boolean expected = a.get(c_x + p0.x, c_y + p0.y).doubleValue() < a.get(c_x + p1.x, c_y + p1.y).doubleValue();
        assertTrue(expected == desc.isBitTrue(def.compare.length - i - 1));
    }
}
Also used : TupleDesc_B(boofcv.struct.feature.TupleDesc_B) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) Point2D_I32(georegression.struct.point.Point2D_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