Search in sources :

Example 11 with Estimate1ofEpipolar

use of boofcv.abst.geo.Estimate1ofEpipolar 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);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point3D_F64(georegression.struct.point.Point3D_F64) Estimate1ofEpipolar(boofcv.abst.geo.Estimate1ofEpipolar) ArrayList(java.util.ArrayList) Se3_F64(georegression.struct.se.Se3_F64) TriangulateTwoViewsCalibrated(boofcv.abst.geo.TriangulateTwoViewsCalibrated) Test(org.junit.Test)

Aggregations

Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)11 AssociatedPair (boofcv.struct.geo.AssociatedPair)5 DMatrixRMaj (org.ejml.data.DMatrixRMaj)5 ArrayList (java.util.ArrayList)4 Point2D_F64 (georegression.struct.point.Point2D_F64)2 FMatrixRMaj (org.ejml.data.FMatrixRMaj)2 FDistort (boofcv.abst.distort.FDistort)1 TriangulateTwoViewsCalibrated (boofcv.abst.geo.TriangulateTwoViewsCalibrated)1 EstimateNto1ofEpipolar (boofcv.abst.geo.f.EstimateNto1ofEpipolar)1 DistanceFromModelResidual (boofcv.abst.geo.fitting.DistanceFromModelResidual)1 GenerateEpipolarMatrix (boofcv.abst.geo.fitting.GenerateEpipolarMatrix)1 ModelManagerEpipolarMatrix (boofcv.abst.geo.fitting.ModelManagerEpipolarMatrix)1 DistanceEpipolarConstraint (boofcv.alg.geo.f.DistanceEpipolarConstraint)1 FundamentalResidualSampson (boofcv.alg.geo.f.FundamentalResidualSampson)1 PixelTransform2_F32 (boofcv.struct.distort.PixelTransform2_F32)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 Se3_F64 (georegression.struct.se.Se3_F64)1 Random (java.util.Random)1 Ransac (org.ddogleg.fitting.modelset.ransac.Ransac)1 Test (org.junit.Test)1