|
7 | 7 |
|
8 | 8 | #include "SuperPoint.hpp" |
9 | 9 | #include "Utility.hpp" |
| 10 | +#include <opencv2/features2d.hpp> |
10 | 11 |
|
11 | 12 | namespace |
12 | 13 | { |
@@ -49,21 +50,12 @@ int main(int argc, char* argv[]) |
49 | 50 | std::transform(grays.begin(), grays.end(), std::back_inserter(results), |
50 | 51 | [&osh, &dst](const auto& gray) { return processOneFrame(osh, gray, dst.data()); }); |
51 | 52 |
|
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); |
64 | 56 |
|
65 | 57 | 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, |
67 | 59 | cv::Scalar::all(-1), cv::Scalar::all(-1), std::vector<char>(), |
68 | 60 | cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS); |
69 | 61 | cv::imwrite("super_point_good_matches.jpg", matchesImage); |
|
0 commit comments