Open mcmingchang opened 3 weeks ago
Send me an email, pls; i'm not sure i fully understand what you're trying to do, and k-d tree might not be the best place to start in the first place.
https://github.com/isl-org/Open3D/blob/main/cpp/open3d/pipelines/registration/FastGlobalRegistration.cpp ,at line 25, we perform kdtree construction. At line 34, we execute the index of knn.
https://github.com/isl-org/Open3D/blob/main/cpp/open3d/pipelines/registration/Feature.h In line 30, we can know the construction method of the feature.
https://github.com/isl-org/Open3D/blob/main/cpp/open3d/pipelines/registration/Feature.cpp In line 98, we can know the dimension of feature.data_
So we need to modify the code to use data from Eigen:: Matrix<float, 33, 1>for kdtree construction, even for Eigen:: Matrix<float, Eigen:: Dynamic, 1>, so that we can dynamically adjust the dimensions
I added the following code to the cukd-math. h file
template<> struct num_dims_of<Eigen::Matrix<float, 33, 1>> { enum { value = 33 }; }; inline both float get_coord(const Eigen::Matrix<float, 33, 1>& v, int d) { return v(d); } inline both float &get_coord(Eigen::Matrix<float, 33, 1> &v, int d) { return v(d); } inline both void set_coord(Eigen::Matrix<float, 33, 1> &v, int d, float vv) { v(d) = vv; } inline both Eigen::Matrix<float, 33, 1> operator-(Eigen::Matrix<float, 33, 1> a, Eigen::Matrix<float, 33, 1> b) { return a-b; } inline both float dot(Eigen::Matrix<float, 33, 1> a, Eigen::Matrix<float, 33, 1> b) { return a.dot(b); } inline both Eigen::Matrix<float, 33, 1> min(Eigen::Matrix<float, 33, 1> a, Eigen::Matrix<float, 33, 1> b) { Eigen::MatrixXf c(a.rows(), 2); c.col(0) = a; c.col(1) = b; return c.rowwise().minCoeff(); } inline both Eigen::Matrix<float, 33, 1> max(Eigen::Matrix<float, 33, 1> a, Eigen::Matrix<float, 33, 1> b) { Eigen::MatrixXf c(a.rows(), 2); c.col(0) = a; c.col(1) = b; return c.rowwise().maxCoeff(); }
Running spatial-kdtree build and knn index did not report any errors, but knn's result is incorrect.
I found a strange bug and have fixed it. The program can now output the correct results. It would be great if future projects could officially be compatible with Eigen's data.
The repaired code is
inline both Eigen::Matrix<float, 33, 1> operator-(Eigen::Matrix<float, 33, 1> a, Eigen::Matrix<float, 33, 1> b) { Eigen::Matrix<float, 33, 1> c; for (int i = 0; i < 33; i++) { c(i) = a(i) - b(i); } return c; }
I am currently upgrading Open3D to Open3D CUDA,your open source has great speed and accuracy in point cloud clustering.
I need to convert Eigen:: Vector3f to float3 for clustering point clouds, which is not a problem, but the fgr algorithm requires clustering thousands of Eigen:: Matrix<float, 33, 1>data. I think the algorithm only supports float3 and float4. How should I modify it?