Hi,
I have a vector of matches (vector<DMatch>
) in which are multiple same matches. Now I want to get the best (so the match with the most occurences) out of this vector.
For understanding:
I calculate a Fundamental matrix a lot of times for the same image pair but the calculation is everytime slightly different. I always save the best matches (most of the times: 7 per iteration) in my vector<DMatch>
. Here is the code snippet:
vector<DMatch> all_inlier_matches;
// This part is in a for loop with several iterations
vector<DMatch> good_matches, good_matches_2, sym_matches;
BFMatcher matcher;
vector<DMatch> matches, matches_2;
float ratio_Lowe, ratio_Lowe_2;
BruteForceMatching(descriptors_1, descriptors_2, good_matches, matches, ratio_Lowe);
BruteForceMatching(descriptors_2, descriptors_1, good_matches_2, matches_2, ratio_Lowe_2);
symmetryTest(matches, matches_2, sym_matches); // Calculation of the best matches
for (size_t i = 0; i < sym_matches.size(); i++) {
all_inlier_matches.push_back(sym_matches[i]); // Push_back ~seven matches per iteration;
}
Now I want the best of my best matches, so the matches which occur for example more than 5 times. So what is the structure of a DMatch, how can I compare them to each other and how can I count same occurences? I read something about counting in a vector with unordered map but I can hardly understand it.