Skip to content

Commit 89acb2e

Browse files
committed
use crosscheck instead of lowe ratio test
1 parent 344c387 commit 89acb2e

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

examples/SuperGlueApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ int main(int argc, char* argv[])
125125
cv::drawMatches(images[0], superPointResults[0].first, images[1], superPointResults[1].first, goodMatches,
126126
matchesImage, cv::Scalar::all(-1), cv::Scalar::all(-1), std::vector<char>(),
127127
cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
128-
cv::imwrite("super_point_good_matches.jpg", matchesImage);
129-
cv::imshow("super_point_good_matches", matchesImage);
128+
cv::imwrite("super_point_super_glue_good_matches.jpg", matchesImage);
129+
cv::imshow("super_point_super_glue_good_matches", matchesImage);
130130
cv::waitKey();
131131

132132
return EXIT_SUCCESS;

examples/SuperPointApp.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "SuperPoint.hpp"
99
#include "Utility.hpp"
10+
#include <opencv2/features2d.hpp>
1011

1112
namespace
1213
{
@@ -49,21 +50,12 @@ int main(int argc, char* argv[])
4950
std::transform(grays.begin(), grays.end(), std::back_inserter(results),
5051
[&osh, &dst](const auto& gray) { return processOneFrame(osh, gray, dst.data()); });
5152

52-
cv::Ptr<cv::DescriptorMatcher> matcher = cv::DescriptorMatcher::create(cv::DescriptorMatcher::FLANNBASED);
53-
std::vector<std::vector<cv::DMatch>> knnMatches;
54-
const int numMatch = 2;
55-
matcher->knnMatch(results[0].second, results[1].second, knnMatches, numMatch);
56-
57-
std::vector<cv::DMatch> goodMatches;
58-
const float loweRatioThresh = 0.8;
59-
for (const auto& match : knnMatches) {
60-
if (match[0].distance < loweRatioThresh * match[1].distance) {
61-
goodMatches.emplace_back(match[0]);
62-
}
63-
}
53+
cv::BFMatcher matcher(cv::NORM_L2, true /* crossCheck */);
54+
std::vector<cv::DMatch> knnMatches;
55+
matcher.match(results[0].second, results[1].second, knnMatches);
6456

6557
cv::Mat matchesImage;
66-
cv::drawMatches(images[0], results[0].first, images[1], results[1].first, goodMatches, matchesImage,
58+
cv::drawMatches(images[0], results[0].first, images[1], results[1].first, knnMatches, matchesImage,
6759
cv::Scalar::all(-1), cv::Scalar::all(-1), std::vector<char>(),
6860
cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
6961
cv::imwrite("super_point_good_matches.jpg", matchesImage);

0 commit comments

Comments
 (0)