class cv::BOWKMeansTrainer

Overview

kmeans -based class to train visual vocabulary using the bag of visual words approach. : Moreā€¦

#include <features2d.hpp>

class BOWKMeansTrainer: public cv::BOWTrainer
{
public:
    // construction

    BOWKMeansTrainer(
        int clusterCount,
        const TermCriteria& termcrit = TermCriteria(),
        int attempts = 3,
        int flags = KMEANS_PP_CENTERS
        );

    // methods

    virtual
    Mat
    cluster() const;

    virtual
    Mat
    cluster(const Mat& descriptors) const;

protected:
    // fields

    int attempts;
    int clusterCount;
    int flags;
    TermCriteria termcrit;
};

Inherited Members

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;

Detailed Documentation

kmeans -based class to train visual vocabulary using the bag of visual words approach. :

Construction

BOWKMeansTrainer(
    int clusterCount,
    const TermCriteria& termcrit = TermCriteria(),
    int attempts = 3,
    int flags = KMEANS_PP_CENTERS
    )

The constructor.

See also:

cv::kmeans

Methods

virtual
Mat
cluster() const

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

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.