Search in sources :

Example 16 with Affine2D_F32

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

the class DistortSupport method transformRotate.

/**
 * Creates a {@link boofcv.alg.distort.PixelTransformAffine_F32} from the dst image into the src image.
 *
 * @param x0 Center of rotation in input image coordinates.
 * @param y0 Center of rotation in input image coordinates.
 * @param x1 Center of rotation in output image coordinates.
 * @param y1 Center of rotation in output image coordinates.
 * @param angle Angle of rotation.
 */
public static PixelTransformAffine_F32 transformRotate(float x0, float y0, float x1, float y1, float angle) {
    // make the coordinate system's origin the image center
    Se2_F32 imageToCenter = new Se2_F32(-x0, -y0, 0);
    Se2_F32 rotate = new Se2_F32(0, 0, angle);
    Se2_F32 centerToImage = new Se2_F32(x1, y1, 0);
    InvertibleTransformSequence sequence = new InvertibleTransformSequence();
    sequence.addTransform(true, imageToCenter);
    sequence.addTransform(true, rotate);
    sequence.addTransform(true, centerToImage);
    Se2_F32 total = new Se2_F32();
    sequence.computeTransform(total);
    Se2_F32 inv = total.invert(null);
    Affine2D_F32 affine = ConvertTransform_F32.convert(inv, (Affine2D_F32) null);
    PixelTransformAffine_F32 distort = new PixelTransformAffine_F32();
    distort.set(affine);
    return distort;
}
Also used : InvertibleTransformSequence(georegression.transform.InvertibleTransformSequence) Affine2D_F32(georegression.struct.affine.Affine2D_F32) PixelTransformAffine_F32(boofcv.alg.distort.PixelTransformAffine_F32) Se2_F32(georegression.struct.se.Se2_F32)

Example 17 with Affine2D_F32

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

the class TestDistortImageOps method boundBox.

@Test
public void boundBox() {
    // basic sanity check
    Affine2D_F32 affine = new Affine2D_F32(1, 0, 0, 1, 2, 3);
    PixelTransformAffine_F32 transform = new PixelTransformAffine_F32(affine);
    RectangleLength2D_I32 found = DistortImageOps.boundBox(10, 20, transform);
    assertEquals(2, found.x0);
    assertEquals(3, found.y0);
    assertEquals(10, found.width);
    assertEquals(20, found.height);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) RectangleLength2D_I32(georegression.struct.shapes.RectangleLength2D_I32) Test(org.junit.Test)

Example 18 with Affine2D_F32

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

the class TestDistortImageOps method boundBox_F32.

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

Example 19 with Affine2D_F32

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

the class TestPixelDistortAffine_F32 method constructor_32.

@Test
public void constructor_32() {
    Affine2D_F32 a = new Affine2D_F32(1, 2, 3, 4, 5, 6);
    PixelTransformAffine_F32 alg = new PixelTransformAffine_F32();
    alg.set(a);
    alg.compute(2, 3);
    Point2D_F32 p = new Point2D_F32(2, 3);
    Point2D_F32 expected = new Point2D_F32();
    AffinePointOps_F32.transform(a, p, expected);
    assertEquals(expected.x, alg.distX, 1e-4);
    assertEquals(expected.y, alg.distY, 1e-4);
}
Also used : Affine2D_F32(georegression.struct.affine.Affine2D_F32) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 20 with Affine2D_F32

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

Aggregations

Affine2D_F32 (georegression.struct.affine.Affine2D_F32)21 PixelTransformAffine_F32 (boofcv.alg.distort.PixelTransformAffine_F32)13 Test (org.junit.Test)11 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)6 GrayU8 (boofcv.struct.image.GrayU8)3 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)3 Affine2D_F64 (georegression.struct.affine.Affine2D_F64)2 Homography2D_F32 (georegression.struct.homography.Homography2D_F32)2 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)2 RectangleLength2D_F32 (georegression.struct.shapes.RectangleLength2D_F32)2 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)2 ArrayList (java.util.ArrayList)2 PixelTransformHomography_F32 (boofcv.alg.distort.PixelTransformHomography_F32)1 InterpolatePixelS (boofcv.alg.interpolate.InterpolatePixelS)1 GrayF32 (boofcv.struct.image.GrayF32)1 ImageGray (boofcv.struct.image.ImageGray)1 Planar (boofcv.struct.image.Planar)1 EllipseRotated_F64 (georegression.struct.curve.EllipseRotated_F64)1 Point2D_F32 (georegression.struct.point.Point2D_F32)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1