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