findHomography with RANSAC wrong outliering

asked 2012-08-20 17:32:38 -0600

yes123 gravatar image

I am doing some object detection using features2d (ORB, SIFT etc)

I am investigating further into homography with RANSAC. I found out that many good points are marked wrongly as outliers.

For example take this pic, the red circles shows outliers marked by ransac (thresold default at 3)

As you can see there are lots of outliers that shouldn't be outliers inside the object (the book)

I have tried to rise threshold up to 10 but the result is pretty the same. Can I do something to improve this situation?

Is there something broke with RANSAC ?

edit retag flag offensive close merge delete


You ask many questions, but if you do not want to become Captain Obvious you should study by yourself before asking. Actually, posting questions that can easily answered by a Google, Wikipedia or OpenCV docs is strongly discouraged.

sammy gravatar imagesammy ( 2012-08-21 02:31:08 -0600 )edit

@sammy: I have googled lots and read all the documentation about that before posting this, still can't find a reasonable answer. I know RANSAC tries dfferent subset of points to create a good homography, so in this case for RANSAC the best subset discards many good keypoints inside the real object. I read that subsets are choosen random, maybe that's why it discards good keypoints too. Still I believe it's not that good behaviour for RANSAC, don't you think? I am sorry if this question looked obvious for you.

yes123 gravatar imageyes123 ( 2012-08-21 02:43:46 -0600 )edit

As you said, RANSAC looks for a good homography between points. And those points most probably do not fit. Being in the green rectangle does not mean they are correctly matched - it is still a possibility that they are wrong matches, and this is why you use RANSAC for further filtering. It does not guarantee the perfect answer (it is a random algorithm), but it is one of the best available out there.

sammy gravatar imagesammy ( 2012-08-21 02:53:24 -0600 )edit

The problem I am facing is that many times I can't get a good homography because many important keypoints are discarded by RANSAC. Are you aware of any other method I could implement to not discard such good points?

yes123 gravatar imageyes123 ( 2012-08-21 03:15:40 -0600 )edit

How do you know they are good? If you already know which ones are good, select them and use LMEDS, or any other least-mean-squares algorithm to extract the homography. But the main problem is that you cannot know which of them are the good ones, and RANSAC does exactly that - it rejects those who seem good, but are not.

sammy gravatar imagesammy ( 2012-08-21 03:20:47 -0600 )edit

I know they are good when I use drawMatches and I see there is the exact points corrispondence between the train and query image. (the image of the book is the train). For example on the image i posted in my question the points near the flower of the book are NOT outlier because when using drawMatches they have the exact corrispondence within the train image.

yes123 gravatar imageyes123 ( 2012-08-21 03:24:48 -0600 )edit

Take a look at the second pic of this question for a real example of bad outliering:

yes123 gravatar imageyes123 ( 2012-08-21 04:40:46 -0600 )edit