Search in sources :

Example 16 with RectangleLength2D_I32

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

the class TestLikelihoodHistCoupled_SB_U8 method multipleColors.

@Test
public void multipleColors() {
    LikelihoodHistCoupled_SB_U8 alg = new LikelihoodHistCoupled_SB_U8(255, 11);
    GrayU8 image = new GrayU8(30, 40);
    RectangleLength2D_I32 r0 = new RectangleLength2D_I32(3, 4, 8, 8);
    RectangleLength2D_I32 r1 = new RectangleLength2D_I32(11, 4, 4, 8);
    setColor(image, r0, 100);
    setColor(image, r1, 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) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 17 with RectangleLength2D_I32

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

the class TestLikelihoodHueSatHistCoupled_PL_U8 method multipleColors.

@Test
public void multipleColors() {
    LikelihoodHueSatHistCoupled_PL_U8 alg = new LikelihoodHueSatHistCoupled_PL_U8(255, 5);
    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 18 with RectangleLength2D_I32

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

the class TestLikelihoodHueSatHistInd_PL_U8 method numBins.

@Test
public void numBins() {
    LikelihoodHueSatHistInd_PL_U8 alg = new LikelihoodHueSatHistInd_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.binsH.length);
    assertEquals(30, alg.binsS.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 19 with RectangleLength2D_I32

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

the class ExampleTrackerMeanShiftLikelihood method main.

public static void main(String[] args) {
    MediaManager media = DefaultMediaManager.INSTANCE;
    String fileName = UtilIO.pathExample("tracking/balls_blue_red.mjpeg");
    RectangleLength2D_I32 location = new RectangleLength2D_I32(394, 247, 475 - 394, 325 - 247);
    ImageType<Planar<GrayU8>> imageType = ImageType.pl(3, GrayU8.class);
    SimpleImageSequence<Planar<GrayU8>> video = media.openVideo(fileName, imageType);
    // Return a higher likelihood for pixels close to this RGB color
    RgbLikelihood likelihood = new RgbLikelihood(64, 71, 69);
    TrackerMeanShiftLikelihood<Planar<GrayU8>> tracker = new TrackerMeanShiftLikelihood<>(likelihood, 50, 0.1f);
    // specify the target's initial location and initialize with the first frame
    Planar<GrayU8> frame = video.next();
    // Note that the tracker will not automatically invoke RgbLikelihood.createModel() in its initialize function
    tracker.initialize(frame, location);
    // For displaying the results
    TrackerObjectQuadPanel gui = new TrackerObjectQuadPanel(null);
    gui.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight()));
    gui.setImageUI((BufferedImage) video.getGuiImage());
    gui.setTarget(location, true);
    ShowImages.showWindow(gui, "Tracking Results", true);
    // Track the object across each video frame and display the results
    while (video.hasNext()) {
        frame = video.next();
        boolean visible = tracker.process(frame);
        gui.setImageUI((BufferedImage) video.getGuiImage());
        gui.setTarget(tracker.getLocation(), visible);
        gui.repaint();
        BoofMiscOps.pause(20);
    }
}
Also used : TrackerMeanShiftLikelihood(boofcv.alg.tracker.meanshift.TrackerMeanShiftLikelihood) MediaManager(boofcv.io.MediaManager) DefaultMediaManager(boofcv.io.wrapper.DefaultMediaManager) RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) TrackerObjectQuadPanel(boofcv.gui.tracker.TrackerObjectQuadPanel)

Example 20 with RectangleLength2D_I32

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

the class TestRefinePolygonToContour method reverseOrder.

@Test
public void reverseOrder() {
    RectangleLength2D_I32 rect = new RectangleLength2D_I32(0, 0, 10, 5);
    List<Point2D_I32> contour = rectToContour(rect);
    GrowQueue_I32 vertexes = computeContourVertexes(rect);
    flip(vertexes.data, vertexes.size);
    RefinePolygonToContour alg = new RefinePolygonToContour();
    Polygon2D_F64 found = new Polygon2D_F64();
    alg.process(contour, vertexes, found);
    assertTrue(checkPolygon(new double[] { 0, 0, 0, 4, 9, 4, 9, 0 }, found));
}
Also used : RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) 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