# Revision history [back]

### Too many outliers in findHomography

Hello everyone. I come here because I have some troubles using findHomography. I have to datasets of (x, y) points, one reference and one current. Here the example given by:

std::cout << ReferenceImage_pts << std::endl << ImageToRegister_pts << std::endl;

[1221.7125, 918.77368;
734.95111, 287.90887;
1274.4686, 824.61401;
137.96986, 264.46851;
44.125511, 793.7464;
16.055382, 400.53168;
85.167656, 449.41504;
664.56403, 267.73035;
1135.332, 206.07474;
240.12773, 758.36615]

[1220.592, 917.02393;
733.86157, 286.13693;
1273.3839, 822.82416;
137.79268, 261.71985;
43.028145, 792.05322;
664.46063, 265.02847;
14.848706, 398.8092;
1134.2389, 204.29382;
84.96907, 446.72897;
239.95021, 755.71704]


As you can see, it's very easy to visually match correspondant points. But, when I use findHomography, it only find 6 inliers ... Very far to have a good transformation matrix.

Here the code I use to find H and to change the perspective:

H = findHomography(ReferenceImage_pts, ImageToRegister_pts, CV_RANSAC, 3, outputMask);
warpPerspective(in, out, H.inv(), in.size());


Am I doing something wrong ? In this case I just use 10 points as you can see. However, in fact I have more than 200 points. But if I try to use all the points, it is worst. Only 2% of inliers.

I hope someone could help me. Cheers.

### Too many outliers in findHomography

Hello everyone. I come here because I have some troubles using findHomography. I have to datasets of (x, y) points, one reference and one current. Here the example given by:

std::cout << ReferenceImage_pts << std::endl << ImageToRegister_pts << std::endl;

[1221.7125, 918.77368;
734.95111, 287.90887;
1274.4686, 824.61401;
137.96986, 264.46851;
44.125511, 793.7464;
16.055382, 400.53168;
85.167656, 449.41504;
664.56403, 267.73035;
1135.332, 206.07474;
240.12773, 758.36615]

[1220.592, 917.02393;
733.86157, 286.13693;
1273.3839, 822.82416;
137.79268, 261.71985;
43.028145, 792.05322;
664.46063, 265.02847;
14.848706, 398.8092;
1134.2389, 204.29382;
84.96907, 446.72897;
239.95021, 755.71704]


As you can see, it's very easy to visually match correspondant points. But, when I use findHomography, it only find 6 inliers ... Very far to have a good transformation matrix.

Here the code I use to find H and to change the perspective:

H = findHomography(ReferenceImage_pts, ImageToRegister_pts, CV_RANSAC, 3, outputMask);
warpPerspective(in, out, H.inv(), in.size());


Am I doing something wrong ? In this case I just use 10 points as you can see. However, in fact I have more than 200 points. But if I try to use all the points, it is worst. Only 2% of inliers.

EDIT : What I think: I should try to match points by putting outliers at the end of the set. But I thought findHomography was doing this. I don't understand and I don't know how I can do it.

I hope someone could help me. Cheers.