Revision history [back]

Make Descriptor Matcher more discrimatory?

So I've tried out my idea of using cv::BFMatcher to find matches between my custom keypoint descriptors. It works but its not discriminatory enough, meaning it finds too many matches. I think this may be because my keypoint descriptors are too simple and only contain 6 unique numbers. But I am wondering if there is a setting or something in the cv::DescriptorMatcher or cv::BFMatcher or cv::FlannMatcher that will make it more 'discriminatory', ie, make it be more strict about what constitutes a match?

Below is my code and the image I am working with. The green cell is a keypoint descriptor (I have calculated the mean intensity, magnitude and direction across this cell (same for std deviation) and those 6 numbers become the keypoint/cell descriptor). The red rectangle bounds the 8 other cells I am looking for matches, so 8 other keypoint/cell descriptors. When I run my code, I get 6 matches back. I am hoping for 1 or 2 matches and I'm hoping for the cell right adjacent to the green cell to be identified as a match.

Any advice if I could make the descriptor matcher for discriminatory?

void matchCustomDescriptors() {

Mat descriptors1({
174.483f, 19.170f, 12.503f, 10.454f, -81.230f, 0.003765f
});
descriptors1.reshape(1, 1);

Mat descriptors2({
137.942f, 24.953f, 31.512f, 27.309f, -69.655f, 0.000575f, // corresponds to the top left cell of the red rectangle

133.888f, 14.031f, 18.080f, 13.974f, -114.655f, 0.00191f, // corresponds to the cell above of the green cell

165.547f, 36.802f, 19.982f, 34.661f, 28.909f, 0.000625f, // corresponds to the top right cell of the red rectangle

188.496f, 19.021f, 10.202f, 8.445f, -78.267f, 0.005702f, // continue clockwise

192.788f, 23.360f, 14.752f, 20.407f, 89.840f, 0.001577f,

182.088f, 29.258f, 17.928f, 28.822f, 74.453f, 0.000868f,

161.119f, 34.396f, 19.787f, 22.862f, 91.313f, 0.001094f,

159.954f, 17.733f, 14.422f, 11.519f, -83.997f, 0.002935f
});
descriptors2.reshape(1, 8);

cv::BFMatcher matcher(NORM_L2, true);
std::vector<cv::DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);

printf("Matches: %u\n", matches.size());  // I get 6 matches when I'd really like only 1 or 2
}