Skip to content
Snippets Groups Projects
Commit c4534ef1 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

FIX: add check of matches vector size when quering with KNN and RADIUS

parent e055b224
No related branches found
No related tags found
No related merge requests found
...@@ -48,15 +48,13 @@ std::vector<Scalar> MatcherBase::match(const cv::Mat& _desc1, const cv::Mat& _de ...@@ -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 // This conversion is required when using with hamming descriptors outputs
// like BRIEF, ORB, FREAK, AKAZE etc // like BRIEF, ORB, FREAK, AKAZE etc
if (_desc1.type()!=CV_32F) if (_desc1.type()!=CV_32F)
{
matcher_ = new cv::FlannBasedMatcher(new cv::flann::LshIndexParams(LSH_TABLE_NUM, LSH_KEY_SIZE, LSH_MULTI_PROBE_LEVEL)); matcher_ = new cv::FlannBasedMatcher(new cv::flann::LshIndexParams(LSH_TABLE_NUM, LSH_KEY_SIZE, LSH_MULTI_PROBE_LEVEL));
}
matcher_->match( _desc1, _desc2, matches, _mask); matcher_->match( _desc1, _desc2, matches, _mask);
// here we get only the best match score // here we get only the best match score
for (auto m : matches) 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; 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 ...@@ -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 // here we get only the best match score
for (auto m : matches) 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; 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 ...@@ -100,7 +101,10 @@ std::vector<Scalar> MatcherBase::match(const cv::Mat& _desc1, const cv::Mat& _de
matcher_->radiusMatch(_desc1, _desc2, matches, 2, _mask); matcher_->radiusMatch(_desc1, _desc2, matches, 2, _mask);
for (auto m : matches) 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; comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment