![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
opencv on mbed
FlannBasedMatcher Class Reference
[Descriptor Matchers]
Flann-based descriptor matcher. More...
#include <features2d.hpp>
Inherits cv::DescriptorMatcher.
Public Member Functions | |
virtual void | add (InputArrayOfArrays descriptors) |
Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection. | |
virtual void | clear () |
Clears the train descriptor collections. | |
virtual void | read (const FileNode &) |
Reads algorithm parameters from a file storage. | |
virtual void | write (FileStorage &) const |
Stores algorithm parameters in a file storage. | |
virtual void | train () |
Trains a descriptor matcher. | |
virtual bool | isMaskSupported () const |
Returns true if the descriptor matcher supports masking permissible matches. | |
virtual Ptr< DescriptorMatcher > | clone (bool emptyTrainData=false) const |
Clones the matcher. | |
CV_WRAP const std::vector< Mat > & | getTrainDescriptors () const |
Returns a constant link to the train descriptor collection trainDescCollection . | |
virtual CV_WRAP bool | empty () const |
Returns true if there are no train descriptors in the both collections. | |
CV_WRAP void | match (InputArray queryDescriptors, InputArray trainDescriptors, CV_OUT std::vector< DMatch > &matches, InputArray mask=noArray()) const |
Finds the best match for each descriptor from a query set. | |
CV_WRAP void | match (InputArray queryDescriptors, CV_OUT std::vector< DMatch > &matches, InputArrayOfArrays masks=noArray()) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
CV_WRAP void | knnMatch (InputArray queryDescriptors, InputArray trainDescriptors, CV_OUT std::vector< std::vector< DMatch > > &matches, int k, InputArray mask=noArray(), bool compactResult=false) const |
Finds the k best matches for each descriptor from a query set. | |
CV_WRAP void | knnMatch (InputArray queryDescriptors, CV_OUT std::vector< std::vector< DMatch > > &matches, int k, InputArrayOfArrays masks=noArray(), bool compactResult=false) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | radiusMatch (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArray mask=noArray(), bool compactResult=false) const |
For each query descriptor, finds the training descriptors not farther than the specified distance. | |
void | radiusMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArrayOfArrays masks=noArray(), bool compactResult=false) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
virtual CV_WRAP void | save (const String &filename) const |
Saves the algorithm to a file. | |
virtual CV_WRAP String | getDefaultName () const |
Returns the algorithm string identifier. | |
Static Public Member Functions | |
static CV_WRAP Ptr < DescriptorMatcher > | create (const String &descriptorMatcherType) |
Creates a descriptor matcher of a given type with the default parameters (using default constructor). | |
template<typename _Tp > | |
static Ptr< _Tp > | load (const String &filename, const String &objname=String()) |
Loads algorithm from the file. | |
template<typename _Tp > | |
static Ptr< _Tp > | loadFromString (const String &strModel, const String &objname=String()) |
Loads algorithm from a String. | |
Protected Member Functions | |
virtual void | knnMatchImpl (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArrayOfArrays masks=noArray(), bool compactResult=false) |
In fact the matching is implemented only by the following two methods. | |
Protected Attributes | |
std::vector< Mat > | trainDescCollection |
Collection of descriptors from train images. |
Detailed Description
Flann-based descriptor matcher.
This matcher trains flann::Index_ on a train descriptor collection and calls its nearest search methods to find the best matches. So, this matcher may be faster when matching a large train collection than the brute force matcher. FlannBasedMatcher does not support masking permissible matches of descriptor sets because flann::Index does not support this. :
Definition at line 1030 of file features2d.hpp.
Member Function Documentation
virtual void add | ( | InputArrayOfArrays | descriptors ) | [virtual] |
Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection.
If the collection is not empty, the new descriptors are added to existing train descriptors.
- Parameters:
-
descriptors Descriptors to add. Each descriptors[i] is a set of descriptors from the same train image.
Reimplemented from DescriptorMatcher.
virtual void clear | ( | ) | [virtual] |
Clears the train descriptor collections.
Reimplemented from DescriptorMatcher.
virtual Ptr<DescriptorMatcher> clone | ( | bool | emptyTrainData = false ) |
const [virtual] |
Clones the matcher.
- Parameters:
-
emptyTrainData If emptyTrainData is false, the method creates a deep copy of the object, that is, copies both parameters and train data. If emptyTrainData is true, the method creates an object copy with the current parameters but with empty train data.
Implements DescriptorMatcher.
static CV_WRAP Ptr<DescriptorMatcher> create | ( | const String & | descriptorMatcherType ) | [static, inherited] |
Creates a descriptor matcher of a given type with the default parameters (using default constructor).
- Parameters:
-
descriptorMatcherType Descriptor matcher type. Now the following matcher types are supported: - `BruteForce` (it uses L2 )
- `BruteForce-L1`
- `BruteForce-Hamming`
- `BruteForce-Hamming(2)`
- `FlannBased`
virtual CV_WRAP bool empty | ( | ) | const [virtual, inherited] |
Returns true if there are no train descriptors in the both collections.
Reimplemented from Algorithm.
virtual CV_WRAP String getDefaultName | ( | ) | const [virtual, inherited] |
Returns the algorithm string identifier.
This string is used as top level xml/yml node tag when the object is saved to a file or string.
CV_WRAP const std::vector<Mat>& getTrainDescriptors | ( | ) | const [inherited] |
Returns a constant link to the train descriptor collection trainDescCollection .
virtual bool isMaskSupported | ( | ) | const [virtual] |
Returns true if the descriptor matcher supports masking permissible matches.
Implements DescriptorMatcher.
CV_WRAP void knnMatch | ( | InputArray | queryDescriptors, |
CV_OUT std::vector< std::vector< DMatch > > & | matches, | ||
int | k, | ||
InputArrayOfArrays | masks = noArray() , |
||
bool | compactResult = false |
||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
queryDescriptors Query set of descriptors. matches Matches. Each matches[i] is k or less matches for the same query descriptor. k Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total. masks Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i]. compactResult Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
CV_WRAP void knnMatch | ( | InputArray | queryDescriptors, |
InputArray | trainDescriptors, | ||
CV_OUT std::vector< std::vector< DMatch > > & | matches, | ||
int | k, | ||
InputArray | mask = noArray() , |
||
bool | compactResult = false |
||
) | const [inherited] |
Finds the k best matches for each descriptor from a query set.
- Parameters:
-
queryDescriptors Query set of descriptors. trainDescriptors Train set of descriptors. This set is not added to the train descriptors collection stored in the class object. mask Mask specifying permissible matches between an input query and train matrices of descriptors. matches Matches. Each matches[i] is k or less matches for the same query descriptor. k Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total. compactResult Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
These extended variants of DescriptorMatcher::match methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match for the details about query and train descriptors.
virtual void knnMatchImpl | ( | InputArray | queryDescriptors, |
std::vector< std::vector< DMatch > > & | matches, | ||
int | k, | ||
InputArrayOfArrays | masks = noArray() , |
||
bool | compactResult = false |
||
) | [protected, virtual] |
In fact the matching is implemented only by the following two methods.
These methods suppose that the class object has been trained already. Public match methods call these methods after calling train().
Implements DescriptorMatcher.
static Ptr<_Tp> load | ( | const String & | filename, |
const String & | objname = String() |
||
) | [static, inherited] |
Loads algorithm from the file.
- Parameters:
-
filename Name of the file to read. objname The optional name of the node to read (if empty, the first top-level node will be used)
This is static template method of Algorithm. It's usage is following (in the case of SVM):
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
In order to make this method work, the derived class must overwrite Algorithm::read(const FileNode& fn).
static Ptr<_Tp> loadFromString | ( | const String & | strModel, |
const String & | objname = String() |
||
) | [static, inherited] |
Loads algorithm from a String.
- Parameters:
-
strModel The string variable containing the model you want to load. objname The optional name of the node to read (if empty, the first top-level node will be used)
This is static template method of Algorithm. It's usage is following (in the case of SVM):
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
CV_WRAP void match | ( | InputArray | queryDescriptors, |
InputArray | trainDescriptors, | ||
CV_OUT std::vector< DMatch > & | matches, | ||
InputArray | mask = noArray() |
||
) | const [inherited] |
Finds the best match for each descriptor from a query set.
- Parameters:
-
queryDescriptors Query set of descriptors. trainDescriptors Train set of descriptors. This set is not added to the train descriptors collection stored in the class object. matches Matches. If a query descriptor is masked out in mask , no match is added for this descriptor. So, matches size may be smaller than the query descriptors count. mask Mask specifying permissible matches between an input query and train matrices of descriptors.
In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at<uchar>(i,j) is non-zero.
CV_WRAP void match | ( | InputArray | queryDescriptors, |
CV_OUT std::vector< DMatch > & | matches, | ||
InputArrayOfArrays | masks = noArray() |
||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
queryDescriptors Query set of descriptors. matches Matches. If a query descriptor is masked out in mask , no match is added for this descriptor. So, matches size may be smaller than the query descriptors count. masks Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].
void radiusMatch | ( | InputArray | queryDescriptors, |
InputArray | trainDescriptors, | ||
std::vector< std::vector< DMatch > > & | matches, | ||
float | maxDistance, | ||
InputArray | mask = noArray() , |
||
bool | compactResult = false |
||
) | const [inherited] |
For each query descriptor, finds the training descriptors not farther than the specified distance.
- Parameters:
-
queryDescriptors Query set of descriptors. trainDescriptors Train set of descriptors. This set is not added to the train descriptors collection stored in the class object. matches Found matches. compactResult Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors. maxDistance Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)! mask Mask specifying permissible matches between an input query and train matrices of descriptors.
For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.
void radiusMatch | ( | InputArray | queryDescriptors, |
std::vector< std::vector< DMatch > > & | matches, | ||
float | maxDistance, | ||
InputArrayOfArrays | masks = noArray() , |
||
bool | compactResult = false |
||
) | [inherited] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
-
queryDescriptors Query set of descriptors. matches Found matches. maxDistance Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)! masks Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i]. compactResult Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
virtual void read | ( | const FileNode & | fn ) | [virtual] |
Reads algorithm parameters from a file storage.
Reimplemented from DescriptorMatcher.
virtual CV_WRAP void save | ( | const String & | filename ) | const [virtual, inherited] |
Saves the algorithm to a file.
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
virtual void train | ( | ) | [virtual] |
Trains a descriptor matcher.
Trains a descriptor matcher (for example, the flann index). In all methods to match, the method train() is run every time before matching. Some descriptor matchers (for example, BruteForceMatcher) have an empty implementation of this method. Other matchers really train their inner structures (for example, FlannBasedMatcher trains flann::Index ).
Reimplemented from DescriptorMatcher.
virtual void write | ( | FileStorage & | fs ) | const [virtual] |
Stores algorithm parameters in a file storage.
Reimplemented from DescriptorMatcher.
Field Documentation
std::vector<Mat> trainDescCollection [protected, inherited] |
Collection of descriptors from train images.
Definition at line 980 of file features2d.hpp.
Generated on Tue Jul 12 2022 16:42:44 by
![doxygen](doxygen.png)