class cv::BOWTrainer
Overview
Abstract base class for training the bag of visual words vocabulary from a set of descriptors. Moreā¦
#include <features2d.hpp> class BOWTrainer { public: // methods void add(const Mat& descriptors); virtual void clear(); virtual Mat cluster() const = 0; virtual Mat cluster(const Mat& descriptors) const = 0; int descriptorsCount() const; const std::vector<Mat>& getDescriptors() const; protected: // fields std::vector<Mat> descriptors; int size; }; // direct descendants class BOWKMeansTrainer;
Detailed Documentation
Abstract base class for training the bag of visual words vocabulary from a set of descriptors.
For details, see, for example, Visual Categorization with Bags of Keypoints by Gabriella Csurka, Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. :
Methods
void add(const Mat& descriptors)
Adds descriptors to a training set.
The training set is clustered using clustermethod to construct the vocabulary.
Parameters:
descriptors | Descriptors to add to a training set. Each row of the descriptors matrix is a descriptor. |
virtual Mat cluster() const = 0
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
virtual Mat cluster(const Mat& descriptors) const = 0
Clusters train descriptors.
The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first variant of the method, train descriptors stored in the object are clustered. In the second variant, input descriptors are clustered.
Parameters:
descriptors | Descriptors to cluster. Each row of the descriptors matrix is a descriptor. Descriptors are not added to the inner train descriptor set. |
int descriptorsCount() const
Returns the count of all descriptors stored in the training set.
const std::vector<Mat>& getDescriptors() const
Returns a training set of descriptors.