【发布时间】:2016-10-07 16:01:37
【问题描述】:
我正在尝试按照this 代码来实现 BoF。特别是从这段代码:
//featuresUnclustered contains all the feature descriptors of all images
//Construct BOWKMeansTrainer
//the number of bags
int dictionarySize=200;
//define Term Criteria
TermCriteria tc(CV_TERMCRIT_ITER,100,0.001);
//retries number
int retries=1;
//necessary flags
int flags=KMEANS_PP_CENTERS;
//Create the BoW (or BoF) trainer
BOWKMeansTrainer bowTrainer(dictionarySize,tc,retries,flags);
//cluster the feature vectors
cout<<"starting k-means..."<<endl;
Mat dictionary=bowTrainer.cluster(featuresUnclustered);
//store the vocabulary
FileStorage fs("dictionary.yml", FileStorage::WRITE);
fs << "vocabulary" << dictionary;
fs.release();
我得到dictionary.yaml格式的文件:
%YAML:1.0
vocabulary: !!opencv-matrix
rows: 200
cols: 128
dt: f
data: [ 8.19999981e+00, 1.20000005e+00, 1., 24., 5.82000008e+01,
...
]
现在,我的问题是:每一行代表一个质心(我们有 200 个质心,由 dictionarySize 给出)并且由于 SIFT 的描述符大小为 128 位,每个质心具有相同的维度。那是对的吗?
【问题讨论】: