#include #include #include using namespace flann; int main(int argc, char** argv) { int nn = 3; Matrix dataset; Matrix query; load_from_file(dataset, "dataset.hdf5","dataset"); load_from_file(query, "dataset.hdf5","query"); Matrix indices(new int[query.rows*nn], query.rows, nn); Matrix dists(new float[query.rows*nn], query.rows, nn); // construct an randomized kd-tree index using 4 kd-trees Index > index(dataset, flann::KDTreeIndexParams(4)); index.buildIndex(); // do a knn search, using 128 checks index.knnSearch(query, indices, dists, nn, flann::SearchParams(128)); flann::save_to_file(indices,"result.hdf5","result"); delete[] dataset.ptr(); delete[] query.ptr(); delete[] indices.ptr(); delete[] dists.ptr(); return 0; }