kdtree build with eigen matrix not work as kdtree build use open3d geometry.
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
### Checklist
- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).
### Describe the issue
When I run these code, every thing works fine,
```
std::vector centers;
Eigen::MatrixXd BC;
igl::barycenter(V,F, BC);
for (size_t i = 0; i < BC.rows(); i++)
{
centers.emplace_back(BC(i, 0), BC(i, 1), BC(i, 2));
}
auto pcd = std::make_shared();
pcd->points_ = centers;
auto kdtree = open3d::geometry::KDTreeFlann(*pcd);
// get points nearby
std::vector indices;
std::vector dists;
kdtree.SearchRadius(vertice, 0.008, indices, dists);
```
but when change to
```
Eigen::MatrixXd BC;
igl::barycenter(V,F, BC);
auto kdtree = open3d::geometry::KDTreeFlann(BC);
// get points nearby
std::vector indices;
std::vector dists;
kdtree.SearchRadius(vertice, 0.008, indices, dists);
```
I just got empty indices as a result.
### Steps to reproduce the bug
```python
#include
#include
#include
#include
#include
using namespace open3d;
using namespace Eigen;
using namespace std;
int main() {
// Example data (vertices V and faces F), replace with your actual data
Eigen::MatrixXd V; // Replace with your vertex data
Eigen::MatrixXi F; // Replace with your face data
// Method 1: Constructing KDTree using PointCloud
Eigen::MatrixXd BC1;
igl::barycenter(V, F, BC1);
std::vector centers;
for (size_t i = 0; i < BC1.rows(); i++) {
centers.emplace_back(BC1(i, 0), BC1(i, 1), BC1(i, 2));
}
auto pcd = std::make_shared();
pcd->points_ = centers;
KDTreeFlann kdtree1(*pcd);
std::vector indices1;
std::vector dists1;
kdtree1.SearchRadius(/* Replace with a target point coordinate */, 0.008, indices1, dists1);
cout << "Method 1 - Found points: " << indices1.size() << endl;
// Method 2: Directly using Eigen::MatrixXd to construct KDTree
Eigen::MatrixXd BC2;
igl::barycenter(V, F, BC2);
KDTreeFlann kdtree2(BC2);
std::vector indices2;
std::vector dists2;
kdtree2.SearchRadius(/* Replace with a target point coordinate */, 0.008, indices2, dists2);
cout << "Method 2 - Found points: " << indices2.size() << endl;
return 0;
}
```
### Error message
_No response_
### Expected behavior
These two method to use kdtree should return same result.
### Open3D, Python and System information
```markdown
- Operating system: Windows 10 64-bit
- Open3D version: 0.15.0`
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): Visual Studio 2019 Release amd64
```
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.