GithubHelp home page GithubHelp logo

ransac_solver's Introduction

ransac_solver

Header-only ransac solver.

RANSAC is a very commonly used outlier rejection scheme in VO and SLAM. However simple, it is repetitive to write the routine for each new task. Instead, it can be generalized into having the solver class to execute the routine with a model class to provide necessary customization to each problem.

To use it, include the ransac_solver.h in your project.

To define a new model class, you need to:

  1. Specify what is the individual element (Element). e.g., pixel pair, point pair, etc. It can be a std::pair of two items or an object containing two set of properties.
  2. Specify how to describe the fitted model (ModelParams)
class YourModel : public RANSAC::Model<YourElementType, YourParamsType> {}
  1. Implement the following functions:
// let solver know how many elements to sample to fit a model
unsigned int NumElementsRequired() {}
// how to fit the ModelParams given the list of selected elements and weights
ModelParams Fit(const std::vector<Element>& elements, const std::vector<float>& weights) {}
// judge whether the input element is inlier or outlier.
bool IsInlier(const Element& element, float& loss) {}
// you can also return a loss used in the solver for judging how good the parameter fits the list of elements. If judging by counting inlier, simply set 0 for inlier and 1 for outlier.
// only loss of inlier will be added to total loss.
  1. In your main routine,
  • create an instance of YourModel.
  • Create an instance of RANSAC::Solver.
  • Solve for the parameters.
YourModel model;
RANSAC::Solver<YourElementType, YourParamsType> solver(&model, max_iteration);
YourParamsType params = solver.Solve(vector_of_your_elements);

// or
YourParamsType params = solver.Solve(/*input*/ elements, weights, /*output*/ mask, losses);

For a complete example, check the ./examples.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.