예제 #1
0
void cvMatch2MyMatch(const DMatchVec& cvMatch , Matching& myMatch) {
	int numMatch = cvMatch.size();
	myMatch.reserve(numMatch);
	for (int i = 0; i < numMatch; i++) {
		myMatch.add(cvMatch[i].queryIdx, cvMatch[i].trainIdx, cvMatch[i].distance);
	}
}
예제 #2
0
// Remove matches for which NN ratio is > than threshold
// return the number of removed points
int RobustMatcher::ratioTest(const DMatchVec2 &matches, DMatchVec &good_matches,
  const KeyPointVec &kpts1, KeyPointVec &kpts1_out,
  const KeyPointVec &kpts2, KeyPointVec &kpts2_out)
{
  for(size_t i = 0; i < matches.size(); i++)
  {
    cv::DMatch first = matches[i][0];
    float dist1 = matches[i][0].distance;
    float dist2 = matches[i][1].distance;

    if(dist1 < nn_match_ratio_ * dist2) {
      kpts1_out.push_back(kpts1[first.queryIdx]);
      kpts2_out.push_back(kpts2[first.trainIdx]);
      good_matches.push_back(first);
    }
  }
  return static_cast<int>(good_matches.size());
}