Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi! Your question is not entirely clear. But I'll try to answer it.

There are two types of match() methods in DescriptorMatcher interface to match query image descriptors with descriptors of (1) one train image and (2) a set of training images (see doc). The matching_to_many_images is about (2). The example of real usage of (2) is textured object detection, where test image descriptors are matched with all train images descriptors in conjunction, then train images (objects) with a large count of matches are found. BTW FlannBasedMatcher is used for a better performance in such case.

In both cases (1) and (2) you will get matches count equal to query image descriptors number because DescriptorMatcher finds for each query descriptor one nearest train descriptor (among all test images for (2)). So your result with 1001 images is not a bug. If you would like to achieve the same count of matches with each of duplicate images, maybe you shoud use (1) interface with each train image independently. But it's not efficiently in comparison with FlannBasedMatcher trained on all training set of descriptors.

To match training set with query descriptors, ie vice versa, you can use the "quick-and-dirty" solution. I don't see insufficiency of indices if you mean indices of DMatch structure. But if you mean FlannIndex, I agree the "quick-and-dirty" solution is not efficient if your training set is really large and query despriptors number is small.

Then again are you sure that you want to match all training set to query descriptors? Eg if you try to implement a "cross-check" filter of matches, you can match only a small subset of training descriptors that are in matches of direct matching (query to train). Or even better you can think about other filter of matches, eg "ratio check", that don't need to match training set to query desriptors.

Hi! Your question is not entirely clear. But I'll try to answer it.

There are two types of match() methods in DescriptorMatcher interface to match query image descriptors with descriptors of (1) one train image and (2) a set of training images (see doc). The matching_to_many_images is about (2). The example of real usage of (2) is textured object detection, where test image descriptors are matched with all train images descriptors in conjunction, then train images (objects) with a large count of matches are found. BTW FlannBasedMatcher is used for a better performance in such case.

In both cases (1) and (2) you will get matches count equal to query image descriptors number because DescriptorMatcher DescriptorMatcher::match() finds for each query descriptor one nearest train descriptor (among all test images for (2)). So your result with 1001 images is not a bug. If you would like to achieve the same count of matches with each of duplicate images, maybe you shoud use (1) interface with each train image independently. But it's not efficiently in comparison with FlannBasedMatcher trained on all training set of descriptors.

To match training set with query descriptors, ie vice versa, you can use the "quick-and-dirty" solution. I don't see insufficiency of indices if you mean indices of DMatch structure. But if you mean FlannIndex, I agree the "quick-and-dirty" solution is not efficient if your training set is really large and query despriptors number is small.

Then again are you sure that you want to match all training set to query descriptors? Eg if you try to implement a "cross-check" filter of matches, you can match only a small subset of training descriptors that are in matches of direct matching (query to train). Or even better you can think about other filter of matches, eg "ratio check", that don't need to match training set to query desriptors.