mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 20:50:25 +08:00
added sample on BOW usage to image classification (training and testing is on Pascal VOC dataset)
This commit is contained in:
parent
66df8ef06c
commit
9f934363e5
@ -2243,6 +2243,9 @@ CV_EXPORTS void evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& im
|
||||
class CV_EXPORTS BOWTrainer
|
||||
{
|
||||
public:
|
||||
BOWTrainer(){}
|
||||
virtual ~BOWTrainer(){}
|
||||
|
||||
void add( const Mat& descriptors );
|
||||
const vector<Mat>& getDescriptors() const { return descriptors; }
|
||||
int descripotorsCount() const { return descriptors.empty() ? 0 : size; }
|
||||
@ -2272,8 +2275,7 @@ class CV_EXPORTS BOWKMeansTrainer : public BOWTrainer
|
||||
public:
|
||||
BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(),
|
||||
int attempts=3, int flags=KMEANS_PP_CENTERS );
|
||||
|
||||
|
||||
virtual ~BOWKMeansTrainer(){}
|
||||
|
||||
// Returns trained vocabulary (i.e. cluster centers).
|
||||
virtual Mat cluster() const;
|
||||
@ -2295,6 +2297,8 @@ class CV_EXPORTS BOWImgDescriptorExtractor
|
||||
public:
|
||||
BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor,
|
||||
const Ptr<DescriptorMatcher>& dmatcher );
|
||||
virtual ~BOWImgDescriptorExtractor(){}
|
||||
|
||||
void setVocabulary( const Mat& vocabulary );
|
||||
const Mat& getVocabulary() const { return vocabulary; }
|
||||
void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor,
|
||||
|
@ -84,7 +84,7 @@ Mat BOWKMeansTrainer::cluster() const
|
||||
Mat mergedDescriptors( descCount, descriptors[0].cols, descriptors[0].type() );
|
||||
for( size_t i = 0, start = 0; i < descriptors.size(); i++ )
|
||||
{
|
||||
Mat submut = mergedDescriptors.rowRange(start, descriptors[i].rows);
|
||||
Mat submut = mergedDescriptors.rowRange(start, start + descriptors[i].rows);
|
||||
descriptors[i].copyTo(submut);
|
||||
start += descriptors[i].rows;
|
||||
}
|
||||
|
2581
samples/cpp/bagofwords_classification.cpp
Normal file
2581
samples/cpp/bagofwords_classification.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user