This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

`findHomography()`

uses RANSAC to compute a transformation matrix.
It iteratively picks 4 random point pairs to compute a homography, then tests, how good it is (classifying other point pairs as inliers/outliers) and chooses the homography with the most inliers. This way it is very robust to outliers (false matches) whereas using all matches for computation would falsify the transformation.

2 | No.2 Revision |

`findHomography()`

uses RANSAC to compute a transformation matrix.
It iteratively picks 4 random point pairs to compute a homography, then tests, how good it is (classifying other point pairs as inliers/outliers) and chooses the homography with the most inliers. This way it is very robust to outliers (false matches) whereas using all matches for computation would falsify the transformation.

**UPDATE**

Ok, here a sort of pseudo code to explain the RANSAC algorithm.

Let's say you have a list of point pairs `matchlist`

, which represent matches between a source and a destination image. Now RANSAC does something like:

```
Homography bestH = null
while (termination criteria not fulfilled)
{
randomly choose 4 matches from matchlist
compute homography H from those 4 matches (-> not overdeterminated)
numInliers = 0
foreach (match m in matchlist)
{
if (m is inlier) numInliers += 1
}
if (numInliers > minNumInliers)
{
if (H better than bestH) bestH = H // H has more inliers than bestH
}
}
```

This is a very simple version, the OpenCV RANSAC algorithm probably is more complex. Termination criteria typically are

maximum number of iterations -> give up, if you don't find a good homography after x iterations

minimum quality of the best homography -> don't unnecessarily perform further iterations, if you already found a good enough homography

I hope, this little example helps for better understanding.

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.