sift特征点直接运用BruteForce方法进行匹配会出现很多错误,因此我们运用最近邻点比次近邻点进行限制,可大大提高特征点匹配的正确率。
即:bestmatch
BFMatcher matcher(NORM_L2, false);
vector<vector<DMatch>> matches2;
vector<DMatch>matches;
matcher.match(descriptors1, descriptors2, matches);
const float ratio = 0.7;
matches.clear();
matcher.knnMatch(descriptors1, descriptors2, matches2, 2);
for (int n = 0; n < matches2.size(); n++)
{
DMatch& bestmatch = matches2[n][0];
DMatch& bettermatch = matches2[n][1];
if (bestmatch.distance < ratio*bettermatch.distance)
{
matches.push_back(bestmatch);
}
}
cout << "match个数:" << matches.size() << endl;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17