There are two answers to your problem. First, you must use a completely different technique, the second answer is how to do what you asked.
Use another method
You want to find duplicates of the given image. Traditionally, you do this by comparing global image descriptors rather than local function descriptors.
The easiest way to do this is to combine the local function descriptors into a local descriptor. The standard method here is the "bag of visual words." In OpenCV, this is called Bag-Of-Words (e.g. BOWTrainer , BOWImgDescriptorExtractor , etc.). See the documentation for using this.
In samples/cpp/bagofwords_classification.cpp
There is an example code.
The benefits will be that you will get more reliable results (depending on the implementation of what you are doing now), and that the match is faster.
Use your method
I understand that you want to remove points from the input that lead to false positives in your mapping.
You cannot delete points from FLANN ( 1 , 2 , 3 ). FLANN creates a tree for quick searches. Depending on the type of tree, deleting a node becomes impossible. Guess that FLANN uses a KD tree that does not make it easy to delete points.
FlannBasedMatcher does not support masking of valid matches for descriptor sets because the :: Index flange does not support this.
I would suggest using a radius search instead of a simple search. Alternatively, look at the L2 distance of the matches found and write a function in the code to see if the distance falls below the threshold.
Edit
I should also note that you can rebuild your flann-tree. Obviously, when doing this, a performance penalty occurs. But if you have a large number of requests and some functions that occur as false positives, too often, it may make sense to do this once.
To do this, you need the functions DescriptorMatcher::clear() , and then DescriptorMatcher::add(const vector<Mat>& descriptors) . Referenz .