本文整理汇总了C++中Loader::loadMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::loadMatrix方法的具体用法?C++ Loader::loadMatrix怎么用?C++ Loader::loadMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::loadMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validate
void validate(const char *fileName, const int K, const int dim, const int method, const T maxRadius)
{
typedef Nabo::NearestNeighbourSearch<T, CloudType> NNS;
typedef vector<NNS*> NNSV;
typedef typename NNS::Matrix Matrix;
typedef typename NNS::Vector Vector;
typedef typename NNS::IndexMatrix IndexMatrix;
Loader<T, CloudType> loader;
loader.loadMatrix(fileName);
// check if file is ok
const CloudType d = loader.getValue();
if (d.rows() != dim)
{
cerr << "Provided data has " << d.rows() << " dimensions, but the requested dimensions were " << dim << endl;
exit(2);
}
if (K >= d.cols())
{
cerr << "Requested more nearest neighbour than points in the data set" << endl;
exit(2);
}
// create different methods
NNSV nnss;
unsigned searchTypeCount(NNS::SEARCH_TYPE_COUNT);
#ifndef HAVE_OPENCL
searchTypeCount -= 3;
#endif // HAVE_OPENCL
for (unsigned i = 0; i < searchTypeCount; ++i)
nnss.push_back(NNS::create(d, d.rows(), typename NNS::SearchType(i)));
//nnss.push_back(new KDTreeBalancedPtInLeavesStack<T>(d, false));
// check methods together
const int itCount(method != -1 ? method : d.cols() * 2);
/*
// element-by-element search
typedef typename NNS::IndexVector IndexVector;
for (int i = 0; i < itCount; ++i)
{
const Vector q(createQuery<T>(d, *nnss[0], i, method));
const IndexVector indexes_bf(nnss[0]->knn(q, K, 0, NNS::SORT_RESULTS));
for (size_t j = 1; j < nnss.size(); ++j)
{
const IndexVector indexes_kdtree(nnss[j]->knn(q, K, 0, NNS::SORT_RESULTS));
if (indexes_bf.size() != K)
{
cerr << "Different number of points found between brute force and request" << endl;
exit(3);
}
if (indexes_bf.size() != indexes_kdtree.size())
{
cerr << "Different number of points found between brute force and NNS type "<< j << endl;
exit(3);
}
for (size_t k = 0; k < size_t(K); ++k)
{
Vector pbf(d.col(indexes_bf[k]));
//cerr << indexes_kdtree[k] << endl;
Vector pkdtree(d.col(indexes_kdtree[k]));
if (fabsf((pbf-q).squaredNorm() - (pkdtree-q).squaredNorm()) >= numeric_limits<float>::epsilon())
{
cerr << "Method " << j << ", cloud point " << i << ", neighbour " << k << " of " << K << " is different between bf and kdtree (dist " << (pbf-pkdtree).norm() << ")\n";
cerr << "* query:\n";
cerr << q << "\n";
cerr << "* indexes " << indexes_bf[k] << " (bf) vs " << indexes_kdtree[k] << " (kdtree)\n";
cerr << "* coordinates:\n";
cerr << "bf: (dist " << (pbf-q).norm() << ")\n";
cerr << pbf << "\n";
cerr << "kdtree (dist " << (pkdtree-q).norm() << ")\n";
cerr << pkdtree << endl;
exit(4);
}
}
}
}
*/
// create big query
// check all-in-one query
Matrix q(createQuery<T>(d, itCount, method));
IndexMatrix indexes_bf(K, q.cols());
Matrix dists2_bf(K, q.cols());
nnss[0]->knn(q, indexes_bf, dists2_bf, K, 0, NNS::SORT_RESULTS, maxRadius);
assert(indexes_bf.cols() == q.cols());
for (size_t j = 1; j < nnss.size(); ++j)
{
IndexMatrix indexes_kdtree(K, q.cols());
Matrix dists2_kdtree(K, q.cols());
nnss[j]->knn(q, indexes_kdtree, dists2_kdtree, K, 0, NNS::SORT_RESULTS, maxRadius);
if (indexes_bf.rows() != K)
{
cerr << "Different number of points found between brute force and request" << endl;
exit(3);
}
if (indexes_bf.cols() != indexes_kdtree.cols())
{
cerr << "Different number of points found between brute force and NNS type "<< j << endl;
//.........这里部分代码省略.........