OpenCV  5.0.0alpha
Open Source Computer Vision
Loading...
Searching...
No Matches
cv::xfeatures2d::BOWImgDescriptorExtractor Class Reference

Class to compute an image descriptor using the bag of visual words. More...

#include <opencv2/xfeatures2d.hpp>

Collaboration diagram for cv::xfeatures2d::BOWImgDescriptorExtractor:

Public Member Functions

 BOWImgDescriptorExtractor (const Ptr< DescriptorMatcher > &dmatcher)
 
 BOWImgDescriptorExtractor (const Ptr< Feature2D > &dextractor, const Ptr< DescriptorMatcher > &dmatcher)
 The constructor.
 
virtual ~BOWImgDescriptorExtractor ()
 
void compute (InputArray image, std::vector< KeyPoint > &keypoints, OutputArray imgDescriptor, std::vector< std::vector< int > > *pointIdxsOfClusters=0, Mat *descriptors=0)
 Computes an image descriptor using the set visual vocabulary.
 
void compute (InputArray keypointDescriptors, OutputArray imgDescriptor, std::vector< std::vector< int > > *pointIdxsOfClusters=0)
 
void compute2 (const Mat &image, std::vector< KeyPoint > &keypoints, Mat &imgDescriptor)
 
int descriptorSize () const
 Returns an image descriptor size if the vocabulary is set. Otherwise, it returns 0.
 
int descriptorType () const
 Returns an image descriptor type.
 
const MatgetVocabulary () const
 Returns the set vocabulary.
 
void setVocabulary (const Mat &vocabulary)
 Sets a visual vocabulary.
 

Protected Attributes

Ptr< DescriptorExtractordextractor
 
Ptr< DescriptorMatcherdmatcher
 
Mat vocabulary
 

Detailed Description

Class to compute an image descriptor using the bag of visual words.

Such a computation consists of the following steps:

  1. Compute descriptors for a given image and its keypoints set.
  2. Find the nearest visual words from the vocabulary for each keypoint descriptor.
  3. Compute the bag-of-words image descriptor as is a normalized histogram of vocabulary words encountered in the image. The i-th bin of the histogram is a frequency of i-th word of the vocabulary in the given image.

Constructor & Destructor Documentation

◆ BOWImgDescriptorExtractor() [1/2]

cv::xfeatures2d::BOWImgDescriptorExtractor::BOWImgDescriptorExtractor ( const Ptr< Feature2D > & dextractor,
const Ptr< DescriptorMatcher > & dmatcher )
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor(dextractor, dmatcher) -> <xfeatures2d_BOWImgDescriptorExtractor object>

The constructor.

Parameters
dextractorDescriptor extractor that is used to compute descriptors for an input image and its keypoints.
dmatcherDescriptor matcher that is used to find the nearest word of the trained vocabulary for each keypoint descriptor of the image.

◆ BOWImgDescriptorExtractor() [2/2]

cv::xfeatures2d::BOWImgDescriptorExtractor::BOWImgDescriptorExtractor ( const Ptr< DescriptorMatcher > & dmatcher)
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor(dextractor, dmatcher) -> <xfeatures2d_BOWImgDescriptorExtractor object>

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

◆ ~BOWImgDescriptorExtractor()

virtual cv::xfeatures2d::BOWImgDescriptorExtractor::~BOWImgDescriptorExtractor ( )
virtual

Member Function Documentation

◆ compute() [1/2]

void cv::xfeatures2d::BOWImgDescriptorExtractor::compute ( InputArray image,
std::vector< KeyPoint > & keypoints,
OutputArray imgDescriptor,
std::vector< std::vector< int > > * pointIdxsOfClusters = 0,
Mat * descriptors = 0 )

Computes an image descriptor using the set visual vocabulary.

Parameters
imageImage, for which the descriptor is computed.
keypointsKeypoints detected in the input image.
imgDescriptorComputed output image descriptor.
pointIdxsOfClustersIndices of keypoints that belong to the cluster. This means that pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary) returned if it is non-zero.
descriptorsDescriptors of the image keypoints that are returned if they are non-zero.

◆ compute() [2/2]

void cv::xfeatures2d::BOWImgDescriptorExtractor::compute ( InputArray keypointDescriptors,
OutputArray imgDescriptor,
std::vector< std::vector< int > > * pointIdxsOfClusters = 0 )

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

Parameters
keypointDescriptorsComputed descriptors to match with vocabulary.
imgDescriptorComputed output image descriptor.
pointIdxsOfClustersIndices of keypoints that belong to the cluster. This means that pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary) returned if it is non-zero.

◆ compute2()

void cv::xfeatures2d::BOWImgDescriptorExtractor::compute2 ( const Mat & image,
std::vector< KeyPoint > & keypoints,
Mat & imgDescriptor )
inline
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor.compute(image, keypoints[, imgDescriptor]) -> imgDescriptor

◆ descriptorSize()

int cv::xfeatures2d::BOWImgDescriptorExtractor::descriptorSize ( ) const
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor.descriptorSize() -> retval

Returns an image descriptor size if the vocabulary is set. Otherwise, it returns 0.

◆ descriptorType()

int cv::xfeatures2d::BOWImgDescriptorExtractor::descriptorType ( ) const
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor.descriptorType() -> retval

Returns an image descriptor type.

◆ getVocabulary()

const Mat & cv::xfeatures2d::BOWImgDescriptorExtractor::getVocabulary ( ) const
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor.getVocabulary() -> retval

Returns the set vocabulary.

◆ setVocabulary()

void cv::xfeatures2d::BOWImgDescriptorExtractor::setVocabulary ( const Mat & vocabulary)
Python:
cv.xfeatures2d.BOWImgDescriptorExtractor.setVocabulary(vocabulary) -> None

Sets a visual vocabulary.

Parameters
vocabularyVocabulary (can be trained using the inheritor of BOWTrainer ). Each row of the vocabulary is a visual word (cluster center).

Member Data Documentation

◆ dextractor

Ptr<DescriptorExtractor> cv::xfeatures2d::BOWImgDescriptorExtractor::dextractor
protected

◆ dmatcher

Ptr<DescriptorMatcher> cv::xfeatures2d::BOWImgDescriptorExtractor::dmatcher
protected

◆ vocabulary

Mat cv::xfeatures2d::BOWImgDescriptorExtractor::vocabulary
protected

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