Search in sources :

Example 16 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 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 Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 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 18 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestAffine2DCodec method encode.

@Test
public void encode() {
    Affine2DCodec codec = new Affine2DCodec();
    Affine2D_F64 model = new Affine2D_F64(1, 2, 3, 4, 5, 6);
    double[] param = new double[6];
    codec.encode(model, param);
    for (int i = 0; i < 6; i++) {
        assertEquals(i + 1, param[i], 1e-6);
    }
    // decode
    model = new Affine2D_F64();
    codec.decode(param, model);
    assertEquals(1, model.a11, 1e-4);
    assertEquals(2, model.a12, 1e-4);
    assertEquals(3, model.a21, 1e-4);
    assertEquals(4, model.a22, 1e-4);
    assertEquals(5, model.tx, 1e-4);
    assertEquals(6, model.ty, 1e-4);
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Test(org.junit.Test)

Example 19 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestGenerateAffine2D method createRandomModel.

@Override
public Affine2D_F64 createRandomModel() {
    Affine2D_F64 model = new Affine2D_F64();
    model.a11 = rand.nextDouble();
    model.a12 = rand.nextDouble();
    model.a21 = rand.nextDouble();
    model.a22 = rand.nextDouble();
    model.tx = rand.nextDouble();
    model.ty = rand.nextDouble();
    return model;
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64)

Example 20 with Affine2D_F64

use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.

the class TestStitchingFromMotion2D method resizeStitchImage_Transform.

@Test
public void resizeStitchImage_Transform() {
    HelperMotion motion = new HelperMotion();
    InterpolatePixelS interp = FactoryInterpolation.createPixelS(0, 255, InterpolationType.BILINEAR, BorderType.EXTENDED, GrayF32.class);
    ImageDistort distorter = FactoryDistort.distortSB(false, interp, GrayF32.class);
    StitchingTransform trans = FactoryStitchingTransform.createAffine_F64();
    StitchingFromMotion2D<GrayF32, Affine2D_F64> alg = new StitchingFromMotion2D<>(motion, distorter, trans, 0.3);
    alg.configure(200, 300, null);
    assertTrue(alg.process(image));
    ImageMiscOps.fill(alg.getStitchedImage().subimage(2, 3, 30, 40, null), 1);
    Affine2D_F64 transform = new Affine2D_F64(1, 0, 0, 1, -2, 4);
    alg.resizeStitchImage(250, 400, transform);
    // see if the image is where it should be
    checkBlock(4, 0, 32, 36, alg.getStitchedImage());
    // check the stitched image size
    assertEquals(250, alg.getStitchedImage().width);
    assertEquals(400, alg.getStitchedImage().height);
    // check to see if translation was correctly applied
    Affine2D_F64 found = alg.getWorldToCurr();
    assertEquals(1 - 2, found.tx, 1e-5);
    assertEquals(-2 + 4, found.ty, 1e-5);
}
Also used : InterpolatePixelS(boofcv.alg.interpolate.InterpolatePixelS) GrayF32(boofcv.struct.image.GrayF32) Affine2D_F64(georegression.struct.affine.Affine2D_F64) ImageDistort(boofcv.alg.distort.ImageDistort) Test(org.junit.Test)

Aggregations

Affine2D_F64 (georegression.struct.affine.Affine2D_F64)24 Test (org.junit.Test)20 Se2_F64 (georegression.struct.se.Se2_F64)6 GrayF32 (boofcv.struct.image.GrayF32)4 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Rectangle2D_I32 (georegression.struct.shapes.Rectangle2D_I32)3 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)2 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)2 Affine2D_F32 (georegression.struct.affine.Affine2D_F32)2 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)2 WrapImageMotionPtkSmartRespawn (boofcv.abst.sfm.d2.WrapImageMotionPtkSmartRespawn)1 ImageDistort (boofcv.alg.distort.ImageDistort)1 PixelTransformHomography_F32 (boofcv.alg.distort.PixelTransformHomography_F32)1 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)1 AssociatedPair (boofcv.struct.geo.AssociatedPair)1 ModelManagerAffine2D_F64 (georegression.fitting.affine.ModelManagerAffine2D_F64)1 ModelManagerHomography2D_F64 (georegression.fitting.homography.ModelManagerHomography2D_F64)1 ModelManagerSe2_F64 (georegression.fitting.se.ModelManagerSe2_F64)1 MotionSe2PointSVD_F64 (georegression.fitting.se.MotionSe2PointSVD_F64)1 Homography2D_F32 (georegression.struct.homography.Homography2D_F32)1