Ask Your Question

CV findHomography assertion error - counter => 4

asked 2013-01-20 11:13:05 -0500

Mr.Mountain gravatar image

updated 2013-01-23 18:16:37 -0500

Hello, I'm currently finishing my evaluation-tool for interest point detectors. In the last steps I found a confusing error.

Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() )

The srcPoints and dstPoints are vector<points2f> which stores the corresponding points of the matched keypoints. So far nothing special - It's like in the tutorials.

But when I use RANSAC and have a vector<Points2f> in range [0, ... , 4[ I get an assertion error than the counter should be greater or equals four.

Question 1: Does the algorithm needs at least four points to describe what belongs to the current model or not and to create the consensus ?

Question 2: Is there any documentation about this? (I took a look at the doc and the tutorials.)

Thanks for your help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-21 01:53:59 -0500

SR gravatar image

updated 2013-01-21 01:54:58 -0500

  • In all cases: You need at least 4 point correspondences to estimate a perspective tranformation. You can use more than four correspondences and estimate a transformation by least-mean/least-median-of-squares. However, RANSAC (this particular version in OpenCV, not in general) always uses four correspondences and scores the transformation by the size of the concensus set.
  • In case of RANSAC you therefore need > 4 point correspodences to find the concensus set. Otherwise there are no correspondences besides these that have been used to estimate the transformation.
  • I think this is not explicitly mentioned in the documentation but it is described everywhere in RANSAC-related literature. E.g. see Hartley and Zisserman, Multiple View Geometry in Computer Vision for details.
edit flag offensive delete link more


I found out that besides of RANSAC/LHS or something else the estimation of the homography always needs at least four points.

Mr.Mountain gravatar imageMr.Mountain ( 2013-01-23 18:02:12 -0500 )edit

That's why I wrote "In all cases".

SR gravatar imageSR ( 2013-01-24 02:44:51 -0500 )edit

Thank you. =)

Mr.Mountain gravatar imageMr.Mountain ( 2013-02-13 11:19:23 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-01-20 11:13:05 -0500

Seen: 1,125 times

Last updated: Jan 23 '13