VlFeat の SIFT 実装を機能させることができたので、2 つの画像記述子のセットを一致させたいと思います。
std::vector
SIFT の特徴ベクトルは 128 要素の float 配列です。以下のスニペットに示すように、記述子リストを s に格納しました。
std::vector<std::vector<float> > ldescriptors = leftImage->descriptors;
std::vector<std::vector<float> > rdescriptors = rightImage->descriptors;
/* KDTree, L1 comparison metric, dimension 128, 1 tree, L1 metric */
VlKDForest* forest = vl_kdforest_new(VL_TYPE_FLOAT, 128, 1, VlDistanceL1);
/* Build the tree from the left descriptors */
vl_kdforest_build(forest, ldescriptors.size(), ldescriptors.data());
/* Searcher object */
VlKDForestSearcher* searcher = vl_kdforest_new_searcher(forest);
VlKDForestNeighbor neighbours[2];
/* Query the first ten points for now */
for(int i=0; i < 10; i++){
int nvisited = vl_kdforestsearcher_query(searcher, &neighbours, 2, rdescriptors[i].data());
cout << nvisited << neighbours[0].distance << neighbours[1].distance;
}
私が知る限り、それはうまくいくはずですが、私が得たのは、距離についてはnan
です。記述子配列の長さはチェックアウトされるため、ツリーにデータが入っているように見えます。キーポイントをプロットしましたが、それらも妥当に見えるため、データはかなり正常です。
私は何が欠けていますか?
こちらのかなりまばらなドキュメント (API へのリンク): http://www.vlfeat.org/api/kdtree.html