OpenCV  4.7.0
Open Source Computer Vision
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
cv::FlannBasedMatcher Class Reference

Flann-based descriptor matcher. More...

#include <opencv2/features2d.hpp>

Inheritance diagram for cv::FlannBasedMatcher:
cv::DescriptorMatcher cv::Algorithm

Public Member Functions

 FlannBasedMatcher (const Ptr< flann::IndexParams > &indexParams=makePtr< flann::KDTreeIndexParams >(), const Ptr< flann::SearchParams > &searchParams=makePtr< flann::SearchParams >())
 
virtual void add (InputArrayOfArrays descriptors) CV_OVERRIDE
 Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection. More...
 
virtual void clear () CV_OVERRIDE
 Clears the train descriptor collections. More...
 
virtual CV_NODISCARD_STD Ptr< DescriptorMatcherclone (bool emptyTrainData=false) const CV_OVERRIDE
 Clones the matcher. More...
 
virtual bool isMaskSupported () const CV_OVERRIDE
 Returns true if the descriptor matcher supports masking permissible matches. More...
 
virtual void read (const FileNode &) CV_OVERRIDE
 Reads algorithm parameters from a file storage. More...
 
virtual void train () CV_OVERRIDE
 Trains a descriptor matcher. More...
 
virtual void write (FileStorage &) const CV_OVERRIDE
 Stores algorithm parameters in a file storage. More...
 
- Public Member Functions inherited from cv::DescriptorMatcher
virtual ~DescriptorMatcher ()
 
virtual bool empty () const CV_OVERRIDE
 Returns true if there are no train descriptors in the both collections. More...
 
const std::vector< Mat > & getTrainDescriptors () const
 Returns a constant link to the train descriptor collection trainDescCollection . More...
 
void knnMatch (InputArray queryDescriptors, InputArray trainDescriptors, 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. More...
 
void knnMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArrayOfArrays masks=noArray(), bool compactResult=false)
 
void match (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< DMatch > &matches, InputArray mask=noArray()) const
 Finds the best match for each descriptor from a query set. More...
 
void match (InputArray queryDescriptors, std::vector< DMatch > &matches, InputArrayOfArrays masks=noArray())
 
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. More...
 
void radiusMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArrayOfArrays masks=noArray(), bool compactResult=false)
 
void read (const String &fileName)
 
void write (const String &fileName) const
 
void write (FileStorage &fs, const String &name) const
 
void write (const Ptr< FileStorage > &fs, const String &name) const
 
- Public Member Functions inherited from cv::Algorithm
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual String getDefaultName () const
 
virtual void save (const String &filename) const
 
void write (FileStorage &fs, const String &name) const
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 

Static Public Member Functions

static Ptr< FlannBasedMatchercreate ()
 
- Static Public Member Functions inherited from cv::DescriptorMatcher
static Ptr< DescriptorMatchercreate (const String &descriptorMatcherType)
 Creates a descriptor matcher of a given type with the default parameters (using default constructor). More...
 
static Ptr< DescriptorMatchercreate (const DescriptorMatcher::MatcherType &matcherType)
 
- Static Public Member Functions inherited from cv::Algorithm
template<typename _Tp >
static Ptr< _Tp > load (const String &filename, const String &objname=String())
 Loads algorithm from the file. More...
 
template<typename _Tp >
static Ptr< _Tp > loadFromString (const String &strModel, const String &objname=String())
 Loads algorithm from a String. More...
 
template<typename _Tp >
static Ptr< _Tp > read (const FileNode &fn)
 Reads algorithm from the file node. More...
 

Protected Member Functions

virtual void knnMatchImpl (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArrayOfArrays masks=noArray(), bool compactResult=false) CV_OVERRIDE
 
virtual void radiusMatchImpl (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArrayOfArrays masks=noArray(), bool compactResult=false) CV_OVERRIDE
 
- Protected Member Functions inherited from cv::DescriptorMatcher
void checkMasks (InputArrayOfArrays masks, int queryDescriptorsCount) const
 
- Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const
 

Static Protected Member Functions

static void convertToDMatches (const DescriptorCollection &descriptors, const Mat &indices, const Mat &distances, std::vector< std::vector< DMatch > > &matches)
 
- Static Protected Member Functions inherited from cv::DescriptorMatcher
static CV_NODISCARD_STD Mat clone_op (Mat m)
 
static bool isMaskedOut (InputArrayOfArrays masks, int queryIdx)
 
static bool isPossibleMatch (InputArray mask, int queryIdx, int trainIdx)
 

Protected Attributes

int addedDescCount
 
Ptr< flann::Index > flannIndex
 
Ptr< flann::IndexParams > indexParams
 
DescriptorCollection mergedDescriptors
 
Ptr< flann::SearchParams > searchParams
 
- Protected Attributes inherited from cv::DescriptorMatcher
std::vector< MattrainDescCollection
 Collection of descriptors from train images. More...
 
std::vector< UMatutrainDescCollection
 

Additional Inherited Members

- Public Types inherited from cv::DescriptorMatcher
enum  MatcherType {
  FLANNBASED = 1,
  BRUTEFORCE = 2,
  BRUTEFORCE_L1 = 3,
  BRUTEFORCE_HAMMING = 4,
  BRUTEFORCE_HAMMINGLUT = 5,
  BRUTEFORCE_SL2 = 6
}
 

Detailed Description

Flann-based descriptor matcher.

This matcher trains cv::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. :

Constructor & Destructor Documentation

◆ FlannBasedMatcher()

cv::FlannBasedMatcher::FlannBasedMatcher ( const Ptr< flann::IndexParams > &  indexParams = makePtr< flann::KDTreeIndexParams >(),
const Ptr< flann::SearchParams > &  searchParams = makePtr< flann::SearchParams >() 
)

Member Function Documentation

◆ add()

virtual void cv::FlannBasedMatcher::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
descriptorsDescriptors to add. Each descriptors[i] is a set of descriptors from the same train image.

Reimplemented from cv::DescriptorMatcher.

◆ clear()

virtual void cv::FlannBasedMatcher::clear ( )
virtual

Clears the train descriptor collections.

Reimplemented from cv::DescriptorMatcher.

◆ clone()

virtual CV_NODISCARD_STD Ptr<DescriptorMatcher> cv::FlannBasedMatcher::clone ( bool  emptyTrainData = false) const
virtual

Clones the matcher.

Parameters
emptyTrainDataIf 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 cv::DescriptorMatcher.

◆ convertToDMatches()

static void cv::FlannBasedMatcher::convertToDMatches ( const DescriptorCollection &  descriptors,
const Mat indices,
const Mat distances,
std::vector< std::vector< DMatch > > &  matches 
)
staticprotected

◆ create()

static Ptr<FlannBasedMatcher> cv::FlannBasedMatcher::create ( )
static
Python:
cv.FlannBasedMatcher.create() -> retval
cv.FlannBasedMatcher_create() -> retval

◆ isMaskSupported()

virtual bool cv::FlannBasedMatcher::isMaskSupported ( ) const
virtual

Returns true if the descriptor matcher supports masking permissible matches.

Implements cv::DescriptorMatcher.

◆ knnMatchImpl()

virtual void cv::FlannBasedMatcher::knnMatchImpl ( InputArray  queryDescriptors,
std::vector< std::vector< DMatch > > &  matches,
int  k,
InputArrayOfArrays  masks = noArray(),
bool  compactResult = false 
)
protectedvirtual

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 cv::DescriptorMatcher.

◆ radiusMatchImpl()

virtual void cv::FlannBasedMatcher::radiusMatchImpl ( InputArray  queryDescriptors,
std::vector< std::vector< DMatch > > &  matches,
float  maxDistance,
InputArrayOfArrays  masks = noArray(),
bool  compactResult = false 
)
protectedvirtual

Implements cv::DescriptorMatcher.

◆ read()

virtual void cv::FlannBasedMatcher::read ( const FileNode fn)
virtual

Reads algorithm parameters from a file storage.

Reimplemented from cv::DescriptorMatcher.

◆ train()

virtual void cv::FlannBasedMatcher::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 cv::DescriptorMatcher.

◆ write()

virtual void cv::FlannBasedMatcher::write ( FileStorage fs) const
virtual

Stores algorithm parameters in a file storage.

Reimplemented from cv::DescriptorMatcher.

Member Data Documentation

◆ addedDescCount

int cv::FlannBasedMatcher::addedDescCount
protected

◆ flannIndex

Ptr<flann::Index> cv::FlannBasedMatcher::flannIndex
protected

◆ indexParams

Ptr<flann::IndexParams> cv::FlannBasedMatcher::indexParams
protected

◆ mergedDescriptors

DescriptorCollection cv::FlannBasedMatcher::mergedDescriptors
protected

◆ searchParams

Ptr<flann::SearchParams> cv::FlannBasedMatcher::searchParams
protected

The documentation for this class was generated from the following file: