jlblancoc / nanoflann

nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees
Other
2.24k stars 491 forks source link

The result of nanoflann returned #196

Open whu-lyh opened 1 year ago

whu-lyh commented 1 year ago
nanoflann::KdTreeFLANN<PB::pmPointXYZ>::Ptr kdtree = std::make_shared<nanoflann::KdTreeFLANN<PB::pmPointXYZ>>();
if (!kdtree) {
    std::cerr << "KD tree build failed!" << std::endl;
    return;
}
kdtree->setInputCloud(cloud);
for (int i = 0; i < checkcorrs.size(); ++i) {
    std::vector<int> searchIndexes;
    std::vector<SCALAR_TYPE> distances;
    SCALAR_TYPE *search_pt = new SCALAR_TYPE[3];
    search_pt[0] = checkcorrs[i].x;
    search_pt[1] = checkcorrs[i].y;
    search_pt[2] = checkcorrs[i].z;
    kdtree->radiusSearch(search_pt, 2.0, searchIndexes, distances);
}

The size of searchIndexes is always equal to 1 during the for-loop(I have checked the point that the number of the nearest point is large), and once the searched point's distance is too large(e.g. distance>10m ), the searchIndexes[0] also be same with the i-1 iteration result. What's the point? Is this a bug?

whu-lyh commented 1 year ago

forget to mention that I write a adaptor of the original nanoflann kdtree class for better usage.

jlblancoc commented 1 year ago

Hi @whu-lyh :

Please, we would need a complete, minimum size, full code (a CMakeLists.txt + test.cpp) and data (if applicable) to verify what's going on.

whu-lyh commented 1 year ago

@jlblancoc , thanks for the reply but I could not provide the minimum size code for now, and I implement the kdtree search operation with CoudCompare octree for the deadline of project in a hurry. I will try to reproduce this bug.