Search in sources :

Example 1 with RectangleLength2D_I32

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

the class TestDistortImageOps method boundBox_check.

/**
 * boundBox that checks to see if it is contained inside the output image.
 */
@Test
public void boundBox_check() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 0, 0, 1, 2, 3);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_I32 found = DistortImageOps.boundBox(10, 20, 30, 40, transform);
    assertEquals(2, found.x0);
    assertEquals(3, found.y0);
    assertEquals(10, found.width);
    assertEquals(20, found.height);
    // bottom right border
    found = DistortImageOps.boundBox(10, 20, 8, 18, transform);
    assertEquals(2, found.x0);
    assertEquals(3, found.y0);
    assertEquals(6, found.width);
    assertEquals(15, found.height);
    // top right border
    affine.set(new Affine2D_F32(1, 0, 0, 1, -2, -3));
    found = DistortImageOps.boundBox(10, 20, 8, 18, transform);
    assertEquals(0, found.x0);
    assertEquals(0, found.y0);
    assertEquals(8, found.width);
    assertEquals(17, found.height);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Test(org.junit.Test)

Example 2 with RectangleLength2D_I32

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

the class StitchingFromMotion2D method update.

/**
 * Adds the latest image into the stitched image
 *
 * @param image
 */
private void update(I image) {
    computeCurrToInit_PixelTran();
    // only process a cropped portion to speed up processing
    RectangleLength2D_I32 box = DistortImageOps.boundBox(image.width, image.height, stitchedImage.width, stitchedImage.height, tranCurrToWorld);
    int x0 = box.x0;
    int y0 = box.y0;
    int x1 = box.x0 + box.width;
    int y1 = box.y0 + box.height;
    distorter.setModel(tranWorldToCurr);
    distorter.apply(image, stitchedImage, x0, y0, x1, y1);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32)

Example 3 with RectangleLength2D_I32

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

the class TestLikelihoodHistCoupled_PL_U8 method singleColor.

@Test
public void singleColor() {
    LikelihoodHistCoupled_PL_U8 alg = new LikelihoodHistCoupled_PL_U8(255, 11);
    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 4 with RectangleLength2D_I32

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

the class TestLikelihoodHistCoupled_PL_U8 method multipleColors.

@Test
public void multipleColors() {
    LikelihoodHistCoupled_PL_U8 alg = new LikelihoodHistCoupled_PL_U8(255, 11);
    Planar<GrayU8> image = new Planar<>(GrayU8.class, 30, 40, 3);
    RectangleLength2D_I32 r0 = new RectangleLength2D_I32(3, 4, 8, 8);
    RectangleLength2D_I32 r1 = new RectangleLength2D_I32(11, 4, 4, 8);
    setColor(image, r0, 100, 105, 12);
    setColor(image, r1, 50, 200, 50);
    RectangleLength2D_I32 region = new RectangleLength2D_I32(3, 4, 12, 8);
    alg.setImage(image);
    alg.createModel(region);
    float v0 = alg.compute(3, 4);
    float v1 = alg.compute(11, 4);
    assertEquals(1.0f, v0 + v1, 1e-4);
    assertTrue(v0 > v1);
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 5 with RectangleLength2D_I32

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

the class TestLikelihoodHistCoupled_SB_U8 method singleColor.

@Test
public void singleColor() {
    LikelihoodHistCoupled_SB_U8 alg = new LikelihoodHistCoupled_SB_U8(255, 11);
    GrayU8 image = new GrayU8(30, 40);
    RectangleLength2D_I32 r = new RectangleLength2D_I32(3, 4, 12, 8);
    setColor(image, r, 100);
    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) 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