use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.
the class TestPixelTransformHomography_F32 method constructor_32.
@Test
public void constructor_32() {
Homography2D_F32 a = new Homography2D_F32(1, 2, 3, 4, 5, 6, 7, 8, 9);
PixelTransformHomography_F32 alg = new PixelTransformHomography_F32();
alg.set(a);
alg.compute(2, 3);
Point2D_F32 p = new Point2D_F32(2, 3);
Point2D_F32 expected = new Point2D_F32();
HomographyPointOps_F32.transform(a, p, expected);
assertEquals(expected.x, alg.distX, 1e-4);
assertEquals(expected.y, alg.distY, 1e-4);
}
use of georegression.struct.homography.Homography2D_F32 in project BoofCV by lessthanoptimal.
the class TestPointTransformHomography_F32 method compareToDirect.
/**
* Directly computes the output
*/
@Test
public void compareToDirect() {
Point2D_F32 input = new Point2D_F32(50, 60);
Point2D_F32 output = new Point2D_F32();
Point2D_F32 expected = new Point2D_F32();
Homography2D_F32 H = new Homography2D_F32(1, 2, 3, 4, 5, 6, 7, 8, 9);
HomographyPointOps_F32.transform(H, input, expected);
PointTransformHomography_F32 alg = new PointTransformHomography_F32();
alg.set(H);
alg.compute(input.x, input.y, output);
assertEquals(expected.x, output.x, 1e-4);
assertEquals(expected.y, output.y, 1e-4);
}
use of georegression.struct.homography.Homography2D_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