use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestDistanceSe2Sq method createRandomData.
@Override
public AssociatedPair createRandomData() {
Point2D_F64 p1 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
Point2D_F64 p2 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
return new AssociatedPair(p1, p2);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestDistanceSe3SymmetricSq method testNoisy.
@Test
public void testNoisy() {
Se3_F64 keyToCurr = new Se3_F64();
keyToCurr.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
keyToCurr.getT().set(0.1, -0.1, 0.01);
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
AssociatedPair obs = new AssociatedPair();
obs.p1.x = X.x / X.z;
obs.p1.y = X.y / X.z;
SePointOps_F64.transform(keyToCurr, X, X);
obs.p2.x = X.x / X.z + 1;
obs.p2.y = X.y / X.z + 1;
alg.setModel(keyToCurr);
assertTrue(alg.computeDistance(obs) > 1e-8);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestDistanceSe3SymmetricSq method testPerfect.
@Test
public void testPerfect() {
Se3_F64 keyToCurr = new Se3_F64();
keyToCurr.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
keyToCurr.getT().set(0.1, -0.1, 0.01);
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
AssociatedPair obs = new AssociatedPair();
obs.p1.x = X.x / X.z;
obs.p1.y = X.y / X.z;
SePointOps_F64.transform(keyToCurr, X, X);
obs.p2.x = X.x / X.z;
obs.p2.y = X.y / X.z;
alg.setModel(keyToCurr);
assertEquals(0, alg.computeDistance(obs), 1e-8);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestGenerateAffine2D method createRandomPointFromModel.
@Override
public AssociatedPair createRandomPointFromModel(Affine2D_F64 affine) {
AssociatedPair ret = new AssociatedPair();
ret.p1.x = rand.nextDouble() * 10;
ret.p1.y = rand.nextDouble() * 10;
AffinePointOps_F64.transform(affine, ret.p1, ret.p2);
return ret;
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestSe3FromEssentialGenerator method simpleTest.
@Test
public void simpleTest() {
// define motion
Se3_F64 motion = new Se3_F64();
motion.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.05, -0.01, null));
motion.getT().set(2, -0.1, 0.1);
// define observations
List<AssociatedPair> obs = new ArrayList<>();
for (int i = 0; i < 8; i++) {
Point3D_F64 p = new Point3D_F64(rand.nextGaussian() * 0.1, rand.nextGaussian() * 0.1, 3 + rand.nextGaussian() * 0.1);
AssociatedPair o = new AssociatedPair();
o.p1.x = p.x / p.z;
o.p1.y = p.y / p.z;
Point3D_F64 pp = new Point3D_F64();
SePointOps_F64.transform(motion, p, pp);
o.p2.x = pp.x / pp.z;
o.p2.y = pp.y / pp.z;
obs.add(o);
}
// create alg
Estimate1ofEpipolar essentialAlg = FactoryMultiView.computeFundamental_1(EnumFundamental.LINEAR_8, 0);
TriangulateTwoViewsCalibrated triangulate = FactoryMultiView.triangulateTwoGeometric();
Se3FromEssentialGenerator alg = new Se3FromEssentialGenerator(essentialAlg, triangulate);
Se3_F64 found = new Se3_F64();
// recompute the motion
assertTrue(alg.generate(obs, found));
// account for scale difference
double scale = found.getT().norm() / motion.getT().norm();
assertTrue(MatrixFeatures_DDRM.isIdentical(motion.getR(), found.getR(), 1e-6));
assertEquals(motion.getT().x * scale, found.getT().x, 1e-8);
assertEquals(motion.getT().y * scale, found.getT().y, 1e-8);
assertEquals(motion.getT().z * scale, found.getT().z, 1e-8);
}
Aggregations