@Override public List<? extends IndependentPair<Point2d, Point2d>> getOutliers() { return robustFitter.getOutliers(); } }
@Override public HomographyModel getModel() { return robustFitter.getModel(); }
@Override public int numItemsToEstimate() { return robustFitter.numItemsToEstimate(); }
private Matrix estimateModel() { if (this.initialFeatures == null) { return null; } final List<? extends IndependentPair<Point2d, Point2d>> pairs = findAllMatchedPairs(); final HomographyModel model = new HomographyModel(); // model.estimate(pairs); final RANSAC<Point2d, Point2d, HomographyModel> fitter = new RANSAC<Point2d, Point2d, HomographyModel>(model, new SingleImageTransferResidual2d<HomographyModel>(), 10.0, 1500, new RANSAC.PercentageInliersStoppingCondition(0.5), false); if (!fitter.fitData(pairs)) return null; model.getTransform().print(5, 5); return model.getTransform(); }
@Override public boolean fitData(List<? extends IndependentPair<Point2d, Point2d>> data) { // Use a robust fitting technique to find the inliers and estimate a // model using DLT if (!robustFitter.fitData(data)) { // just go with full-on DLT estimate rather than a robust one robustFitter.getModel().estimate(data); return false; } return true; }
/** * @return a matcher with a homographic constraint */ private static LocalFeatureMatcher<Keypoint> createConsistentRANSACHomographyMatcher() { final ConsistentLocalFeatureMatcher2d<Keypoint> matcher = new ConsistentLocalFeatureMatcher2d<Keypoint>( createFastBasicMatcher()); matcher.setFittingModel(new RobustHomographyEstimator(10.0, 1000, new RANSAC.BestFitStoppingCondition(), HomographyRefinement.NONE)); return matcher; }
@Override public List<? extends IndependentPair<Point2d, Point2d>> getInliers() { return robustFitter.getInliers(); }
/** * Construct using the {@link LMedS} algorithm with the given expected * outlier percentage * * @param outlierProportion * expected proportion of outliers (between 0 and 1) */ public RobustAffineTransformEstimator(double outlierProportion) { robustFitter = new LMedS<Point2d, Point2d, AffineTransformModel>( new AffineTransformModel(), new AlgebraicResidual2d<AffineTransformModel>(), outlierProportion, true, new BucketingSampler2d()); }
private int calculateMinInliers() { double pi, sum; int i, j; for (j = numItemsToEstimate + 1; j <= numDataItems; j++) { sum = 0; for (i = j; i <= numDataItems; i++) { pi = (i - numItemsToEstimate) * Math.log(inlierIsBadProbability) + (numDataItems - i + numItemsToEstimate) * Math.log(1.0 - inlierIsBadProbability) + log_factorial(numDataItems - numItemsToEstimate) - log_factorial(i - numItemsToEstimate) - log_factorial(numDataItems - i); /* * Last three terms above are equivalent to log( n-m choose * i-m ) */ sum += Math.exp(pi); } if (sum < desiredErrorProbability) break; } return j; }
@Override public boolean init(List<?> data, EstimatableModel<?, ?> model) { this.limit = (int) Math.rint(percentageLimit * data.size()); return super.init(data, model); } }
@Override public boolean init(List<?> data, EstimatableModel<?, ?> model) { numItemsToEstimate = model.numItemsToEstimate(); numDataItems = data.size(); this.limit = calculateMinInliers(); this.iteration = 0; this.currentProb = 1.0; this.maxInliers = 0; return true; }
private Matrix estimateModel() { if (this.initialFeatures == null) { return null; } final List<? extends IndependentPair<Point2d, Point2d>> pairs = findAllMatchedPairs(); final HomographyModel model = new HomographyModel(); // model.estimate(pairs); final RANSAC<Point2d, Point2d, HomographyModel> fitter = new RANSAC<Point2d, Point2d, HomographyModel>(model, new SingleImageTransferResidual2d<HomographyModel>(), 10.0, 1500, new RANSAC.PercentageInliersStoppingCondition(0.5), false); if (!fitter.fitData(pairs)) return null; model.getTransform().print(5, 5); return model.getTransform(); }
@Override public AffineTransformModel getModel() { return robustFitter.getModel(); }
@Override public int numItemsToEstimate() { return robustFitter.numItemsToEstimate(); }
/** * Construct using the {@link LMedS} algorithm with the given expected * outlier percentage * * @param outlierProportion * expected proportion of outliers (between 0 and 1) * @param modelCheck * the predicate to test whether an estimated model is sane */ public RobustAffineTransformEstimator(double outlierProportion, Predicate<AffineTransformModel> modelCheck) { robustFitter = new LMedS<Point2d, Point2d, AffineTransformModel>( new AffineTransformModel(modelCheck), new AlgebraicResidual2d<AffineTransformModel>(), outlierProportion, true, new BucketingSampler2d()); }
@Override public Model<Point2d, Point2d> getModel() { return modelfit.getModel(); }
@Override public int numItemsToEstimate() { return robustFitter.numItemsToEstimate(); }
/** * Construct using the {@link LMedS} algorithm with the given expected * outlier percentage * * @param outlierProportion * expected proportion of outliers (between 0 and 1) * @param refinement * the refinement technique */ public RobustFundamentalEstimator(double outlierProportion, FundamentalRefinement refinement) { robustFitter = new LMedS<Point2d, Point2d, FundamentalModel>( new FundamentalModel(false), new FundamentalModel.Fundamental8PtResidual(), outlierProportion, true, new BucketingSampler2d()); this.refinement = refinement; }
@Override public FundamentalModel getModel() { return robustFitter.getModel(); }
@Override public Model<Point2d, Point2d> getModel() { return modelfit.getModel(); }