Search in sources :

Example 6 with RectangleRotate_F32

use of boofcv.struct.RectangleRotate_F32 in project BoofCV by lessthanoptimal.

the class TestTrackerMeanShiftComaniciu2003 method track.

@Test
public void track() {
    InterpolatePixelS interpSB = FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.EXTENDED);
    InterpolatePixelMB interpolate = FactoryInterpolation.createPixelPL(interpSB);
    LocalWeightedHistogramRotRect calcHistogram = new LocalWeightedHistogramRotRect(30, 3, 10, 3, 255, interpolate);
    TrackerMeanShiftComaniciu2003 alg = new TrackerMeanShiftComaniciu2003(false, 100, 1e-8f, 0.0f, 0.0f, 0.1f, calcHistogram);
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 100, 150, 3);
    // odd width and height so samples land on pixels
    render(image, 50, 40, 21, 31);
    RectangleRotate_F32 found = new RectangleRotate_F32(50, 40, 21, 31, 0);
    alg.initialize(image, found);
    // test no change
    alg.track(image);
    check(alg.getRegion(), 50, 40, 21, 31, 0);
    // test translation
    render(image, 55, 34, 21, 31);
    alg.track(image);
    check(alg.getRegion(), 55, 34, 21, 31, 0);
    // test scale
    render(image, 55, 34, 23, 34);
    alg.track(image);
    assertEquals(alg.getRegion().cx, 55, 1f);
    assertEquals(alg.getRegion().cy, 34, 1f);
    assertEquals(alg.getRegion().width, 23, 1);
    assertEquals(alg.getRegion().height, 34, 1);
}
Also used : InterpolatePixelS(boofcv.alg.interpolate.InterpolatePixelS) GrayF32(boofcv.struct.image.GrayF32) RectangleRotate_F32(boofcv.struct.RectangleRotate_F32) InterpolatePixelMB(boofcv.alg.interpolate.InterpolatePixelMB) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Example 7 with RectangleRotate_F32

use of boofcv.struct.RectangleRotate_F32 in project BoofCV by lessthanoptimal.

the class TestLocalWeightedHistogramRotRect method computeHistogramBorder_compare.

/**
 * When given a region entirely inside, both inside and outside should produce identical solutions
 */
@Test
public void computeHistogramBorder_compare() {
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 40, 50, 3);
    InterpolatePixelMB interp = FactoryInterpolation.createPixelPL(FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.EXTENDED));
    GImageMiscOps.fillUniform(image, rand, 0, 100);
    interp.setImage(image);
    RectangleRotate_F32 rect = new RectangleRotate_F32(20, 25, 10, 15, 0);
    LocalWeightedHistogramRotRect alg = new LocalWeightedHistogramRotRect(10, 3, 12, 3, 255, interp);
    alg.computeHistogramBorder(image, rect);
    int[] insideHistIndex = alg.sampleHistIndex.clone();
    float[] insideHist = alg.histogram.clone();
    alg = new LocalWeightedHistogramRotRect(10, 3, 12, 3, 255, interp);
    alg.computeHistogramInside(rect);
    for (int i = 0; i < insideHist.length; i++) {
        assertEquals(insideHist[i], alg.histogram[i], 1e-4f);
    }
    for (int i = 0; i < insideHistIndex.length; i++) {
        assertEquals(insideHistIndex[i], alg.sampleHistIndex[i], 1e-4f);
    }
}
Also used : RectangleRotate_F32(boofcv.struct.RectangleRotate_F32) InterpolatePixelMB(boofcv.alg.interpolate.InterpolatePixelMB) Test(org.junit.Test)

Example 8 with RectangleRotate_F32

use of boofcv.struct.RectangleRotate_F32 in project BoofCV by lessthanoptimal.

the class TestTrackerMeanShiftComaniciu2003 method updateLocation.

@Test
public void updateLocation() {
    InterpolatePixelS interpSB = FactoryInterpolation.bilinearPixelS(GrayF32.class, BorderType.EXTENDED);
    InterpolatePixelMB interpolate = FactoryInterpolation.createPixelPL(interpSB);
    LocalWeightedHistogramRotRect calcHistogram = new LocalWeightedHistogramRotRect(30, 3, 10, 3, 255, interpolate);
    TrackerMeanShiftComaniciu2003 alg = new TrackerMeanShiftComaniciu2003(false, 100, 1e-8f, 0.1f, 0.0f, 0.1f, calcHistogram);
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 100, 150, 3);
    // odd width and height so samples land on pixels
    render(image, 50, 40, 21, 31);
    RectangleRotate_F32 found = new RectangleRotate_F32(50, 40, 21, 31, 0);
    alg.initialize(image, found);
    // test no change
    alg.updateLocation(image, found);
    check(found, 50, 40, 21, 31, 0);
    // test translation
    render(image, 55, 34, 21, 31);
    alg.updateLocation(image, found);
    check(found, 55, 34, 21, 31, 0);
}
Also used : InterpolatePixelS(boofcv.alg.interpolate.InterpolatePixelS) GrayF32(boofcv.struct.image.GrayF32) RectangleRotate_F32(boofcv.struct.RectangleRotate_F32) InterpolatePixelMB(boofcv.alg.interpolate.InterpolatePixelMB) Planar(boofcv.struct.image.Planar) Test(org.junit.Test)

Aggregations

RectangleRotate_F32 (boofcv.struct.RectangleRotate_F32)8 Test (org.junit.Test)7 InterpolatePixelMB (boofcv.alg.interpolate.InterpolatePixelMB)4 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)2 GrayF32 (boofcv.struct.image.GrayF32)2 Planar (boofcv.struct.image.Planar)2 Point2D_F32 (georegression.struct.point.Point2D_F32)1