Search in sources :

Example 6 with Rectangle2D_F64

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

the class TestTldAdjustRegion method process.

@Test
public void process() {
    ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
    FastQueue<AssociatedPair> pairs = new FastQueue<>(AssociatedPair.class, true);
    for (int i = 0; i < 200; i++) {
        AssociatedPair p = pairs.grow();
        p.p1.x = rand.nextGaussian() * 2;
        p.p1.y = rand.nextGaussian() * 2;
        p.p2.x = p.p1.x * motion.scale + motion.transX;
        p.p2.y = p.p1.y * motion.scale + motion.transY;
    }
    Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
    TldAdjustRegion alg = new TldAdjustRegion(30);
    alg.init(300, 400);
    assertTrue(alg.process(pairs, rect));
    assertEquals(17, rect.p0.x, 1e-8);
    assertEquals(33, rect.p0.y, 1e-8);
    assertEquals(47, rect.p1.x, 1e-8);
    assertEquals(63, rect.p1.y, 1e-8);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) FastQueue(org.ddogleg.struct.FastQueue) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Example 7 with Rectangle2D_F64

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

the class CommonFitPolygonChecks method findMatchesOriginal.

/**
 * Compare found rectangle against rectangles in the original undistorted image
 */
protected int findMatchesOriginal(Polygon2D_F64 found, double tol) {
    int match = 0;
    for (int i = 0; i < rectangles.size(); i++) {
        Rectangle2D_I32 ri = rectangles.get(i);
        Rectangle2D_F64 r = new Rectangle2D_F64(ri.x0, ri.y0, ri.x1, ri.y1);
        Polygon2D_F64 p = new Polygon2D_F64(4);
        UtilPolygons2D_F64.convert(r, p);
        if (p.isCCW())
            p.flip();
        if (UtilPolygons2D_F64.isEquivalent(found, p, tol))
            match++;
    }
    return match;
}
Also used : Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 8 with Rectangle2D_F64

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

the class TestEdgeIntensityPolygon method checkIntensity.

@Test
public void checkIntensity() {
    GrayU8 image = new GrayU8(400, 500);
    int value = 200;
    ImageMiscOps.fillRectangle(image, value, 20, 30, 40, 40);
    EdgeIntensityPolygon<GrayU8> alg = new EdgeIntensityPolygon<>(2, 2, 10, GrayU8.class);
    Polygon2D_F64 polygon = new Polygon2D_F64(4);
    UtilPolygons2D_F64.convert(new Rectangle2D_F64(20, 30, 60, 70), polygon);
    alg.setImage(image);
    assertTrue(alg.computeEdge(polygon, polygon.isCCW()));
    assertTrue(alg.checkIntensity(false, 50));
    assertFalse(alg.checkIntensity(true, 50));
}
Also used : Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) GrayU8(boofcv.struct.image.GrayU8) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 9 with Rectangle2D_F64

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

the class TestTldAdjustRegion method adjustRectangle.

@Test
public void adjustRectangle() {
    TldAdjustRegion alg = new TldAdjustRegion(50);
    Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
    ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
    alg.adjustRectangle(rect, motion);
    assertEquals(17, rect.p0.x, 1e-8);
    assertEquals(33, rect.p0.y, 1e-8);
    assertEquals(47, rect.p1.x, 1e-8);
    assertEquals(63, rect.p1.y, 1e-8);
}
Also used : Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) ScaleTranslate2D(boofcv.struct.sfm.ScaleTranslate2D) Test(org.junit.Test)

Example 10 with Rectangle2D_F64

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

the class TestTldHelperFunctions method convertRegion_I32_F32.

@Test
public void convertRegion_I32_F32() {
    Rectangle2D_F64 a = new Rectangle2D_F64();
    Rectangle2D_I32 b = new Rectangle2D_I32();
    b.set(10, 12, 11, 61);
    TldHelperFunctions.convertRegion(b, a);
    assertEquals(10, a.p0.x, 1e-8);
    assertEquals(12, a.p0.y, 1e-8);
    assertEquals(11, a.p1.x, 1e-8);
    assertEquals(61, a.p1.y, 1e-8);
}
Also used : Rectangle2D_F64(georegression.struct.shapes.Rectangle2D_F64) Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Test(org.junit.Test)

Aggregations

Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)17 Test (org.junit.Test)11 GrayU8 (boofcv.struct.image.GrayU8)3 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)3 Rectangle2D_I32 (georegression.struct.shapes.Rectangle2D_I32)3 ScaleTranslate2D (boofcv.struct.sfm.ScaleTranslate2D)2 Webcam (com.github.sarxos.webcam.Webcam)2 BufferedImage (java.awt.image.BufferedImage)2 FastQueue (org.ddogleg.struct.FastQueue)2 ConvertBufferedImage (boofcv.core.image.ConvertBufferedImage)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 ImageRectangle (boofcv.struct.ImageRectangle)1 AssociatedPair (boofcv.struct.geo.AssociatedPair)1