Search code examples
image-processingopencvhomography

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.


Solution

  • The reason to be hardcoded is that for the majority of users, this is a very good choice.

    Maybe you were the first to feel the need for something more. But this is why OpenCV is open - take the code, modify it, make a patch and propose it to OpenCV dev team - whatever you like.

    And, are you sure this is what you need? Usually, a tighter reproj threshold will do the trick. If you have problems, they may be somewhere else - some badly chosen points, a too big fit error on point matching, etc.