Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV: RANSAC confidence parameter for finding a homography

The OpenCV function findhomography() finds a homographic transformation between matching points of two images. (See Definition)

For finding matching subsets of points RANSAC can be used.

Here's the catch: In contrast to other function in OpenCV which use RANSAC (e.g. findfundamentalMat (See Definition)) the RANSAC parameter for confidence cannot be changed. Only the reprojection threshold can be passed as an argument.

I looked in the OpenCV source, and for findhomography() the confidence is hardcoded to 0.995.

For my purposes I need to increase this. Is there a way to do this without changing the value in the OpenCV source itself?

Is there a reason why this should be hardcoded?

PS: I added a change request under Ticket 1557 for the next subversion.

like image 483
user834985 Avatar asked Jan 22 '12 12:01

user834985


1 Answers

Well, you are not the first that needs to change harcoded variables or functions in OpenCV. Actually we are changing a lot of OpenCV functions in order to make them faster and more efficient for mobile phones. If you want to change RANSAC, just create a copy of the class with a different name

class  CvModelEstimator2
{

}

in your code, and modify it yourself as you need. You can also change the maxnumber of iterations for RANSAC, the default is very high and makes application really slow.

like image 181
Jav_Rock Avatar answered Nov 15 '22 19:11

Jav_Rock