Open Philip035 opened 1 year ago
When I use flann to perform KNN search on the same data, the result seems to be random in every test. Here is my code:
vector<vector<int>> Poi_kNN_Idx(Poi_In_Ipl_Num, vector<int>(Ngh_K)); vector<vector<double>> Dis_kNN(Poi_In_Ipl_Num, vector<double>(Ngh_K)); flann::Matrix<double> dataMatrix(Poi_In_Ref_Tmp, Poi_In_Ref_Num, 3); flann::Index<flann::L2<double>> index(dataMatrix, flann::KDTreeIndexParams(4)); index.buildIndex(); flann::Matrix<double> queryMatrix(Poi_In_Ipl_Tmp, Poi_In_Ipl_Num, 3); index.knnSearch(queryMatrix, Poi_kNN_Idx, Dis_kNN, Ngh_K, flann::SearchParams(128));
where Poi_In_Ref_Tmp and Poi_In_Ipl_Tmp are defined as double*, and xyz coordinates of each point are stored in turn. However, the result of Poi_kNN_Idx seems to be unfixed.
Poi_In_Ref_Tmp
Poi_In_Ipl_Tmp
double*
Poi_kNN_Idx
The default method is randomised kd-trees therefore the results are random, too. The algorithms are described here: https://www.cs.ubc.ca/~lowe/papers/09muja.pdf
When I use flann to perform KNN search on the same data, the result seems to be random in every test. Here is my code:
where
Poi_In_Ref_Tmp
andPoi_In_Ipl_Tmp
are defined asdouble*
, and xyz coordinates of each point are stored in turn. However, the result ofPoi_kNN_Idx
seems to be unfixed.