Search in sources :

Example 81 with AssociatedPair

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);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64)

Example 82 with AssociatedPair

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);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ClosestPoint3D_F64(georegression.metric.ClosestPoint3D_F64) Point3D_F64(georegression.struct.point.Point3D_F64) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 83 with AssociatedPair

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);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ClosestPoint3D_F64(georegression.metric.ClosestPoint3D_F64) Point3D_F64(georegression.struct.point.Point3D_F64) Se3_F64(georegression.struct.se.Se3_F64) Test(org.junit.Test)

Example 84 with AssociatedPair

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;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 85 with AssociatedPair

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

AssociatedPair (boofcv.struct.geo.AssociatedPair)110 Test (org.junit.Test)32 Point2D_F64 (georegression.struct.point.Point2D_F64)28 ArrayList (java.util.ArrayList)27 DMatrixRMaj (org.ejml.data.DMatrixRMaj)22 Se3_F64 (georegression.struct.se.Se3_F64)17 Point3D_F64 (georegression.struct.point.Point3D_F64)12 ScaleTranslate2D (boofcv.struct.sfm.ScaleTranslate2D)7 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)6 Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)5 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)4 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)4 ScaleTranslateRotate2D (boofcv.struct.sfm.ScaleTranslateRotate2D)4 ClosestPoint3D_F64 (georegression.metric.ClosestPoint3D_F64)4 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)3 TriangulateTwoViewsCalibrated (boofcv.abst.geo.TriangulateTwoViewsCalibrated)3 AssociationPanel (boofcv.gui.feature.AssociationPanel)3 BrightFeature (boofcv.struct.feature.BrightFeature)3 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)3 Ransac (org.ddogleg.fitting.modelset.ransac.Ransac)3