本文整理汇总了C++中KDTree::KDTree_build方法的典型用法代码示例。如果您正苦于以下问题:C++ KDTree::KDTree_build方法的具体用法?C++ KDTree::KDTree_build怎么用?C++ KDTree::KDTree_build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDTree
的用法示例。
在下文中一共展示了KDTree::KDTree_build方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_matchs
void Panorama::create_matchs()
{
KDTree kd;
Node *nodes = new Node[features.size()];
kd.KDTree_build(nodes, &(featureData[0]), features.size(), 128);
int *numMatchOf_i = new int[images.size()]();
#define _K 4
int max_match = min(_K, (int)images.size()-1);
for (int i = 0; i < features.size(); ++i) {
int *target = &featureData[128*i];
int indice[_K];
kd.find_kNN(indice, target, max_match, i);
for (int j = 0; j < max_match; ++j) {
int iMatch = indice[j];
Feature f1 = features[i];
Feature f2 = features[iMatch];
if (f1.iid != f2.iid) {
MatchPair match = {f1, f2};
matchs.push_back(match);
++(numMatchOf_i[f1.iid]);
}
}
#undef _K
}
vector<MatchPair>::iterator op = matchs.begin();
vector<MatchPair>::iterator ed = matchs.begin();
for (int i = 0; i < imageNames.size(); ++i) {
op = ed;
ed += numMatchOf_i[i];
sort(op, ed, compare_match);
}
create_match_info();
FILE *fp = fopen("matchs_0.txt", "w");
print_matchs(fp, matchs);
fclose(fp);
fp = fopen("imatchs_0.txt", "w");
print_imatchs(fp, imageMatchInfos);
fclose(fp);
delete[] numMatchOf_i;
// featureData is not needed anymore, it is very large, so free its memory
// Note: clear() will not free the memory
vector<int> emptyVec(0);
emptyVec.swap(featureData);
delete[] nodes;
}