Ask Your Question
1

What's the best way to use findHomography

asked 2017-08-25 05:05:42 -0600

lock042 gravatar image

updated 2017-08-25 05:51:34 -0600

Hello everybody. I am trying to use findHomography but I have some issues. Indeed, I have two set of points containing numerous outliers. When I try to apply findHomography to these dataset, the H matrix becomes totally crazy. As I have many outilers I use CV_RANSAC option, but maybe it is not enough ? If I take a look to this code: http://docs.opencv.org/2.4/doc/tutori... I can see that only "probable good matches" are used in the function findHomography. But I thought that was the goal of the RANSAC algorithm ? Am I wrong ? I cannot use the previsous code because I find the point in my own way (each points are in fact stars in astronomical images)

So what I have to do to my datasets before to inject them in findHomography ?

Here two sets of points giving wrong transformation matrix: https://drive.google.com/open?id=0B2y... https://drive.google.com/open?id=0B2y...

EDIT: I forgot to say that line x from the file 1 is not necessary the same point that in line x in the file 2. Maybe this is the problem ? (But I thought that RANSAC was good to get through this). But how I can match them ?

Cheers,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-08-25 07:10:37 -0600

Ziri gravatar image

findHomography allows you to choose CV_LMEDS or CV_RANSAC did you try both ?

for RANSAC you can't choose confidence level parameter and iterations unless you want to modify function source or implement new function.

edit flag offensive delete link more

Comments

Sure I've tested CV_LMEDS and as expected, the result is worst (too much outliers). So the way I use it is good ?

lock042 gravatar imagelock042 ( 2017-08-25 07:23:40 -0600 )edit

How are you detecting those keypoints ?

Ziri gravatar imageZiri ( 2017-08-25 07:30:00 -0600 )edit

These keypoints are stars in astronomical images. So I use my own algorithm. It is working well as I can circle all detected stars.

lock042 gravatar imagelock042 ( 2017-08-25 07:35:06 -0600 )edit

You'll have to tune RANSAC using confidence level parameter. (findHomography python version has ransacReprojThreshold parameter ) or pre-filter data before using RANSAC.
Also , if ordering of points is random you'll get crazy results.

Ziri gravatar imageZiri ( 2017-08-25 07:48:23 -0600 )edit

"EDIT: I forgot to say that line x from the file 1 is not necessary the same point that in line x in the file 2. Maybe this is the problem ? (But I thought that RANSAC was good to get through this). But how I can match them ?" I have to check but I think you are right : srcPoints(i) is matched with dstPoints(i) ->it is the best match. RANSAC won't change matching couple. Why do you need findHomography? Haven't you got image pose ?

LBerger gravatar imageLBerger ( 2017-08-25 07:51:28 -0600 )edit

C++ version has also double ransacReprojThreshold as parameter. By default this is 3. I've already tested with 1 or 0.1 with no sucess. So your last sentence means that ordering points is necessary ? So for now I do not know how I can do and my question is: if I order the 10 best points for example, what is the use of RANSAC algorithm ??? There will be no outliers.

lock042 gravatar imagelock042 ( 2017-08-25 07:55:11 -0600 )edit

outlier means outliers couple. A couple is constructed using a matching procedure. With star I thing you can use color (or grayscale level). Can you post your image? Haven't you got image pose (theta and phi)?

LBerger gravatar imageLBerger ( 2017-08-25 08:08:46 -0600 )edit

@LBerger In fact I search stars in reference image, then I search stars in the second image. I have two lists. I sort these lists by brightness of stars.

But, of course, the order in the two lists can change a bit. Then a stars can be detected in an image while not in the other, etc .... So I want to compare the n reference stars to the other and compute the homography matrix in order to apply the transformation matrix to the second image. At the end, you can stack both.

lock042 gravatar imagelock042 ( 2017-08-25 08:09:37 -0600 )edit

I think you should write your own matching procedure. Takes 20 most bright stars in firrst images. try to match 3 or four stars randomly in second images ( 20 most bright stars too) then check if line between couple intersect or not and if distance between couple is similar. If no intersection try to match more stars using all list and all line must be similar (not exactly of course)

I think this method will fail if there is rotation. have you got rotation?

LBerger gravatar imageLBerger ( 2017-08-25 08:16:56 -0600 )edit

Yes I do have rotation, and sometimes distorsions. So I guess the solution is to use triangle (at least) similarity algorithm before giving list to findHomography.

lock042 gravatar imagelock042 ( 2017-08-25 08:21:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-25 05:05:42 -0600

Seen: 2,720 times

Last updated: Aug 25 '17