FlannBasedMatcher没有会员knnMatch

时间:2018-05-18 10:32:11

标签: stl image-stitching flann

我正在尝试使用Flann匹配器来匹配图像之间的功能。以下是几行代码:

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

这会产生以下错误:

  

class“cv :: Ptr”没有成员“knnMatch”

我做错了什么?

2 个答案:

答案 0 :(得分:0)

试试这个:

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

如果使用KNN也会使用Lowe的比率来确定匹配之间的距离是否合适。还要确保描述符的类型为CV_32F

答案 1 :(得分:0)

如果您使用cv::Ptr,则需要使用箭头指针:->

但是您使用了点指针:.

将代码更改为:

matcher->knnMatch(afeatures.descriptors, bfeatures.descriptors, matches, 2);