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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations