ransac_tutorial

This is the tutorial for the RANSAC algorithm taught at the Technische Hochschule Ingolstadt, in the course of mobile robotics. The script generate_data.m provides a data set, containing a circle and a line pattern, including additional noise.

dataset image

The principle of the RANSAC is summarized by the following steps:

  1. Select a random subset of the original data. Call this subset the hypothetical inliers.
  2. A model is fitted to the set of potential inliers
  3. The complete data is then tested against the fitted model. Those points that fit the estimated model well, according to some model-specific loss function, are considered as part of the consensus set.
  4. The estimated model is reasonably good if sufficiently many points have been classified as part of the consensus set.
  5. Afterwards, the model may be improved by reestimating it using all members of the consensus set, by applying the least square approach.







Search for the line model

Use the existing template to write the RANSAC algorithm to find the line.

Use the highlighted placeholders to add your code to complete the algorithm.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        ADD YOUR CODE HERE          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Have a close look in the code and its comments, which provide extra help for the implementation.

Two points are necessary to calculate the model for a randomly selected set of points. You can use the known equation, but there is a much simpler solution to this.

image

Your solution should lead to a similar result like the following figure.

image







Search for the circle model

If you finished the first task, extend your approach, so the circle is found.

The equation for a circle is described by the error term in the least square approach via: image

Based on partial derivative the error term can be solved. The result are the following equations,

$$A = B \cdot u$$

image

which form a linear equation system; here presented as matrices.

image

Finally, the circles radius can be calculated where

image

The solution of the RANSAC for the circle should look similar to the following figure.

image







Helpful links to ease programmin in matlab