Class cv::DescriptorMatcher#

Abstract base class for matching keypoint descriptors. View details

Collaboration diagram for cv::DescriptorMatcher:

cv::DescriptorMatcher Node1 cv::DescriptorMatcher   + ~DescriptorMatcher() + add() + clear() + clone() + empty() + getTrainDescriptors() + isMaskSupported() + knnMatch() + knnMatch() + match() and 10 more... + create() + create() # checkMasks() # knnMatchImpl() # radiusMatchImpl() # clone_op() # isMaskedOut() # isPossibleMatch() Node2 cv::Algorithm   + Algorithm() + ~Algorithm() + clear() + empty() + getDefaultName() + read() + save() + write() + write() + load() + loadFromString() + read() # writeFormat() Node2->Node1 Node3 std::vector< cv::Mat >     Node3->Node1 #trainDescCollection Node4 cv::Mat   + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() and 152 more... + diag() + eye() + eye() + getDefaultAllocator() + getStdAllocator() + ones() + ones() + ones() + ones() + setDefaultAllocator() + zeros() + zeros() + zeros() + zeros() # forEach_impl() Node4->Node3 +elements Node5 int     Node5->Node4 +cols +dims +dummy +flags +rows Node14 cv::UMat   + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() and 67 more... + diag() + eye() + eye() + getStdAllocator() + ones() + ones() + ones() + ones() + zeros() + zeros() + zeros() + zeros() Node5->Node14 +cols +dims +flags +rows Node6 uint8_t     Node6->Node4 +data +dataend +datalimit +datastart Node7 cv::MatAllocator   + MatAllocator() + ~MatAllocator() + allocate() + allocate() + copy() + deallocate() + download() + getBufferPoolController() + map() + unmap() + upload() Node7->Node4 +allocator Node7->Node14 +allocator Node8 UMatData *     Node8->Node4 +u Node8->Node14 +u Node9 MatSize     Node9->Node4 +size Node9->Node14 +size Node10 MatStep     Node10->Node4 +step Node10->Node14 +step Node11 std::vector< T >     Node11->Node3 < cv::Mat > Node13 std::vector< cv::UMat >     Node11->Node13 < cv::UMat > Node12 T     Node12->Node11 +elements Node13->Node1 #utrainDescCollection Node14->Node13 +elements Node15 UMatUsageFlags     Node15->Node14 +usageFlags Node16 size_t     Node16->Node14 +offset

cv::DescriptorMatcher Node1 cv::DescriptorMatcher   + ~DescriptorMatcher() + add() + clear() + clone() + empty() + getTrainDescriptors() + isMaskSupported() + knnMatch() + knnMatch() + match() and 10 more... + create() + create() # checkMasks() # knnMatchImpl() # radiusMatchImpl() # clone_op() # isMaskedOut() # isPossibleMatch() Node2 cv::Algorithm   + Algorithm() + ~Algorithm() + clear() + empty() + getDefaultName() + read() + save() + write() + write() + load() + loadFromString() + read() # writeFormat() Node2->Node1 Node3 std::vector< cv::Mat >     Node3->Node1 #trainDescCollection Node4 cv::Mat   + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() + Mat() and 152 more... + diag() + eye() + eye() + getDefaultAllocator() + getStdAllocator() + ones() + ones() + ones() + ones() + setDefaultAllocator() + zeros() + zeros() + zeros() + zeros() # forEach_impl() Node4->Node3 +elements Node5 int     Node5->Node4 +cols +dims +dummy +flags +rows Node14 cv::UMat   + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() + UMat() and 67 more... + diag() + eye() + eye() + getStdAllocator() + ones() + ones() + ones() + ones() + zeros() + zeros() + zeros() + zeros() Node5->Node14 +cols +dims +flags +rows Node6 uint8_t     Node6->Node4 +data +dataend +datalimit +datastart Node7 cv::MatAllocator   + MatAllocator() + ~MatAllocator() + allocate() + allocate() + copy() + deallocate() + download() + getBufferPoolController() + map() + unmap() + upload() Node7->Node4 +allocator Node7->Node14 +allocator Node8 UMatData *     Node8->Node4 +u Node8->Node14 +u Node9 MatSize     Node9->Node4 +size Node9->Node14 +size Node10 MatStep     Node10->Node4 +step Node10->Node14 +step Node11 std::vector< T >     Node11->Node3 < cv::Mat > Node13 std::vector< cv::UMat >     Node11->Node13 < cv::UMat > Node12 T     Node12->Node11 +elements Node13->Node1 #utrainDescCollection Node14->Node13 +elements Node15 UMatUsageFlags     Node15->Node14 +usageFlags Node16 size_t     Node16->Node14 +offset

Public Types#

Public Member Functions#

Public Member Functions inherited from cv::Algorithm

Return

Name

Description

Algorithm()

~Algorithm()

void

clear()

Clears the algorithm state.

bool

empty()

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.

String

getDefaultName()

void

read(const FileNode & fn)

Reads algorithm parameters from a file storage.

void

save(const String & filename)

void

write(
    const Ptr< FileStorage > & fs,
    const String & name = String() )

void

write(FileStorage & fs)

Stores algorithm parameters in a file storage.

void

write(
    FileStorage & fs,
    const String & name )

Static Public Member Functions#

Static Public Member Functions inherited from cv::Algorithm

Return

Name

Description

static Ptr< _Tp >

load(
    const String & filename,
    const String & objname = String() )

Loads algorithm from the file.

static Ptr< _Tp >

loadFromString(
    const String & strModel,
    const String & objname = String() )

Loads algorithm from a String.

static Ptr< _Tp >

read(const FileNode & fn)

Reads algorithm from the file node.

Additional Inherited Members#

Protected Member Functions inherited from cv::Algorithm

Return

Name

Description

void

writeFormat(FileStorage & fs)

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 Enumeration Documentation#

enum MatcherType

FLANNBASED
Python: cv.DescriptorMatcher_FLANNBASED

BRUTEFORCE
Python: cv.DescriptorMatcher_BRUTEFORCE

BRUTEFORCE_L1
Python: cv.DescriptorMatcher_BRUTEFORCE_L1

BRUTEFORCE_HAMMING
Python: cv.DescriptorMatcher_BRUTEFORCE_HAMMING

BRUTEFORCE_HAMMINGLUT
Python: cv.DescriptorMatcher_BRUTEFORCE_HAMMINGLUT

BRUTEFORCE_SL2
Python: cv.DescriptorMatcher_BRUTEFORCE_SL2

Constructor & Destructor Documentation#

~DescriptorMatcher()#

cv::DescriptorMatcher::~DescriptorMatcher()

Member Function Documentation#

add()#

void cv::DescriptorMatcher::add(InputArrayOfArrays descriptors)

Python:

cv.DescriptorMatcher.add(descriptors)

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.

clear()#

void cv::DescriptorMatcher::clear()

Python:

cv.DescriptorMatcher.clear()

Clears the train descriptor collections.

clone()#

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

Python:

cv.DescriptorMatcher.clone([, emptyTrainData]) -> retval

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.

empty()#

bool cv::DescriptorMatcher::empty()

Python:

cv.DescriptorMatcher.empty() -> retval

Returns true if there are no train descriptors in the both collections.

getTrainDescriptors()#

const std::vector< Mat > & cv::DescriptorMatcher::getTrainDescriptors()

Python:

cv.DescriptorMatcher.getTrainDescriptors() -> retval

Returns a constant link to the train descriptor collection trainDescCollection .

isMaskSupported()#

bool cv::DescriptorMatcher::isMaskSupported()

Python:

cv.DescriptorMatcher.isMaskSupported() -> retval

Returns true if the descriptor matcher supports masking permissible matches.

knnMatch()#

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

Python:

cv.DescriptorMatcher.knnMatch(queryDescriptors, trainDescriptors, k[, mask[, compactResult]]) -> matches
cv.DescriptorMatcher.knnMatch(queryDescriptors, k[, masks[, compactResult]]) -> matches

Finds the k best matches for each descriptor from a query set.

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.

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.

knnMatch()#

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

Python:

cv.DescriptorMatcher.knnMatch(queryDescriptors, trainDescriptors, k[, mask[, compactResult]]) -> matches
cv.DescriptorMatcher.knnMatch(queryDescriptors, k[, masks[, compactResult]]) -> matches

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.

match()#

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

Python:

cv.DescriptorMatcher.match(queryDescriptors, trainDescriptors[, mask]) -> matches
cv.DescriptorMatcher.match(queryDescriptors[, masks]) -> matches

Finds the best match for each descriptor from a query set.

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(i,j) is non-zero.

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.

match()#

void cv::DescriptorMatcher::match(
InputArray queryDescriptors,
std::vector< DMatch > & matches,
InputArrayOfArrays masks = noArray() )

Python:

cv.DescriptorMatcher.match(queryDescriptors, trainDescriptors[, mask]) -> matches
cv.DescriptorMatcher.match(queryDescriptors[, masks]) -> matches

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].

radiusMatch()#

void cv::DescriptorMatcher::radiusMatch(
InputArray queryDescriptors,
InputArray trainDescriptors,
std::vector< std::vector< DMatch > > & matches,
float maxDistance,
InputArray mask = noArray(),
bool compactResult = false )

Python:

cv.DescriptorMatcher.radiusMatch(queryDescriptors, trainDescriptors, maxDistance[, mask[, compactResult]]) -> matches
cv.DescriptorMatcher.radiusMatch(queryDescriptors, maxDistance[, masks[, compactResult]]) -> matches

For each query descriptor, finds the training descriptors not farther than the specified distance.

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.

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.

radiusMatch()#

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

Python:

cv.DescriptorMatcher.radiusMatch(queryDescriptors, trainDescriptors, maxDistance[, mask[, compactResult]]) -> matches
cv.DescriptorMatcher.radiusMatch(queryDescriptors, maxDistance[, masks[, compactResult]]) -> matches

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.

read()#

void cv::DescriptorMatcher::read(const FileNode & fn)

Python:

cv.DescriptorMatcher.read(fileName)
cv.DescriptorMatcher.read(arg1)

Reads algorithm parameters from a file storage.

read()#

void cv::DescriptorMatcher::read(const String & fileName)

Python:

cv.DescriptorMatcher.read(fileName)
cv.DescriptorMatcher.read(arg1)

Here is the call graph for this function:

cv::DescriptorMatcher::read Node1 cv::DescriptorMatcher ::read Node2 cv::read Node1->Node2 Node3 cv::FileStorage::root Node1->Node3

cv::DescriptorMatcher::read Node1 cv::DescriptorMatcher ::read Node2 cv::read Node1->Node2 Node3 cv::FileStorage::root Node1->Node3

train()#

void cv::DescriptorMatcher::train()

Python:

cv.DescriptorMatcher.train()

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 ).

write()#

void cv::DescriptorMatcher::write(
const Ptr< FileStorage > & fs,
const String & name )

Python:

cv.DescriptorMatcher.write(fileName)
cv.DescriptorMatcher.write(fs, name)

write()#

void cv::DescriptorMatcher::write(const String & fileName)

Python:

cv.DescriptorMatcher.write(fileName)
cv.DescriptorMatcher.write(fs, name)

Here is the call graph for this function:

cv::DescriptorMatcher::write Node1 cv::DescriptorMatcher ::write Node2 cv::write Node1->Node2

cv::DescriptorMatcher::write Node1 cv::DescriptorMatcher ::write Node2 cv::write Node1->Node2

write()#

void cv::DescriptorMatcher::write(FileStorage & fs)

Python:

cv.DescriptorMatcher.write(fileName)
cv.DescriptorMatcher.write(fs, name)

Stores algorithm parameters in a file storage.

write()#

void cv::DescriptorMatcher::write(
FileStorage & fs,
const String & name )

Python:

cv.DescriptorMatcher.write(fileName)
cv.DescriptorMatcher.write(fs, name)

create()#

static Ptr< DescriptorMatcher > cv::DescriptorMatcher::create(const DescriptorMatcher::MatcherType & matcherType)

Python:

cv.DescriptorMatcher.create(descriptorMatcherType) -> retval
cv.DescriptorMatcher.create(matcherType) -> retval
cv.DescriptorMatcher_create(descriptorMatcherType) -> retval
cv.DescriptorMatcher_create(matcherType) -> retval

create()#

static Ptr< DescriptorMatcher > cv::DescriptorMatcher::create(const String & descriptorMatcherType)

Python:

cv.DescriptorMatcher.create(descriptorMatcherType) -> retval
cv.DescriptorMatcher.create(matcherType) -> retval
cv.DescriptorMatcher_create(descriptorMatcherType) -> retval
cv.DescriptorMatcher_create(matcherType) -> retval

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

checkMasks()#

void cv::DescriptorMatcher::checkMasks(
InputArrayOfArrays masks,
int queryDescriptorsCount )

knnMatchImpl()#

void cv::DescriptorMatcher::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. These methods suppose that the class object has been trained already. Public match methods call these methods after calling train().

Here is the call graph for this function:

cv::DescriptorMatcher::knnMatchImpl Node1 cv::DescriptorMatcher ::knnMatchImpl Node2 cv::noArray Node1->Node2

cv::DescriptorMatcher::knnMatchImpl Node1 cv::DescriptorMatcher ::knnMatchImpl Node2 cv::noArray Node1->Node2

radiusMatchImpl()#

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

Here is the call graph for this function:

cv::DescriptorMatcher::radiusMatchImpl Node1 cv::DescriptorMatcher ::radiusMatchImpl Node2 cv::noArray Node1->Node2

cv::DescriptorMatcher::radiusMatchImpl Node1 cv::DescriptorMatcher ::radiusMatchImpl Node2 cv::noArray Node1->Node2

clone_op()#

static CV_NODISCARD_STD Mat cv::DescriptorMatcher::clone_op(Mat m)

Here is the call graph for this function:

cv::DescriptorMatcher::clone_op Node1 cv::DescriptorMatcher ::clone_op Node2 cv::Mat::clone Node1->Node2

cv::DescriptorMatcher::clone_op Node1 cv::DescriptorMatcher ::clone_op Node2 cv::Mat::clone Node1->Node2

isMaskedOut()#

static bool cv::DescriptorMatcher::isMaskedOut(
InputArrayOfArrays masks,
int queryIdx )

isPossibleMatch()#

static bool cv::DescriptorMatcher::isPossibleMatch(
InputArray mask,
int queryIdx,
int trainIdx )

Member Data Documentation#

trainDescCollection#

std::vector< Mat > cv::DescriptorMatcher::trainDescCollection

Collection of descriptors from train images.

utrainDescCollection#

std::vector< UMat > cv::DescriptorMatcher::utrainDescCollection

Source file#

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