Search in sources :

Example 71 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class CheckRefineFundamental method perfectInput.

@Test
public void perfectInput() {
    init(30, false);
    // compute true essential matrix
    DMatrixRMaj E = MultiViewOps.createEssential(worldToCamera.getR(), worldToCamera.getT());
    ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
    // give it the perfect matrix and see if it screwed it up
    assertTrue(alg.fitModel(pairs, E, found));
    // normalize so that they are the same
    CommonOps_DDRM.divide(E, E.get(2, 2));
    CommonOps_DDRM.divide(found, found.get(2, 2));
    assertTrue(MatrixFeatures_DDRM.isEquals(E, found, 1e-8));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 72 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class CheckRefineFundamental method incorrectInput.

@Test
public void incorrectInput() {
    init(30, false);
    // compute true essential matrix
    DMatrixRMaj E = MultiViewOps.createEssential(worldToCamera.getR(), worldToCamera.getT());
    // create an alternative incorrect matrix
    Vector3D_F64 T = worldToCamera.getT().copy();
    T.x += 0.1;
    DMatrixRMaj Emod = MultiViewOps.createEssential(worldToCamera.getR(), T);
    ModelFitter<DMatrixRMaj, AssociatedPair> alg = createAlgorithm();
    // compute and compare results
    assertTrue(alg.fitModel(pairs, Emod, found));
    // normalize to allow comparison
    CommonOps_DDRM.divide(E, E.get(2, 2));
    CommonOps_DDRM.divide(Emod, Emod.get(2, 2));
    CommonOps_DDRM.divide(found, found.get(2, 2));
    double error0 = 0;
    double error1 = 0;
    // very crude error metric
    for (int i = 0; i < 9; i++) {
        error0 += Math.abs(Emod.data[i] - E.data[i]);
        error1 += Math.abs(found.data[i] - E.data[i]);
    }
    // System.out.println("error "+error1+"   other "+error0);
    assertTrue(error1 < error0);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Vector3D_F64(georegression.struct.point.Vector3D_F64) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 73 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class FactoryMultiViewRobust method epipolarLMedS.

private static LeastMedianOfSquares<Se3_F64, AssociatedPair> epipolarLMedS(Estimate1ofEpipolar epipolar, CameraPinholeRadial intrinsic, ConfigLMedS configLMedS) {
    TriangulateTwoViewsCalibrated triangulate = FactoryMultiView.triangulateTwoGeometric();
    ModelManager<Se3_F64> manager = new ModelManagerSe3_F64();
    ModelGenerator<Se3_F64, AssociatedPair> generateEpipolarMotion = new Se3FromEssentialGenerator(epipolar, triangulate);
    DistanceFromModel<Se3_F64, AssociatedPair> distanceSe3 = new DistanceSe3SymmetricSq(triangulate, intrinsic.fx, intrinsic.fy, intrinsic.skew, intrinsic.fx, intrinsic.fy, intrinsic.skew);
    LeastMedianOfSquares<Se3_F64, AssociatedPair> config = new LeastMedianOfSquares<>(configLMedS.randSeed, configLMedS.totalCycles, manager, generateEpipolarMotion, distanceSe3);
    config.setErrorFraction(configLMedS.errorFraction);
    return config;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) LeastMedianOfSquares(org.ddogleg.fitting.modelset.lmeds.LeastMedianOfSquares) DistanceSe3SymmetricSq(boofcv.alg.geo.robust.DistanceSe3SymmetricSq) ModelManagerSe3_F64(georegression.fitting.se.ModelManagerSe3_F64) Se3FromEssentialGenerator(boofcv.alg.geo.robust.Se3FromEssentialGenerator) TriangulateTwoViewsCalibrated(boofcv.abst.geo.TriangulateTwoViewsCalibrated) Se3_F64(georegression.struct.se.Se3_F64) ModelManagerSe3_F64(georegression.fitting.se.ModelManagerSe3_F64)

Example 74 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class DistanceHomographySq method computeDistance.

@Override
public void computeDistance(List<AssociatedPair> points, double[] distance) {
    for (int i = 0; i < points.size(); i++) {
        AssociatedPair p = points.get(i);
        HomographyPointOps_F64.transform(model, p.p1, expected);
        distance[i] = expected.distance2(p.p2);
    }
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 75 with AssociatedPair

use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.

the class ExampleMultiviewSceneReconstruction method estimateStereoPose.

/**
 * Given two images compute the relative location of each image using the essential matrix.
 */
protected boolean estimateStereoPose(int imageA, int imageB, Se3_F64 motionAtoB, List<AssociatedIndex> inliers) {
    // associate the features together
    associate.setSource(imageVisualFeatures.get(imageA));
    associate.setDestination(imageVisualFeatures.get(imageB));
    associate.associate();
    FastQueue<AssociatedIndex> matches = associate.getMatches();
    // create the associated pair for motion estimation
    FastQueue<Point2D_F64> pixelsA = imagePixels.get(imageA);
    FastQueue<Point2D_F64> pixelsB = imagePixels.get(imageB);
    List<AssociatedPair> pairs = new ArrayList<>();
    for (int i = 0; i < matches.size(); i++) {
        AssociatedIndex a = matches.get(i);
        pairs.add(new AssociatedPair(pixelsA.get(a.src), pixelsB.get(a.dst)));
    }
    if (!estimateEssential.process(pairs))
        throw new RuntimeException("Motion estimation failed");
    List<AssociatedPair> inliersEssential = estimateEssential.getMatchSet();
    motionAtoB.set(estimateEssential.getModelParameters());
    for (int i = 0; i < inliersEssential.size(); i++) {
        int index = estimateEssential.getInputIndex(i);
        inliers.add(matches.get(index));
    }
    return true;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

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