Search in sources :

Example 21 with Affine2D_F64

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

the class TestStitchingFromMotion2D method basicTest.

/**
 * Given fake internal algorithms see if it performs as expected.  tests several functions
 */
@Test
public void basicTest() {
    HelperMotion motion = new HelperMotion();
    HelperDistort distort = new HelperDistort();
    StitchingTransform trans = FactoryStitchingTransform.createAffine_F64();
    StitchingFromMotion2D<GrayF32, Affine2D_F64> alg = new StitchingFromMotion2D<>(motion, distort, trans, 0.3);
    alg.configure(200, 300, null);
    assertTrue(alg.process(image));
    assertEquals(0, motion.numReset);
    assertEquals(1, motion.numProcess);
    assertEquals(1, distort.numSetModel);
    assertEquals(1, distort.numApply);
    assertEquals(200, alg.getStitchedImage().width);
    assertEquals(300, alg.getStitchedImage().height);
    Affine2D_F64 found = alg.getWorldToCurr();
    assertEquals(1, found.tx, 1e-5);
    assertEquals(-2, found.ty, 1e-5);
    assertTrue(alg.process(image));
    assertEquals(0, motion.numReset);
    assertEquals(2, motion.numProcess);
    assertEquals(2, distort.numSetModel);
    assertEquals(2, distort.numApply);
    found = alg.getWorldToCurr();
    assertEquals(1, found.tx, 1e-5);
    assertEquals(-2, found.ty, 1e-5);
    // test reset
    alg.reset();
    assertEquals(1, motion.numReset);
    found = alg.getWorldToCurr();
    assertEquals(0, found.tx, 1e-5);
    assertEquals(0, found.ty, 1e-5);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Affine2D_F64(georegression.struct.affine.Affine2D_F64) Test(org.junit.Test)

Example 22 with Affine2D_F64

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

the class TestDistortImageOps method boundBox_F64.

@Test
public void boundBox_F64() {
    // basic sanity check
    Affine2D_F64 affine = new Affine2D_F64(1, 0, 0, 1, 2, 3);
    PixelTransformAffine_F64 transform = new PixelTransformAffine_F64(affine);
    RectangleLength2D_F64 found = DistortImageOps.boundBox_F64(10, 20, transform);
    assertEquals(2, found.x0, 1e-8);
    assertEquals(3, found.y0, 1e-8);
    assertEquals(10, found.width, 1e-8);
    assertEquals(20, found.height, 1e-8);
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) RectangleLength2D_F64(georegression.struct.shapes.RectangleLength2D_F64) Test(org.junit.Test)

Example 23 with Affine2D_F64

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

the class UtilImageMotion method createPixelTransform.

/**
 * Given a motion model create a PixelTransform used to distort the image
 *
 * @param transform Motion transform
 * @return PixelTransform_F32 used to distort the image
 */
public static PixelTransform2_F32 createPixelTransform(InvertibleTransform transform) {
    PixelTransform2_F32 pixelTran;
    if (transform instanceof Homography2D_F64) {
        Homography2D_F32 t = ConvertFloatType.convert((Homography2D_F64) transform, null);
        pixelTran = new PixelTransformHomography_F32(t);
    } else if (transform instanceof Homography2D_F32) {
        pixelTran = new PixelTransformHomography_F32((Homography2D_F32) transform);
    } else if (transform instanceof Affine2D_F64) {
        Affine2D_F32 t = UtilAffine.convert((Affine2D_F64) transform, null);
        pixelTran = new PixelTransformAffine_F32(t);
    } else if (transform instanceof Affine2D_F32) {
        pixelTran = new PixelTransformAffine_F32((Affine2D_F32) transform);
    } else {
        throw new RuntimeException("Unknown model type");
    }
    return pixelTran;
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Affine2D_F32(georegression.struct.affine.Affine2D_F32) PixelTransformHomography_F32(boofcv.alg.distort.PixelTransformHomography_F32) Homography2D_F32(georegression.struct.homography.Homography2D_F32) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Homography2D_F64(georegression.struct.homography.Homography2D_F64) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32)

Example 24 with Affine2D_F64

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

the class FactoryStitchingTransform method createAffine_F64.

public static StitchingTransform<Affine2D_F64> createAffine_F64() {
    return new StitchingTransform<Affine2D_F64>() {

        Affine2D_F32 input_F32 = new Affine2D_F32();

        @Override
        public PixelTransform2_F32 convertPixel(Affine2D_F64 input, PixelTransform2_F32 output) {
            ConvertFloatType.convert(input, input_F32);
            if (output != null) {
                ((PixelTransformAffine_F32) output).set(input_F32);
            } else {
                PixelTransformAffine_F32 a = new PixelTransformAffine_F32();
                a.set(input_F32);
                output = a;
            }
            return output;
        }

        @Override
        public Homography2D_F64 convertH(Affine2D_F64 input, Homography2D_F64 output) {
            if (output == null)
                output = new Homography2D_F64();
            output.set(input.a11, input.a12, input.tx, input.a21, input.a22, input.ty, 0, 0, 1);
            return output;
        }
    };
}
Also used : Affine2D_F64(georegression.struct.affine.Affine2D_F64) Affine2D_F32(georegression.struct.affine.Affine2D_F32) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Homography2D_F64(georegression.struct.homography.Homography2D_F64) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32)

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