Search in sources :

Example 66 with AssociatedPair

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

the class TestGeoModelEstimatorNto1 method checkSelectBestSolution.

/**
 * Generate one matrix which should match the epipolar constraint and a bunch of random
 * ones.  See if it selects the correct matrix
 */
@Test
public void checkSelectBestSolution() {
    DMatrixRMaj correct = createSolution();
    GeoModelEstimatorNto1<DMatrixRMaj, AssociatedPair> alg = new DummyEstimator(new Dummy(correct, 7), distance, 2);
    assertTrue(alg.process(obs, found));
    // See if it selected the correct matrix
    assertTrue(MatrixFeatures_DDRM.isIdentical(found, correct, 1e-8));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 67 with AssociatedPair

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

the class CheckEstimate1ofEpipolar method checkConstraint.

/**
 * Make sure the ordering of the epipolar constraint is computed correctly
 */
@Test
public void checkConstraint() {
    init(50, isPixels);
    boolean workedOnce = false;
    DMatrixRMaj F = new DMatrixRMaj(3, 3);
    for (int i = 0; i < 10; i++) {
        List<AssociatedPair> pairs = randomPairs(alg.getMinimumPoints());
        if (!alg.process(pairs, F)) {
            continue;
        }
        workedOnce = true;
        // normalize to ensure proper scaling
        double n = CommonOps_DDRM.elementMaxAbs(F);
        CommonOps_DDRM.scale(1.0 / n, F);
        for (AssociatedPair p : pairs) {
            double correct = Math.abs(GeometryMath_F64.innerProd(p.p2, F, p.p1));
            double wrong = Math.abs(GeometryMath_F64.innerProd(p.p1, F, p.p2));
            assertTrue(correct < wrong * 0.001);
        }
    }
    assertTrue(workedOnce);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 68 with AssociatedPair

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

the class CheckEstimateNofEpipolar method checkConstraint.

/**
 * Make sure the ordering of the epipolar constraint is computed correctly
 */
@Test
public void checkConstraint() {
    init(50, isPixels);
    boolean workedOnce = false;
    FastQueue<DMatrixRMaj> solutions = new QueueMatrix(3, 3);
    for (int i = 0; i < 10; i++) {
        List<AssociatedPair> pairs = randomPairs(alg.getMinimumPoints());
        if (!alg.process(pairs, solutions)) {
            continue;
        }
        if (solutions.size() <= 0)
            continue;
        workedOnce = true;
        for (DMatrixRMaj F : solutions.toList()) {
            // normalize to ensure proper scaling
            double n = CommonOps_DDRM.elementMaxAbs(F);
            CommonOps_DDRM.scale(1.0 / n, F);
            for (AssociatedPair p : pairs) {
                double correct = Math.abs(GeometryMath_F64.innerProd(p.p2, F, p.p1));
                double wrong = Math.abs(GeometryMath_F64.innerProd(p.p1, F, p.p2));
                assertTrue(correct < wrong * 0.001);
            }
        }
    }
    assertTrue(workedOnce);
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DMatrixRMaj(org.ejml.data.DMatrixRMaj) QueueMatrix(boofcv.struct.geo.QueueMatrix) Test(org.junit.Test)

Example 69 with AssociatedPair

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

the class GenerateAffine2D method generate.

@Override
public boolean generate(List<AssociatedPair> dataSet, Affine2D_F64 model) {
    from.clear();
    to.clear();
    for (int i = 0; i < dataSet.size(); i++) {
        AssociatedPair p = dataSet.get(i);
        from.add(p.p1);
        to.add(p.p2);
    }
    if (!fitter.process(from, to))
        return false;
    model.set(fitter.getTransformSrcToDst());
    return true;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair)

Example 70 with AssociatedPair

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

the class GenerateSe2_AssociatedPair method generate.

@Override
public boolean generate(List<AssociatedPair> dataSet, Se2_F64 output) {
    from.clear();
    to.clear();
    for (int i = 0; i < dataSet.size(); i++) {
        AssociatedPair p = dataSet.get(i);
        from.add(p.getP1());
        to.add(p.getP2());
    }
    if (!estimate.process(from, to))
        return false;
    output.set(estimate.getTransformSrcToDst());
    return true;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) MotionTransformPoint(georegression.fitting.MotionTransformPoint)

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