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