use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_noisy_affine.
/**
* Fit the quad with a noisy initial guess
*/
@Test
public void fit_noisy_affine() {
// distorted and undistorted views
Affine2D_F64[] affines = new Affine2D_F64[2];
affines[0] = new Affine2D_F64();
affines[1] = new Affine2D_F64(1.3, 0.05, -0.15, 0.87, 0.1, 0.6);
ConvertTransform_F64.convert(new Se2_F64(0, 0, 0.2), affines[0]);
rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
for (Class imageType : imageTypes) {
for (Affine2D_F64 a : affines) {
// System.out.println(imageType+" "+a);
fit_noisy_affine(true, a, imageType);
fit_noisy_affine(false, a, imageType);
}
}
}
use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.
the class TestRefinePolygonToGrayLine method fit_perfect_affine.
/**
* Perfect initial guess.
*/
@Test
public void fit_perfect_affine() {
// distorted and undistorted views
Affine2D_F64[] affines = new Affine2D_F64[2];
affines[0] = new Affine2D_F64();
affines[1] = new Affine2D_F64(1.3, 0.05, -0.15, 0.87, 0.1, 0.6);
ConvertTransform_F64.convert(new Se2_F64(0, 0, 0.2), affines[0]);
rectangles.add(new Rectangle2D_I32(x0, y0, x1, y1));
for (Class imageType : imageTypes) {
for (Affine2D_F64 a : affines) {
// System.out.println(imageType+" "+a);
fit_perfect_affine(true, a, imageType);
fit_perfect_affine(false, a, imageType);
}
}
}
use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.
the class TestAffine2DCodec method encode.
@Test
public void encode() {
Affine2DCodec codec = new Affine2DCodec();
Affine2D_F64 model = new Affine2D_F64(1, 2, 3, 4, 5, 6);
double[] param = new double[6];
codec.encode(model, param);
for (int i = 0; i < 6; i++) {
assertEquals(i + 1, param[i], 1e-6);
}
// decode
model = new Affine2D_F64();
codec.decode(param, model);
assertEquals(1, model.a11, 1e-4);
assertEquals(2, model.a12, 1e-4);
assertEquals(3, model.a21, 1e-4);
assertEquals(4, model.a22, 1e-4);
assertEquals(5, model.tx, 1e-4);
assertEquals(6, model.ty, 1e-4);
}
use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.
the class TestGenerateAffine2D method createRandomModel.
@Override
public Affine2D_F64 createRandomModel() {
Affine2D_F64 model = new Affine2D_F64();
model.a11 = rand.nextDouble();
model.a12 = rand.nextDouble();
model.a21 = rand.nextDouble();
model.a22 = rand.nextDouble();
model.tx = rand.nextDouble();
model.ty = rand.nextDouble();
return model;
}
use of georegression.struct.affine.Affine2D_F64 in project BoofCV by lessthanoptimal.
the class TestStitchingFromMotion2D method resizeStitchImage_Transform.
@Test
public void resizeStitchImage_Transform() {
HelperMotion motion = new HelperMotion();
InterpolatePixelS interp = FactoryInterpolation.createPixelS(0, 255, InterpolationType.BILINEAR, BorderType.EXTENDED, GrayF32.class);
ImageDistort distorter = FactoryDistort.distortSB(false, interp, GrayF32.class);
StitchingTransform trans = FactoryStitchingTransform.createAffine_F64();
StitchingFromMotion2D<GrayF32, Affine2D_F64> alg = new StitchingFromMotion2D<>(motion, distorter, trans, 0.3);
alg.configure(200, 300, null);
assertTrue(alg.process(image));
ImageMiscOps.fill(alg.getStitchedImage().subimage(2, 3, 30, 40, null), 1);
Affine2D_F64 transform = new Affine2D_F64(1, 0, 0, 1, -2, 4);
alg.resizeStitchImage(250, 400, transform);
// see if the image is where it should be
checkBlock(4, 0, 32, 36, alg.getStitchedImage());
// check the stitched image size
assertEquals(250, alg.getStitchedImage().width);
assertEquals(400, alg.getStitchedImage().height);
// check to see if translation was correctly applied
Affine2D_F64 found = alg.getWorldToCurr();
assertEquals(1 - 2, found.tx, 1e-5);
assertEquals(-2 + 4, found.ty, 1e-5);
}
Aggregations