Search in sources :

Example 16 with Rectangle2D_I32

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

the class TestRefinePolygonToGrayLine method fit_noisy_affine.

/**
 * Fit the quad with a noisy initial guess
 */
@Test
public void fit_noisy_affine() {
    // distorted and undistorted views
    Affine2D_F64[] affines = new Affine2D_F64[2];
    affines[0] = new Affine2D_F64();
    affines[1] = new Affine2D_F64(1.3, 0.05, -0.15, 0.87, 0.1, 0.6);
    ConvertTransform_F64.convert(new Se2_F64(0, 0, 0.2), affines[0]);
    rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
    for (Class imageType : imageTypes) {
        for (Affine2D_F64 a : affines) {
            // System.out.println(imageType+"  "+a);
            fit_noisy_affine(true, a, imageType);
            fit_noisy_affine(false, a, imageType);
        }
    }
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Se2_F64(georegression.struct.se.Se2_F64) Test(org.junit.Test)

Example 17 with Rectangle2D_I32

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

the class TestRefinePolygonToGrayLine method fit_tooSmall.

/**
 * Give it a shape which is too small and see if it fails
 */
@Test
public void fit_tooSmall() {
    final boolean black = true;
    Polygon2D_F64 input = new Polygon2D_F64(5, 5, 5, 6, 6, 6, 6, 5);
    rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
    for (Class imageType : imageTypes) {
        renderDistortedRectangles(black, imageType);
        RefinePolygonToGrayLine alg = createAlg(input.size(), imageType);
        Polygon2D_F64 output = new Polygon2D_F64(input.size());
        alg.setImage(image);
        assertFalse(alg.refine(input, output));
    }
}
Also used : Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 18 with Rectangle2D_I32

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

the class TestRefinePolygonToGrayLine method fit_perfect_affine.

/**
 * Perfect initial guess.
 */
@Test
public void fit_perfect_affine() {
    // distorted and undistorted views
    Affine2D_F64[] affines = new Affine2D_F64[2];
    affines[0] = new Affine2D_F64();
    affines[1] = new Affine2D_F64(1.3, 0.05, -0.15, 0.87, 0.1, 0.6);
    ConvertTransform_F64.convert(new Se2_F64(0, 0, 0.2), affines[0]);
    rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
    for (Class imageType : imageTypes) {
        for (Affine2D_F64 a : affines) {
            // System.out.println(imageType+"  "+a);
            fit_perfect_affine(true, a, imageType);
            fit_perfect_affine(false, a, imageType);
        }
    }
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Se2_F64(georegression.struct.se.Se2_F64) Test(org.junit.Test)

Example 19 with Rectangle2D_I32

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

the class TestRefinePolygonToGrayLine method fit_subimage.

/**
 * Makes sure it can handle sub-images
 */
@Test
public void fit_subimage() {
    final boolean black = true;
    rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
    Polygon2D_F64 input = new Polygon2D_F64(x0, y0, x0, y1, x1, y1, x1, y0);
    for (Class imageType : imageTypes) {
        renderDistortedRectangles(black, imageType);
        RefinePolygonToGrayLine alg = createAlg(input.size(), imageType);
        Polygon2D_F64 output = new Polygon2D_F64(4);
        alg.setImage(image);
        assertTrue(alg.refine(input, output));
        // do it again with a sub-image
        Polygon2D_F64 output2 = new Polygon2D_F64(4);
        image = BoofTesting.createSubImageOf_S(image);
        alg.setImage(image);
        assertTrue(alg.refine(input, output2));
        assertTrue(UtilPolygons2D_F64.isIdentical(output, output2, 1e-8));
    }
}
Also used : Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64) Test(org.junit.Test)

Example 20 with Rectangle2D_I32

use of georegression.struct.shapes.Rectangle2D_I32 in project narchy by automenta.

the class ShapeSensor method inputQuadBlob.

private void inputQuadBlob(int k, List<PointIndex_I32> polygon, float w, float h) {
    Polygon2D_I32 p = new Polygon2D_I32(polygon.size());
    for (PointIndex_I32 v : polygon) p.vertexes.add(v);
    Rectangle2D_I32 quad = new Rectangle2D_I32();
    UtilPolygons2D_I32.bounding(p, quad);
    float cx = ((quad.x0 + quad.x1) / 2f) / w;
    float cy = ((quad.y0 + quad.y1) / 2f) / h;
    float cw = quad.getWidth() / w;
    float ch = quad.getHeight() / h;
    Term pid = $.p(id, $.the(k));
    float conf = nar.confDefault(BELIEF);
    long now = nar.time();
    believe(now, $.inh(pid, $.the("x")), $.t(cx, conf));
    believe(now, $.inh(pid, $.the("y")), $.t(cy, conf));
    believe(now, $.inh(pid, $.the("w")), $.t(cw, conf));
    believe(now, $.inh(pid, $.the("h")), $.t(ch, conf));
}
Also used : Polygon2D_I32(georegression.struct.shapes.Polygon2D_I32) PointIndex_I32(boofcv.struct.PointIndex_I32) Rectangle2D_I32(georegression.struct.shapes.Rectangle2D_I32) Term(nars.term.Term)

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