0
我试图按照this代码来实现BoF。尤其是这样的代码:OpenCV,由BOWKMeansTrainer获得的词汇矩阵
//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位,所以每个质心具有相同的维度。那是对的吗?
哎呀,我的错!如果我们讨论的是二进制描述符,就像ORB一样;) – justHelloWorld
我的意思是,假设二进制描述符有128个维度(以及128位)。只是在说'。 – justHelloWorld
是的,没问题; D很高兴帮助! – Miki