Question

In my code I'm filtering the good images based on the nearest neigbour distance ratio, as follows:

for(int i = 0; i < min(des_image.rows-1,(int) matches.size()); i++) 
{
        if((matches[i][0].distance < 0.6*(matches[i][1].distance)) && 
                                  ((int)matches[i].size()<=2 && (int)matches[i].size()>0))
        {
            good_matches.push_back(matches[i][0]);
        }
 }

Since I'm filtering the good images based on the nearest neighbor distance ratio, do I need to still do Euclidean distance calculation?

And I want to know when I use the knnMatch method in FlannBasedMatcher, inside the method do they use the Euclidean distance to match the keypoints?

Était-ce utile?

La solution

Yes, you need. Nearest neigbour distance ratio means that you: 1)Calculate distances from the descriptor in one image to the the 1st and 2nd nearest neighbours in the second image. d1 = d(desc1_img1, descA_img2); d2 = d(desc1_img1, descB_img2). 2)Calculate distance ratio R = d1/d2. If R < 0.6, then match is probably good. It is done because you will always got "nearest" descriptor in the second image, no matter how bad it is - you check it with ratio.

So if you have no distances, from what will you calculate ratio?

Type of distance depends on value you passed when constructed KNN-matcher in normType parameter.

 BFMatcher::BFMatcher(int normType=NORM_L2, bool crossCheck=false )  
  • NORM_L2 means Eucledian d(p1,p2) = sqrt((x1 - x2)^2+(y1 - y2)^2 + ...);
  • NORM_Ll means Manhattan d(p1,p2) = abs(x1 - x2)+abs(y1 - y2) + ..;
  • NORM_HAMMING means Hamming, etc.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top