0

I am trying to use the Flann matcher for matching features between images. Following are few lines of code:

vector<MatchesInfo> matches;
Ptr<FlannBasedMatcher> matcher(new flann::LshIndexParams(20, 10, 2));  
matcher.knnMatch(afeatures.descriptors, bfeatures.descriptors, matches, 2);

This generates the following error:

class "cv::Ptr" has no member "knnMatch"

What am I doing wrong?

lazyadt
  • 13
  • 6

2 Answers2

0

Try this:

vector<vector< DMatch >> knnMatches;
FlannBasedMatcher matcher;
matcher.knnMatch(desc1, desc2, knnMatches, 50);

If using KNN would also used Lowe's ratios to determine if distance is appropriate between matches. Also make sure that descriptors are of type CV_32F

C.Radford
  • 882
  • 4
  • 13
  • 31
  • vector > is a matrix, I need the result to be a vector. Also there is no predefined method of converting a matrix of type DMatch to a vector of type MatchesInfo. – lazyadt May 23 '18 at 08:25
0

If you use cv::Ptr, you need to use arrow pointer: ->

But you used dot pointer: .

Change your code as:

matcher->knnMatch(afeatures.descriptors, bfeatures.descriptors, matches, 2);
biruk1230
  • 3,042
  • 4
  • 16
  • 29