Skip to content
Snippets Groups Projects
Commit 6c07df30 authored by Angel Santamaria-Navarro's avatar Angel Santamaria-Navarro
Browse files

Add nnSymmetryTest. No gtest yet

parent 64b06297
No related branches found
No related tags found
No related merge requests found
......@@ -308,6 +308,32 @@ void MatcherBase::ransacTest(const KeyPointVector& _raw_kps1,
}
}
void MatcherBase::nnSymmetryTest(const std::vector<DMatchVector>& _matches1,
const std::vector<DMatchVector>& _matches2,
DMatchVector& _sym_matches)
{
// for all matches image 1 -> image 2
for (std::vector<DMatchVector>::const_iterator itM1 = _matches1.begin(); itM1 != _matches1.end(); ++itM1)
{
if (itM1->size() < 2) // ignore deleted matches
continue;
// for all matches image 2 -> image 1
for (std::vector<DMatchVector>::const_iterator itM2 = _matches2.begin(); itM2 != _matches2.end(); ++itM2)
{
if (itM2->size() < 2) // ignore deleted matches
continue;
// Match symmetry test
if ((*itM1)[0].queryIdx == (*itM2)[0].trainIdx && (*itM2)[0].queryIdx == (*itM1)[0].trainIdx)
{
// add symmetrical match
_sym_matches.push_back(cv::DMatch((*itM1)[0].queryIdx, (*itM1)[0].trainIdx, (*itM1)[0].distance));
break; // next match in image 1 -> image 2
}
}
}
}
cv::Mat MatcherBase::drawMatches(const cv::Mat _img1, const cv::Mat _img2, KeyPointVector _kpts12_img1, KeyPointVector _kpts12_img2)
{
......
......@@ -134,6 +134,11 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
KeyPointVector& _inlier_kps2,
DMatchVector& _inlier_matches);
// Check symmetry between nn matches from <im1->im2> and from <im2->im1> pairs
void nnSymmetryTest(const std::vector<DMatchVector>& _matches1,
const std::vector<DMatchVector>& _matches2,
DMatchVector& _sym_matches);
// Factory method
static MatcherBasePtr create(const std::string& _unique_name,
const ParamsBasePtr _params);
......
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