| OpenCV 5.0.0alpha Open Source Computer Vision

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cv::BFMatcher Class Reference
Features Framework » Descriptor Matchers

Brute-force descriptor matcher. More...

`#include <opencv2/features.hpp>`

Collaboration diagram for cv::BFMatcher:

## Public Member Functions
| BFMatcher (int normType=NORM_L2, bool crossCheck=false)
| Brute-force matcher constructor (obsolete). Please use BFMatcher.create()
virtual | ~BFMatcher ()
virtual CV_NODISCARD_STD Ptr< DescriptorMatcher > | clone (bool emptyTrainData=false) const CV_OVERRIDE
| Clones the matcher.
virtual bool | isMaskSupported () const CV_OVERRIDE
| Returns true if the descriptor matcher supports masking permissible matches.
Public Member Functions inherited from cv::DescriptorMatcher
virtual | ~DescriptorMatcher ()
virtual void | add (InputArrayOfArrays descriptors)
| Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection.
virtual void | clear () CV_OVERRIDE
| Clears the train descriptor collections.
virtual bool | empty () const CV_OVERRIDE
| Returns true if there are no train descriptors in the both collections.
const std::vector< Mat > & | getTrainDescriptors () const
| Returns a constant link to the train descriptor collection trainDescCollection .
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.
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.
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.
void | radiusMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArrayOfArrays masks=noArray(), bool compactResult=false)
virtual void | read (const FileNode &) CV_OVERRIDE
| Reads algorithm parameters from a file storage.
void | read (const String &fileName)
virtual void | train ()
| Trains a descriptor matcher.
void | write (const Ptr< FileStorage > &fs, const String &name) const
void | write (const String &fileName) const
virtual void | write (FileStorage &) const CV_OVERRIDE
| Stores algorithm parameters in a file storage.
void | write (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

## Static Public Member Functions
static Ptr< BFMatcher > | create (int normType=NORM_L2, bool crossCheck=false)
| Brute-force matcher create method.
Static Public Member Functions inherited from cv::DescriptorMatcher
static Ptr< DescriptorMatcher > | create (const DescriptorMatcher::MatcherType &matcherType)
static Ptr< DescriptorMatcher > | create (const String &descriptorMatcherType)
| Creates a descriptor matcher of a given type with the default parameters (using default constructor).
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.
template<typename _Tp >
static Ptr< _Tp > | loadFromString (const String &strModel, const String &objname=String())
| Loads algorithm from a String.
template<typename _Tp >
static Ptr< _Tp > | read (const FileNode &fn)
| Reads algorithm from the file node.

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

## Protected Attributes
bool | crossCheck
int | normType
Protected Attributes inherited from cv::DescriptorMatcher
std::vector< Mat > | trainDescCollection
| Collection of descriptors from train images.
std::vector< UMat > | utrainDescCollection

## 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 }
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)

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ BFMatcher()

cv::BFMatcher::BFMatcher | ( | int | normType = NORM_L2,
|  | bool | crossCheck = false )

Python:
| cv.BFMatcher( | [, normType[, crossCheck]] | ) -> | <BFMatcher object>

Brute-force matcher constructor (obsolete). Please use BFMatcher.create()

## ◆ ~BFMatcher()

virtual cv::BFMatcher::~BFMatcher | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ clone()

virtual CV_NODISCARD_STD Ptr< DescriptorMatcher > cv::BFMatcher::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 cv::DescriptorMatcher.

## ◆ create()

static Ptr< BFMatcher > cv::BFMatcher::create | ( | int | normType = NORM_L2,
|  | bool | crossCheck = false )
| static

Python:
| cv.BFMatcher.create( | [, normType[, crossCheck]] | ) -> | retval
| cv.BFMatcher_create( | [, normType[, crossCheck]] | ) -> | retval

Brute-force matcher create method.

Parameters

  normType | One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor description).
  crossCheck | If it is false, this is will be default BFMatcher behaviour when it finds the k nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent pairs. Such technique usually produces best results with minimal number of outliers when there are enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.

## ◆ isMaskSupported()

virtual bool cv::BFMatcher::isMaskSupported | ( |  | ) | const
| inline virtual

Returns true if the descriptor matcher supports masking permissible matches.

Implements cv::DescriptorMatcher.

## ◆ knnMatchImpl()

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

## ◆ radiusMatchImpl()

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

Implements cv::DescriptorMatcher.

## Member Data Documentation

## ◆ crossCheck

bool cv::BFMatcher::crossCheck
| protected

## ◆ normType

int cv::BFMatcher::normType
| protected

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

- opencv2/features.hpp