Search in sources :

Example 1 with EstimateNto1ofEpipolar

use of boofcv.abst.geo.f.EstimateNto1ofEpipolar in project BoofCV by lessthanoptimal.

the class BenchmarkStabilityFundamental method evaluateMinimal.

public void evaluateMinimal(GeoModelEstimatorN<DMatrixRMaj, AssociatedPair> estimatorN) {
    DistanceEpipolarConstraint distance = new DistanceEpipolarConstraint();
    Estimate1ofEpipolar estimator = new EstimateNto1ofEpipolar(estimatorN, distance, 1);
    scores = new ArrayList<>();
    int failed = 0;
    int numSamples = estimator.getMinimumPoints();
    Random rand = new Random(234);
    DMatrixRMaj F = new DMatrixRMaj(3, 3);
    for (int i = 0; i < 50; i++) {
        List<AssociatedPair> pairs = new ArrayList<>();
        // create a unique set of pairs
        while (pairs.size() < numSamples) {
            AssociatedPair p = observations.get(rand.nextInt(observations.size()));
            if (!pairs.contains(p)) {
                pairs.add(p);
            }
        }
        if (!estimator.process(pairs, F)) {
            failed++;
            continue;
        }
        // normalize the scale of F
        CommonOps_DDRM.scale(1.0 / CommonOps_DDRM.elementMaxAbs(F), F);
        double totalScore = 0;
        // score against all observations
        for (AssociatedPair p : observations) {
            double score = Math.abs(GeometryMath_F64.innerProd(p.p2, F, p.p1));
            if (Double.isNaN(score))
                System.out.println("Score is NaN");
            scores.add(score);
            totalScore += score;
        }
    // System.out.println("  score["+i+"] = "+totalScore);
    }
    Collections.sort(scores);
    System.out.printf(" Failures %3d  Score:  50%% = %6.3e  95%% = %6.3e\n", failed, scores.get(scores.size() / 2), scores.get((int) (scores.size() * 0.95)));
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) DistanceEpipolarConstraint(boofcv.alg.geo.f.DistanceEpipolarConstraint) Random(java.util.Random) Estimate1ofEpipolar(boofcv.abst.geo.Estimate1ofEpipolar) DMatrixRMaj(org.ejml.data.DMatrixRMaj) ArrayList(java.util.ArrayList) EstimateNto1ofEpipolar(boofcv.abst.geo.f.EstimateNto1ofEpipolar) DistanceEpipolarConstraint(boofcv.alg.geo.f.DistanceEpipolarConstraint)

Aggregations

Estimate1ofEpipolar (boofcv.abst.geo.Estimate1ofEpipolar)1 EstimateNto1ofEpipolar (boofcv.abst.geo.f.EstimateNto1ofEpipolar)1 DistanceEpipolarConstraint (boofcv.alg.geo.f.DistanceEpipolarConstraint)1 AssociatedPair (boofcv.struct.geo.AssociatedPair)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 DMatrixRMaj (org.ejml.data.DMatrixRMaj)1