-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_reduce_kmeans_baseline.cpp
32 lines (24 loc) · 1.19 KB
/
read_reduce_kmeans_baseline.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "read_reduce_kmeans.h"
void read_readuce_kmeans_baseline()
{
vector<string> trainposfiles;
getImagenamelist(train_pos_shotfilename,"trainpos", NUM_POS_TRAIN,trainposfiles);
cout<<"Total number of examples is "<<trainposfiles.size()<<endl;
cv::Mat allfeatures = cvCreateMat(0,featureDimension_baseline,CV_32FC1);
int imgnum = 0;
for(; imgnum < NUM_POS_TRAIN; imgnum++ )
{
cout<<"inside image # "<<imgnum<<endl;
read_reduce_baseline_desc(trainposfiles[imgnum],allfeatures,5000,"trainpos");
}
cout<<"Total number of features used for kmeans are "<<allfeatures.rows<<endl;
cout<<"Read all the training features. run k means to create a vocabulary"<<endl;
cout<<"Start k means "<<endl;
cv::Mat dictionary = cvCreateMat(dictionarySize,featureDimension_baseline,CV_32FC1);
cv::Mat labels = cvCreateMat(allfeatures.rows,1,CV_32FC1);
double* retkmeans = doKmeans(allfeatures,dictionary,dictionarySize,labels);
cout<<"Completed Kmeans. Going to write the dictionary now"<<endl;
// WRITE DICTIONARY
writeDictionary(dictionary,dictionarySize,retkmeans[0],retkmeans[1],"baseline");
cout<<"completed writing the dictionary"<<endl;
}