diff --git a/src/matchers/matcher_base.cpp b/src/matchers/matcher_base.cpp index 2842d8993614d92326b1d26e62a8da49e1ea738f..8ee93a2e2c58eb57f502a87dd5ef98a359d0af0f 100644 --- a/src/matchers/matcher_base.cpp +++ b/src/matchers/matcher_base.cpp @@ -48,15 +48,13 @@ std::vector<Scalar> MatcherBase::match(const cv::Mat& _desc1, const cv::Mat& _de // This conversion is required when using with hamming descriptors outputs // like BRIEF, ORB, FREAK, AKAZE etc if (_desc1.type()!=CV_32F) - { matcher_ = new cv::FlannBasedMatcher(new cv::flann::LshIndexParams(LSH_TABLE_NUM, LSH_KEY_SIZE, LSH_MULTI_PROBE_LEVEL)); - } matcher_->match( _desc1, _desc2, matches, _mask); // here we get only the best match score for (auto m : matches) - normalized_scores.push_back(1.0 - m.distance/(desc_size_bytes*8)); + normalized_scores.push_back(1.0 - m.distance/(desc_size_bytes*8)); } comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC; } @@ -83,7 +81,10 @@ std::vector<Scalar> MatcherBase::match(const cv::Mat& _desc1, const cv::Mat& _de // here we get only the best match score for (auto m : matches) - normalized_scores.push_back(1.0 - m[0].distance/(desc_size_bytes*8)); + if (m.size()>0) + normalized_scores.push_back(1.0 - m[0].distance/(desc_size_bytes*8)); + else + normalized_scores.push_back(0.0); } comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC; } @@ -100,7 +101,10 @@ std::vector<Scalar> MatcherBase::match(const cv::Mat& _desc1, const cv::Mat& _de matcher_->radiusMatch(_desc1, _desc2, matches, 2, _mask); for (auto m : matches) - normalized_scores.push_back(1.0 - m[0].distance/(desc_size_bytes*8)); + if (m.size()>0) + normalized_scores.push_back(1.0 - m[0].distance/(desc_size_bytes*8)); + else + normalized_scores.push_back(0.0); } comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC; }