findHomography, getPerspectiveTransform, & getAffineTransform

Q #1: Right, the findHomography tries to find the best transform between two sets of points. It uses something smarter than least squares, called RANSAC, which has the ability to reject outliers – if at least 50% + 1 of your data points are OK, RANSAC will do its best to find them, and build a reliable transform.

The getPerspectiveTransform has a lot of useful reasons to stay – it is the base for findHomography, and it is useful in many situations where you only have 4 points, and you know they are the correct ones. The findHomography is usually used with sets of points detected automatically – you can find many of them, but with low confidence. getPerspectiveTransform is good when you kn ow for sure 4 corners – like manual marking, or automatic detection of a rectangle.

Q #2 There is no equivalent for affine transforms. You can use findHomography, because affine transforms are a subset of homographies.

Leave a Comment