added sample on BOW usage to image classification (training and testing is on Pascal VOC dataset)

This commit is contained in:
Maria Dimashova 2010-10-08 13:17:34 +00:00
parent 66df8ef06c
commit 9f934363e5
3 changed files with 2588 additions and 3 deletions

View File

@ -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,

View File

@ -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;
}

File diff suppressed because it is too large Load Diff