Search in sources :

Example 6 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestLikelihoodHueSatHistCoupled_PL_U8 method convertToHueSat.

@Test
public void convertToHueSat() {
    LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_PL_U8(255, 30);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    setColor(image, 5, 6, 120, 50, 255);
    alg.setImage(image);
    alg.createModel(new RectangleLength2D_I32(5, 6, 1, 1));
    float[] hsv = new float[3];
    ColorHsv.rgbToHsv(120, 50, 255, hsv);
    int indexH = (int) (hsv[0] / alg.sizeH);
    int indexS = (int) (hsv[1] / alg.sizeS);
    int index = indexH * 30 + indexS;
    assertEquals(1.0, alg.bins[index], 1e-4);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 7 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestLikelihoodHueSatHistCoupled_PL_U8 method numBins.

@Test
public void numBins() {
    LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_PL_U8(255, 30);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    // make sure the upper limit is handled correctly
    setColor(image, 5, 6, 255, 255, 255);
    alg.setImage(image);
    alg.createModel(new RectangleLength2D_I32(5, 6, 1, 1));
    assertEquals(30, alg.numHistogramBins);
    assertEquals(30 * 30, alg.bins.length);
    // it comes out to a slightly larger size on purpose
    assertEquals(2 * Math.PI, alg.sizeH * 30, 0.01);
    assertEquals(1.0, alg.sizeS * 30, 0.01);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 8 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestLikelihoodHueSatHistCoupled_PL_U8 method singleColor.

@Test
public void singleColor() {
    LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_PL_U8(255, 5);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    RectangleLength2D_I32 r = new RectangleLength2D_I32(3, 4, 12, 8);
    setColor(image, r, 100, 105, 12);
    alg.setImage(image);
    alg.createModel(r);
    assertEquals(1.0f, alg.compute(3, 4), 1e-4);
    assertEquals(1.0f, alg.compute(14, 11), 1e-4);
    assertEquals(0, alg.compute(10, 30), 1e-4);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 9 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestLikelihoodHueSatHistInd_PL_U8 method convertToHueSat.

@Test
public void convertToHueSat() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_PL_U8(255, 30);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    setColor(image, 5, 6, 120, 50, 255);
    alg.setImage(image);
    alg.createModel(new RectangleLength2D_I32(5, 6, 1, 1));
    float[] hsv = new float[3];
    ColorHsv.rgbToHsv(120, 50, 255, hsv);
    int indexH = (int) (hsv[0] / alg.sizeH);
    int indexS = (int) (hsv[1] / alg.sizeS);
    assertEquals(1.0, alg.binsH[indexH], 1e-4);
    assertEquals(1.0, alg.binsS[indexS], 1e-4);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 10 with RectangleLength2D_I32

use of georegression.struct.shapes.RectangleLength2D_I32 in project BoofCV by lessthanoptimal.

the class TestLikelihoodHueSatHistInd_PL_U8 method singleColor.

@Test
public void singleColor() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_PL_U8(255, 5);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    RectangleLength2D_I32 r = new RectangleLength2D_I32(3, 4, 12, 8);
    setColor(image, r, 100, 105, 12);
    alg.setImage(image);
    alg.createModel(r);
    assertEquals(1.0f, alg.compute(3, 4), 1e-4);
    assertEquals(1.0f, alg.compute(14, 11), 1e-4);
    assertEquals(0, alg.compute(10, 30), 1e-4);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Aggregations

RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)24 Test (org.junit.Test)20 GrayU8 (boofcv.struct.image.GrayU8)16 Planar (boofcv.struct.image.Planar)12 Point2D_I32 (georegression.struct.point.Point2D_I32)5 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)2 TrackerMeanShiftLikelihood (boofcv.alg.tracker.meanshift.TrackerMeanShiftLikelihood)1 TrackerObjectQuadPanel (boofcv.gui.tracker.TrackerObjectQuadPanel)1 MediaManager (boofcv.io.MediaManager)1 DefaultMediaManager (boofcv.io.wrapper.DefaultMediaManager)1