Search in sources :

Example 6 with Rectangle2D_I32

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

the class TestRefinePolygonToGrayLine method fitWithEdgeOnBorder.

/**
 * See if it handles lines along the image border correctly
 */
@Test
public void fitWithEdgeOnBorder() {
    x0 = 0;
    x1 = 100;
    y0 = 100;
    y1 = 200;
    rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
    for (Class imageType : imageTypes) {
        renderDistortedRectangles(true, imageType);
        RefinePolygonToGrayLine alg = createAlg(4, imageType);
        Polygon2D_F64 input = createFromSquare(null);
        input.get(0).set(x0, y0 + 1.1);
        input.get(1).set(x0, y1 - 1.1);
        Polygon2D_F64 found = new Polygon2D_F64(4);
        alg.setImage(image);
        assertTrue(alg.refine(input, found));
        Polygon2D_F64 expected = createFromSquare(null);
        assertTrue(expected.isIdentical(found, 0.01));
    }
}
Also used : Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 7 with Rectangle2D_I32

use of georegression.struct.shapes.Rectangle2D_I32 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_I32

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

the class CommonFitPolygonChecks method renderDistortedRectangles.

public void renderDistortedRectangles(boolean blackShape, Class imageType) {
    orig = GeneralizedImageOps.createSingleBand(imageType, width, height);
    image = GeneralizedImageOps.createSingleBand(imageType, width, height);
    int white = blackShape ? this.white : this.black;
    int black = blackShape ? this.black : this.white;
    GImageMiscOps.fill(orig, white);
    GImageMiscOps.fill(image, white);
    distorted.clear();
    for (Rectangle2D_I32 q : rectangles) {
        if (fittingToBinaryImage)
            GImageMiscOps.fillRectangle(orig, black, q.x0, q.y0, q.x1 - q.x0 + 1, q.y1 - q.y0 + 1);
        else
            GImageMiscOps.fillRectangle(orig, black, q.x0, q.y0, q.x1 - q.x0, q.y1 - q.y0);
        Polygon2D_F64 tran = new Polygon2D_F64(4);
        AffinePointOps_F64.transform(transform, q.x0, q.y0, tran.get(0));
        AffinePointOps_F64.transform(transform, q.x0, q.y1, tran.get(1));
        AffinePointOps_F64.transform(transform, q.x1, q.y1, tran.get(2));
        AffinePointOps_F64.transform(transform, q.x1, q.y0, tran.get(3));
        distorted.add(tran);
    }
    new FDistort(orig, image).border(white).affine(transform).apply();
    if (showRendered) {
        ListDisplayPanel panel = new ListDisplayPanel();
        panel.addImage(orig, "Original");
        panel.addImage(image, "Image");
        ShowImages.showWindow(panel, "Rendered");
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
Also used : ListDisplayPanel(boofcv.gui.ListDisplayPanel) FDistort(boofcv.abst.distort.FDistort) Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 9 with Rectangle2D_I32

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

the class TestDetectPolygonBinaryGrayRefine method refineAll.

@Test
public void refineAll() {
    rectangles.add(new Rectangle2D_I32(30, 30, 60, 60));
    rectangles.add(new Rectangle2D_I32(90, 30, 120, 60));
    for (Class type : imageTypes) {
        refineAll(type, 1.5, 0.1);
    }
}
Also used : Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Test(org.junit.Test)

Example 10 with Rectangle2D_I32

use of georegression.struct.shapes.Rectangle2D_I32 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_I32 (georegression.struct.shapes.Rectangle2D_I32)20 Test (org.junit.Test)17 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)6 Affine2D_F64 (georegression.struct.affine.Affine2D_F64)3 Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)3 Se2_F64 (georegression.struct.se.Se2_F64)2 FDistort (boofcv.abst.distort.FDistort)1 ListDisplayPanel (boofcv.gui.ListDisplayPanel)1 PointIndex_I32 (boofcv.struct.PointIndex_I32)1 Polygon2D_I32 (georegression.struct.shapes.Polygon2D_I32)1 Term (nars.term.Term)1