OpenCV  3.2.0-dev
Open Source Computer Vision

Abstract base class for matching keypoint descriptors. More...

#include "cudafeatures2d.hpp"

Inheritance diagram for cv::cuda::DescriptorMatcher:
Collaboration diagram for cv::cuda::DescriptorMatcher:

Public Member Functions

virtual void add (const std::vector< GpuMat > &descriptors)=0
 Adds descriptors to train a descriptor collection. More...
 
virtual void clear ()=0
 Clears the train descriptor collection. More...
 
virtual bool empty () const =0
 Returns true if there are no train descriptors in the collection. More...
 
virtual String getDefaultName () const
 Returns the algorithm string identifier. More...
 
virtual const std::vector< GpuMat > & getTrainDescriptors () const =0
 Returns a constant link to the train descriptor collection. More...
 
virtual bool isMaskSupported () const =0
 Returns true if the descriptor matcher supports masking permissible matches. More...
 
virtual void knnMatch (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArray mask=noArray(), bool compactResult=false)=0
 Finds the k best matches for each descriptor from a query set (blocking version). More...
 
virtual void knnMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, const std::vector< GpuMat > &masks=std::vector< GpuMat >(), bool compactResult=false)=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void knnMatchAsync (InputArray queryDescriptors, InputArray trainDescriptors, OutputArray matches, int k, InputArray mask=noArray(), Stream &stream=Stream::Null())=0
 Finds the k best matches for each descriptor from a query set (asynchronous version). More...
 
virtual void knnMatchAsync (InputArray queryDescriptors, OutputArray matches, int k, const std::vector< GpuMat > &masks=std::vector< GpuMat >(), Stream &stream=Stream::Null())=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void knnMatchConvert (InputArray gpu_matches, std::vector< std::vector< DMatch > > &matches, bool compactResult=false)=0
 Converts matches array from internal representation to standard matches vector. More...
 
virtual void match (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< DMatch > &matches, InputArray mask=noArray())=0
 Finds the best match for each descriptor from a query set (blocking version). More...
 
virtual void match (InputArray queryDescriptors, std::vector< DMatch > &matches, const std::vector< GpuMat > &masks=std::vector< GpuMat >())=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void matchAsync (InputArray queryDescriptors, InputArray trainDescriptors, OutputArray matches, InputArray mask=noArray(), Stream &stream=Stream::Null())=0
 Finds the best match for each descriptor from a query set (asynchronous version). More...
 
virtual void matchAsync (InputArray queryDescriptors, OutputArray matches, const std::vector< GpuMat > &masks=std::vector< GpuMat >(), Stream &stream=Stream::Null())=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void matchConvert (InputArray gpu_matches, std::vector< DMatch > &matches)=0
 Converts matches array from internal representation to standard matches vector. More...
 
virtual void radiusMatch (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArray mask=noArray(), bool compactResult=false)=0
 For each query descriptor, finds the training descriptors not farther than the specified distance (blocking version). More...
 
virtual void radiusMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, const std::vector< GpuMat > &masks=std::vector< GpuMat >(), bool compactResult=false)=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void radiusMatchAsync (InputArray queryDescriptors, InputArray trainDescriptors, OutputArray matches, float maxDistance, InputArray mask=noArray(), Stream &stream=Stream::Null())=0
 For each query descriptor, finds the training descriptors not farther than the specified distance (asynchronous version). More...
 
virtual void radiusMatchAsync (InputArray queryDescriptors, OutputArray matches, float maxDistance, const std::vector< GpuMat > &masks=std::vector< GpuMat >(), Stream &stream=Stream::Null())=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual void radiusMatchConvert (InputArray gpu_matches, std::vector< std::vector< DMatch > > &matches, bool compactResult=false)=0
 Converts matches array from internal representation to standard matches vector. More...
 
virtual void read (const FileNode &fn)
 Reads algorithm parameters from a file storage. More...
 
virtual void save (const String &filename) const
 Saves the algorithm to a file. More...
 
virtual void train ()=0
 Trains a descriptor matcher. More...
 
virtual void write (FileStorage &fs) const
 Stores algorithm parameters in a file storage. More...
 

Static Public Member Functions

static Ptr< DescriptorMatchercreateBFMatcher (int normType=cv::NORM_L2)
 Brute-force descriptor matcher. More...
 
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

void writeFormat (FileStorage &fs) const
 

Detailed Description

Abstract base class for matching keypoint descriptors.

It has two groups of match methods: for matching descriptors of an image with another image or with an image set.

Member Function Documentation

virtual void cv::cuda::DescriptorMatcher::add ( const std::vector< GpuMat > &  descriptors)
pure virtual

Adds descriptors to train a 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.
virtual void cv::cuda::DescriptorMatcher::clear ( )
pure virtual

Clears the train descriptor collection.

Reimplemented from cv::Algorithm.

static Ptr<DescriptorMatcher> cv::cuda::DescriptorMatcher::createBFMatcher ( int  normType = cv::NORM_L2)
static

Brute-force descriptor matcher.

For each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each one. This descriptor matcher supports masking permissible matches of descriptor sets.

Parameters
normTypeOne of NORM_L1, NORM_L2, NORM_HAMMING. L1 and L2 norms are preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and BRIEF).
virtual bool cv::cuda::DescriptorMatcher::empty ( ) const
pure virtual

Returns true if there are no train descriptors in the collection.

Reimplemented from cv::Algorithm.

virtual String cv::Algorithm::getDefaultName ( ) const
virtualinherited

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.

virtual const std::vector<GpuMat>& cv::cuda::DescriptorMatcher::getTrainDescriptors ( ) const
pure virtual

Returns a constant link to the train descriptor collection.

virtual bool cv::cuda::DescriptorMatcher::isMaskSupported ( ) const
pure virtual

Returns true if the descriptor matcher supports masking permissible matches.

virtual void cv::cuda::DescriptorMatcher::knnMatch ( InputArray  queryDescriptors,
InputArray  trainDescriptors,
std::vector< std::vector< DMatch > > &  matches,
int  k,
InputArray  mask = noArray(),
bool  compactResult = false 
)
pure virtual

Finds the k best matches for each descriptor from a query set (blocking version).

Parameters
queryDescriptorsQuery set of descriptors.
trainDescriptorsTrain set of descriptors. This set is not added to the train descriptors collection stored in the class object.
matchesMatches. Each matches[i] is k or less matches for the same query descriptor.
kCount of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
maskMask specifying permissible matches between an input query and train matrices of descriptors.
compactResultParameter 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 cv::cuda::DescriptorMatcher::knnMatch ( InputArray  queryDescriptors,
std::vector< std::vector< DMatch > > &  matches,
int  k,
const std::vector< GpuMat > &  masks = std::vector< GpuMat >(),
bool  compactResult = false 
)
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void cv::cuda::DescriptorMatcher::knnMatchAsync ( InputArray  queryDescriptors,
InputArray  trainDescriptors,
OutputArray  matches,
int  k,
InputArray  mask = noArray(),
Stream stream = Stream::Null() 
)
pure virtual

Finds the k best matches for each descriptor from a query set (asynchronous version).

Parameters
queryDescriptorsQuery set of descriptors.
trainDescriptorsTrain set of descriptors. This set is not added to the train descriptors collection stored in the class object.
matchesMatches array stored in GPU memory. Internal representation is not defined. Use DescriptorMatcher::knnMatchConvert method to retrieve results in standard representation.
kCount of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
maskMask specifying permissible matches between an input query and train matrices of descriptors.
streamCUDA stream.

These extended variants of DescriptorMatcher::matchAsync methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::matchAsync for the details about query and train descriptors.

virtual void cv::cuda::DescriptorMatcher::knnMatchAsync ( InputArray  queryDescriptors,
OutputArray  matches,
int  k,
const std::vector< GpuMat > &  masks = std::vector< GpuMat >(),
Stream stream = Stream::Null() 
)
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void cv::cuda::DescriptorMatcher::knnMatchConvert ( InputArray  gpu_matches,
std::vector< std::vector< DMatch > > &  matches,
bool  compactResult = false 
)
pure virtual

Converts matches array from internal representation to standard matches vector.

The method is supposed to be used with DescriptorMatcher::knnMatchAsync to get final result. Call this method only after DescriptorMatcher::knnMatchAsync is completed (ie. after synchronization).

Parameters
gpu_matchesMatches, returned from DescriptorMatcher::knnMatchAsync.
matchesVector of DMatch objects.
compactResultParameter 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.
template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::load ( const String filename,
const String objname = String() 
)
inlinestaticinherited

Loads algorithm from the file.

Parameters
filenameName of the file to read.
objnameThe 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).

References cv::Ptr< T >::empty(), cv::FileNode::empty(), cv::FileStorage::getFirstTopLevelNode(), and cv::FileStorage::READ.

Here is the call graph for this function:

template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::loadFromString ( const String strModel,
const String objname = String() 
)
inlinestaticinherited

Loads algorithm from a String.

Parameters
strModelThe string variable containing the model you want to load.
objnameThe 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);

References CV_WRAP, cv::Ptr< T >::empty(), cv::FileNode::empty(), cv::FileStorage::getFirstTopLevelNode(), cv::FileStorage::MEMORY, and cv::FileStorage::READ.

Here is the call graph for this function:

virtual void cv::cuda::DescriptorMatcher::match ( InputArray  queryDescriptors,
InputArray  trainDescriptors,
std::vector< DMatch > &  matches,
InputArray  mask = noArray() 
)
pure virtual

Finds the best match for each descriptor from a query set (blocking version).

Parameters
queryDescriptorsQuery set of descriptors.
trainDescriptorsTrain set of descriptors. This set is not added to the train descriptors collection stored in the class object.
matchesMatches. 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.
maskMask 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.

virtual void cv::cuda::DescriptorMatcher::match ( InputArray  queryDescriptors,
std::vector< DMatch > &  matches,
const std::vector< GpuMat > &  masks = std::vector< GpuMat >() 
)
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void cv::cuda::DescriptorMatcher::matchAsync ( InputArray  queryDescriptors,
InputArray  trainDescriptors,
OutputArray  matches,
InputArray  mask = noArray(),
Stream stream = Stream::Null() 
)
pure virtual

Finds the best match for each descriptor from a query set (asynchronous version).

Parameters
queryDescriptorsQuery set of descriptors.
trainDescriptorsTrain set of descriptors. This set is not added to the train descriptors collection stored in the class object.
matchesMatches array stored in GPU memory. Internal representation is not defined. Use DescriptorMatcher::matchConvert method to retrieve results in standard representation.
maskMask specifying permissible matches between an input query and train matrices of descriptors.
streamCUDA stream.

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.

virtual void cv::cuda::DescriptorMatcher::matchAsync ( InputArray  queryDescriptors,
OutputArray  matches,
const std::vector< GpuMat > &  masks = std::vector< GpuMat >(),
Stream stream = Stream::Null() 
)
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void cv::cuda::DescriptorMatcher::matchConvert ( InputArray  gpu_matches,
std::vector< DMatch > &  matches 
)
pure virtual

Converts matches array from internal representation to standard matches vector.

The method is supposed to be used with DescriptorMatcher::matchAsync to get final result. Call this method only after DescriptorMatcher::matchAsync is completed (ie. after synchronization).

Parameters
gpu_matchesMatches, returned from DescriptorMatcher::matchAsync.
matchesVector of DMatch objects.
virtual void cv::cuda::DescriptorMatcher::radiusMatch ( InputArray  queryDescriptors,
InputArray  trainDescriptors,
std::vector< std::vector< DMatch > > &  matches,
float  maxDistance,
InputArray  mask = noArray(),
bool  compactResult = false 
)
pure virtual

For each query descriptor, finds the training descriptors not farther than the specified distance (blocking version).

Parameters
queryDescriptorsQuery set of descriptors.
trainDescriptorsTrain set of descriptors. This set is not added to the train descriptors collection stored in the class object.
matchesFound matches.
maxDistanceThreshold 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)!
maskMask specifying permissible matches between an input query and train matrices of descriptors.
compactResultParameter 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.

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.

virtual void cv::cuda::DescriptorMatcher::radiusMatch ( InputArray  queryDescriptors,
std::vector< std::vector< DMatch > > &  matches,
float  maxDistance,
const std::vector< GpuMat > &  masks = std::vector< GpuMat >(),
bool  compactResult = false 
)
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void cv::cuda::DescriptorMatcher::radiusMatchAsync ( InputArray  queryDescriptors,
InputArray  trainDescriptors,
OutputArray  matches,
float  maxDistance,
InputArray  mask = noArray(),
Stream stream = Stream::Null() 
)
pure virtual

For each query descriptor, finds the training descriptors not farther than the specified distance (asynchronous version).

Parameters
queryDescriptorsQuery set of descriptors.
trainDescriptorsTrain set of descriptors. This set is not added to the train descriptors collection stored in the class object.
matchesMatches array stored in GPU memory. Internal representation is not defined. Use DescriptorMatcher::radiusMatchConvert method to retrieve results in standard representation.
maxDistanceThreshold 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)!
maskMask specifying permissible matches between an input query and train matrices of descriptors.
streamCUDA stream.

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.

virtual void cv::cuda::DescriptorMatcher::radiusMatchAsync ( InputArray  queryDescriptors,
OutputArray  matches,
float  maxDistance,
const std::vector< GpuMat > &  masks = std::vector< GpuMat >(),
Stream stream = Stream::Null() 
)
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void cv::cuda::DescriptorMatcher::radiusMatchConvert ( InputArray  gpu_matches,
std::vector< std::vector< DMatch > > &  matches,
bool  compactResult = false 
)
pure virtual

Converts matches array from internal representation to standard matches vector.

The method is supposed to be used with DescriptorMatcher::radiusMatchAsync to get final result. Call this method only after DescriptorMatcher::radiusMatchAsync is completed (ie. after synchronization).

Parameters
gpu_matchesMatches, returned from DescriptorMatcher::radiusMatchAsync.
matchesVector of DMatch objects.
compactResultParameter 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 cv::Algorithm::read ( const FileNode fn)
inlinevirtualinherited

Reads algorithm parameters from a file storage.

Reimplemented in cv::FlannBasedMatcher, cv::DescriptorMatcher, and cv::Feature2D.

template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::read ( const FileNode fn)
inlinestaticinherited

Reads algorithm from the file node.

This is static template method of Algorithm. It's usage is following (in the case of SVM):

cv::FileStorage fsRead("example.xml", FileStorage::READ);
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());

In order to make this method work, the derived class must overwrite Algorithm::read(const FileNode& fn) and also have static create() method without parameters (or with all the optional parameters)

References cv::Ptr< T >::empty().

Here is the call graph for this function:

virtual void cv::Algorithm::save ( const String filename) const
virtualinherited

Saves the algorithm to a file.

In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

virtual void cv::cuda::DescriptorMatcher::train ( )
pure 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.

virtual void cv::Algorithm::write ( FileStorage fs) const
inlinevirtualinherited

Stores algorithm parameters in a file storage.

Reimplemented in cv::FlannBasedMatcher, cv::DescriptorMatcher, and cv::Feature2D.

void cv::Algorithm::writeFormat ( FileStorage fs) const
protectedinherited

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