OpenCV  3.4.7
Open Source Computer Vision
Classes | Public Member Functions | Static Public Member Functions | List of all members
cv::line_descriptor::BinaryDescriptorMatcher Class Reference

furnishes all functionalities for querying a dataset provided by user or internal to class (that user must, anyway, populate) on the model of Descriptor Matchers More...

#include <opencv2/line_descriptor/descriptor.hpp>

Inheritance diagram for cv::line_descriptor::BinaryDescriptorMatcher:
cv::Algorithm

Public Member Functions

 BinaryDescriptorMatcher ()
 Constructor. More...
 
 ~BinaryDescriptorMatcher ()
 
void add (const std::vector< Mat > &descriptors)
 Store locally new descriptors to be inserted in dataset, without updating dataset. More...
 
void clear () CV_OVERRIDE
 Clear dataset and internal data. More...
 
void knnMatch (const Mat &queryDescriptors, const Mat &trainDescriptors, std::vector< std::vector< DMatch > > &matches, int k, const Mat &mask=Mat(), bool compactResult=false) const
 For every input query descriptor, retrieve the best k matching ones from a dataset provided from user or from the one internal to class. More...
 
void knnMatch (const Mat &queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, const std::vector< Mat > &masks=std::vector< Mat >(), bool compactResult=false)
 
void match (const Mat &queryDescriptors, const Mat &trainDescriptors, std::vector< DMatch > &matches, const Mat &mask=Mat()) const
 For every input query descriptor, retrieve the best matching one from a dataset provided from user or from the one internal to class. More...
 
void match (const Mat &queryDescriptors, std::vector< DMatch > &matches, const std::vector< Mat > &masks=std::vector< Mat >())
 
void radiusMatch (const Mat &queryDescriptors, const Mat &trainDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, const Mat &mask=Mat(), bool compactResult=false) const
 For every input query descriptor, retrieve, from a dataset provided from user or from the one internal to class, all the descriptors that are not further than maxDist from input query. More...
 
void radiusMatch (const Mat &queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, const std::vector< Mat > &masks=std::vector< Mat >(), bool compactResult=false)
 
void train ()
 Update dataset by inserting into it all descriptors that were stored locally by add function. More...
 
- Public Member Functions inherited from cv::Algorithm
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual bool empty () const
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. More...
 
virtual String getDefaultName () const
 
virtual void read (const FileNode &fn)
 Reads algorithm parameters from a file storage. More...
 
virtual void save (const String &filename) const
 
virtual void write (FileStorage &fs) const
 Stores algorithm parameters in a file storage. More...
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 simplified API for language bindings This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 

Static Public Member Functions

static Ptr< BinaryDescriptorMatchercreateBinaryDescriptorMatcher ()
 Create a BinaryDescriptorMatcher object and return a smart pointer to it. More...
 
- 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...
 

Additional Inherited Members

- Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const
 

Detailed Description

furnishes all functionalities for querying a dataset provided by user or internal to class (that user must, anyway, populate) on the model of Descriptor Matchers

Once descriptors have been extracted from an image (both they represent lines and points), it becomes interesting to be able to match a descriptor with another one extracted from a different image and representing the same line or point, seen from a differente perspective or on a different scale. In reaching such goal, the main headache is designing an efficient search algorithm to associate a query descriptor to one extracted from a dataset. In the following, a matching modality based on Multi-Index Hashing (MiHashing) will be described.

Multi-Index Hashing

The theory described in this section is based on [157] . Given a dataset populated with binary codes, each code is indexed m times into m different hash tables, according to m substrings it has been divided into. Thus, given a query code, all the entries close to it at least in one substring are returned by search as neighbor candidates. Returned entries are then checked for validity by verifying that their full codes are not distant (in Hamming space) more than r bits from query code. In details, each binary code h composed of b bits is divided into m disjoint substrings \(\mathbf{h}^{(1)}, ..., \mathbf{h}^{(m)}\), each with length \(\lfloor b/m \rfloor\) or \(\lceil b/m \rceil\) bits. Formally, when two codes h and g differ by at the most r bits, in at the least one of their m substrings they differ by at the most \(\lfloor r/m \rfloor\) bits. In particular, when \(||\mathbf{h}-\mathbf{g}||_H \le r\) (where \(||.||_H\) is the Hamming norm), there must exist a substring k (with \(1 \le k \le m\)) such that

\[||\mathbf{h}^{(k)} - \mathbf{g}^{(k)}||_H \le \left\lfloor \frac{r}{m} \right\rfloor .\]

That means that if Hamming distance between each of the m substring is strictly greater than \(\lfloor r/m \rfloor\), then \(||\mathbf{h}-\mathbf{g}||_H\) must be larger that r and that is a contradiction. If the codes in dataset are divided into m substrings, then m tables will be built. Given a query q with substrings \(\{\mathbf{q}^{(i)}\}^m_{i=1}\), i-th hash table is searched for entries distant at the most \(\lfloor r/m \rfloor\) from \(\mathbf{q}^{(i)}\) and a set of candidates \(\mathcal{N}_i(\mathbf{q})\) is obtained. The union of sets \(\mathcal{N}(\mathbf{q}) = \bigcup_i \mathcal{N}_i(\mathbf{q})\) is a superset of the r-neighbors of q. Then, last step of algorithm is computing the Hamming distance between q and each element in \(\mathcal{N}(\mathbf{q})\), deleting the codes that are distant more that r from q.

Constructor & Destructor Documentation

§ BinaryDescriptorMatcher()

cv::line_descriptor::BinaryDescriptorMatcher::BinaryDescriptorMatcher ( )
Python:
<line_descriptor_BinaryDescriptorMatcher object>=cv.line_descriptor_BinaryDescriptorMatcher()

Constructor.

The BinaryDescriptorMatcher constructed is able to store and manage 256-bits long entries.

§ ~BinaryDescriptorMatcher()

cv::line_descriptor::BinaryDescriptorMatcher::~BinaryDescriptorMatcher ( )
inline

destructor

Member Function Documentation

§ add()

void cv::line_descriptor::BinaryDescriptorMatcher::add ( const std::vector< Mat > &  descriptors)

Store locally new descriptors to be inserted in dataset, without updating dataset.

Parameters
descriptorsmatrices containing descriptors to be inserted into dataset
Note
Each matrix i in descriptors should contain descriptors relative to lines extracted from i*-th image.

§ clear()

void cv::line_descriptor::BinaryDescriptorMatcher::clear ( )
virtual

Clear dataset and internal data.

Reimplemented from cv::Algorithm.

§ createBinaryDescriptorMatcher()

static Ptr<BinaryDescriptorMatcher> cv::line_descriptor::BinaryDescriptorMatcher::createBinaryDescriptorMatcher ( )
static

Create a BinaryDescriptorMatcher object and return a smart pointer to it.

§ knnMatch() [1/2]

void cv::line_descriptor::BinaryDescriptorMatcher::knnMatch ( const Mat queryDescriptors,
const Mat trainDescriptors,
std::vector< std::vector< DMatch > > &  matches,
int  k,
const Mat mask = Mat(),
bool  compactResult = false 
) const
Python:
matches=cv.line_descriptor_BinaryDescriptorMatcher.knnMatch(queryDescriptors, trainDescriptors, k[, mask[, compactResult]])
None=cv.line_descriptor_BinaryDescriptorMatcher.knnMatchQuery(queryDescriptors, matches, k[, masks[, compactResult]])

For every input query descriptor, retrieve the best k matching ones from a dataset provided from user or from the one internal to class.

Parameters
queryDescriptorsquery descriptors
trainDescriptorsdataset of descriptors furnished by user
matchesvector to host retrieved matches
knumber of the closest descriptors to be returned for every input query
maskmask to select which input descriptors must be matched to ones in dataset
compactResultflag to obtain a compact result (if true, a vector that doesn't contain any matches for a given query is not inserted in final result)

§ knnMatch() [2/2]

void cv::line_descriptor::BinaryDescriptorMatcher::knnMatch ( const Mat queryDescriptors,
std::vector< std::vector< DMatch > > &  matches,
int  k,
const std::vector< Mat > &  masks = std::vector< Mat >(),
bool  compactResult = false 
)
Python:
matches=cv.line_descriptor_BinaryDescriptorMatcher.knnMatch(queryDescriptors, trainDescriptors, k[, mask[, compactResult]])
None=cv.line_descriptor_BinaryDescriptorMatcher.knnMatchQuery(queryDescriptors, matches, k[, masks[, compactResult]])

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

Parameters
queryDescriptorsquery descriptors
matchesvector to host retrieved matches
knumber of the closest descriptors to be returned for every input query
masksvector of masks to select which input descriptors must be matched to ones in dataset (the i-th mask in vector indicates whether each input query can be matched with descriptors in dataset relative to i-th image)
compactResultflag to obtain a compact result (if true, a vector that doesn't contain any matches for a given query is not inserted in final result)

§ match() [1/2]

void cv::line_descriptor::BinaryDescriptorMatcher::match ( const Mat queryDescriptors,
const Mat trainDescriptors,
std::vector< DMatch > &  matches,
const Mat mask = Mat() 
) const
Python:
matches=cv.line_descriptor_BinaryDescriptorMatcher.match(queryDescriptors, trainDescriptors[, mask])
matches=cv.line_descriptor_BinaryDescriptorMatcher.matchQuery(queryDescriptors[, masks])

For every input query descriptor, retrieve the best matching one from a dataset provided from user or from the one internal to class.

Parameters
queryDescriptorsquery descriptors
trainDescriptorsdataset of descriptors furnished by user
matchesvector to host retrieved matches
maskmask to select which input descriptors must be matched to one in dataset

§ match() [2/2]

void cv::line_descriptor::BinaryDescriptorMatcher::match ( const Mat queryDescriptors,
std::vector< DMatch > &  matches,
const std::vector< Mat > &  masks = std::vector< Mat >() 
)
Python:
matches=cv.line_descriptor_BinaryDescriptorMatcher.match(queryDescriptors, trainDescriptors[, mask])
matches=cv.line_descriptor_BinaryDescriptorMatcher.matchQuery(queryDescriptors[, masks])

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

Parameters
queryDescriptorsquery descriptors
matchesvector to host retrieved matches
masksvector of masks to select which input descriptors must be matched to one in dataset (the i-th mask in vector indicates whether each input query can be matched with descriptors in dataset relative to i-th image)

§ radiusMatch() [1/2]

void cv::line_descriptor::BinaryDescriptorMatcher::radiusMatch ( const Mat queryDescriptors,
const Mat trainDescriptors,
std::vector< std::vector< DMatch > > &  matches,
float  maxDistance,
const Mat mask = Mat(),
bool  compactResult = false 
) const

For every input query descriptor, retrieve, from a dataset provided from user or from the one internal to class, all the descriptors that are not further than maxDist from input query.

Parameters
queryDescriptorsquery descriptors
trainDescriptorsdataset of descriptors furnished by user
matchesvector to host retrieved matches
maxDistancesearch radius
maskmask to select which input descriptors must be matched to ones in dataset
compactResultflag to obtain a compact result (if true, a vector that doesn't contain any matches for a given query is not inserted in final result)

§ radiusMatch() [2/2]

void cv::line_descriptor::BinaryDescriptorMatcher::radiusMatch ( const Mat queryDescriptors,
std::vector< std::vector< DMatch > > &  matches,
float  maxDistance,
const std::vector< Mat > &  masks = std::vector< Mat >(),
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.

Parameters
queryDescriptorsquery descriptors
matchesvector to host retrieved matches
maxDistancesearch radius
masksvector of masks to select which input descriptors must be matched to ones in dataset (the i-th mask in vector indicates whether each input query can be matched with descriptors in dataset relative to i-th image)
compactResultflag to obtain a compact result (if true, a vector that doesn't contain any matches for a given query is not inserted in final result)

§ train()

void cv::line_descriptor::BinaryDescriptorMatcher::train ( )

Update dataset by inserting into it all descriptors that were stored locally by add function.

Note
Every time this function is invoked, current dataset is deleted and locally stored descriptors are inserted into dataset. The locally stored copy of just inserted descriptors is then removed.

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