In the Visual Slam based on feature points, it is often found that mis-matching information is often found in the process of feature matching, which makes the precision of the position and pose of the computation get low and prone to the failure of pose estimation, so it is necessary to eliminate these mismatch points. Often use the RANSAC algorithm to eliminate the 22 matching image of the wrong match point, if only stay in the application level is very simple, call the OPENCV function directly, see the effect, feel good magic, in the end how to achieve ah, has not been too clear, and the image of the blog less, After consulting some information, the author seems to understand a little, I hope that the author's summary will be helpful to your understanding.
First, let's introduce the RANSAC algorithm (random sample consensus the same)
the basic assumptions of the algorithm are:
(1) The data is composed of "insider points", for example: the distribution of data can be explained by some model parameters;
(2) "Outliers" are data that cannot be adapted to the model;
(3) The data in addition is noise.
The reasons for the outliers are: the extreme value of the noise, the method of measuring the error, and the false hypothesis of the data.
algorithm Core:quasi-unity line. It is assumed that the observed data contains an inside point and an outer point, in which the inter-point approximation is passed by a straight line, and the outliers are far away from the line. The simple least squares method can not find the straight line which adapts to the internal point, because the least squares can adapt to all the points including the outliers, instead, the Ransa is able to get a model with only the internal points, and the probability is high enough, but it can't guarantee the result must be correct.
Ransac the goal by repeatedly selecting a set of random subsets in the data. The selected subset is assumed to be an insider, and is validated using the following method:
1. There is a model adapted to the hypothetical insider point, where all the unknown parameters can be calculated from the hypothetical insider points.
2. Use the model obtained in 1 to test all other data, if a point applies to the estimated model, it is considered an insider point.
3. If there are enough points to be classified as hypothetical insider points, then the estimated model is reasonable enough.
4. The model is then re-evaluated with all the hypothetical insider points, as it is only estimated by the initial assumption-points.
5. Finally, the model is evaluated by estimating the error rate of the insider and the model.
This process is repeated for a fixed number of times, and each time the resulting model is either discarded because it is too small, or is chosen better than the existing model.
Advantages of Ransac: can be robust to estimate the model parameters. For example, it can estimate high-precision parameters from a dataset that contains a large number of outliers. Disadvantages of Ransac:there is no upper limit to the number of iterations of the calculation parameters, and if the maximum number of iterations is set, the resulting results may not be optimal and may even result in incorrect results. Ransac only a certain probability to obtain a credible model, the probability is proportional to the number of iterations. Another drawback is that it requires setting the threshold associated with the problem. and RANSAC can only estimate a model from a particular data set, and if there are two (or more) models, RANSAC cannot find another model.
in summary, in a set of data sets that contain outliers, the iterative approach is used to find the parametric model.
The RANSAC algorithm is used to eliminate the principle of image mismatch:
RANSAC algorithm is to find an optimal single-response matrix H, the matrix size is 3*3, the purpose is to find the optimal parameter matrix, so that the number of data points satisfying the matrix is the most, usually , because the single-response matrix has 8 unknown parameters, so need 8 linear equations, corresponding to the point position information, a set of pairs of points can be listed two equations, then at least 4 pairs of matching points are included.
Which represents the corner position of the target image, which is the corner position of the scene image. S is the scale parameter.
The RANSAC algorithm randomly extracts 4 samples from the matching data set and guarantees that the four samples are not collinear. The single-matrix matrix is calculated, and then the model is used to test all the data, and the number of data points and the projection error (that is, the cost function) of the model are calculated, and the corresponding cost function is minimized if the model is the optimal model:
algorithm steps:
- Randomly extracting 4 samples of data from the data set (no collinear between the four samples) calculates the transformation matrix H, which is recorded as Model M:,
- The projection error of all data in the dataset and the model m is calculated, and if the error is less than the threshold, the inner point set I is added ;
- If the number of elements in the current set of points is greater than the optimal inner point set , then update the number of iterations K;
- If the number of iterations is greater than K, exit: Otherwise the number of iterations plus 1, and repeat the above steps
Note: The number of iterations K is constantly updated instead of fixed in cases where the maximum number of iterations is not greater.
Among them,P is the confidence degree, generally take 0.995,W is the proportion of the interior point,m is the minimum number of samples required to calculate the model =4.
The RANSAC algorithm of visual slam to eliminate the principle of image mis-matching