【问题标题】:OpenCV, vocabulary matrix obtained by BOWKMeansTrainerOpenCV,BOWKMeansTrainer得到的词汇矩阵
【发布时间】: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 位,每个质心具有相同的维度。那是对的吗?

【问题讨论】:

    标签: c++ opencv k-means


    【解决方案1】:

    每一行代表一个质​​心(我们有 200 个质心,由dictionarySize 给出)并且由于 SIFT 的描述符大小为 128 位,因此每个质心具有相同的维度。对吗?

    是的,正确的。

    好吧,SIFT 有 128 个值(不是 bit)。在 OpenCV 中,每个值都是float,即 32 位。但是是的,每个质心都有 128 个值。


    k-means (dictionarySize) 的K 是质心数。每个质心与您使用的特征具有相同的维度N,因此 SIFT 为 128。

    字典将是一个矩阵K x N,在本例中为200 X 128


    请记住,BoW 直方图(它是使用字典计算的全局描述符)将具有 K 值。

    【讨论】:

    • 糟糕,我的错!但是,如果我们谈论的是二进制描述符,例如 ORB,情况就是如此;)
    • 我的意思是,假设二进制描述符是 128 维(因此是 128 位)。只是说。
    • 是的,没问题 ;D 很高兴它有帮助!
    猜你喜欢
    • 2016-05-11
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多