findFundamentalMat documentation for CV_FM_RANSAC (Bug #2394)
findFundamentalMat documentation says that if method is CV_FM_RANSAC, the number of points should be >= 8.
But this is incoherent with the code : in fundam.cpp, lines 636, there is a check that falls back on LMEDS if N < 15 :
if( (method & ~3) == CV_RANSAC && count >= 15 )
result = estimator.runRANSAC(m1, m2, &_F3x3, tempMask, param1, param2 );
result = estimator.runLMeDS(m1, m2, &_F3x3, tempMask, param2 );
I would consider it a feature. Consider the following facts:
1. Fundamental matrix is computed from at least 7 points (actually, 8 points is needed to get a single fundamental matrix, not 1 or 3).
2. If the ratio of inliers is known to be >=50% then LMEDS method is preferable to RANSAC, since the median (on which we compute the error) will always be an inlier and LMEDS is non-parametric method.
3. When the number of points is <= 14 then there will be always >=50% of inliers by definition.
This theory is proved by practice. We had some problems with the correctness test for cv::findFundamentalMat - sometimes it generated point configurations that fooled RANSAC algorithm. Since we added this hack - use LMEDS when the number of points is small enough, we got rid of those problems.
So, I cancel the ticket. If you have the particular dataset on which findFundamentalMat computes wrong matrix, please, reopen the ticket and supply the dataset.
- Status changed from Open to Cancelled
I agree with your analysis. My point was that the documentation should include your analysis or at least say that even if the user pass method=CV_FM_RANSAC, the system will fallback on LMEDS, regardless of the method parameter.
The documentation should read "CV_FM_RANSAC for the RANSAC algorithm N >= 15" and not the current "CV_FM_RANSAC for the RANSAC algorithm N >= 8".