Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function inquiry #30

Open
mcmingchang opened this issue Oct 28, 2024 · 4 comments
Open

Function inquiry #30

mcmingchang opened this issue Oct 28, 2024 · 4 comments

Comments

@mcmingchang
Copy link

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?

@ingowald
Copy link
Owner

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.

@mcmingchang
Copy link
Author

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

@mcmingchang
Copy link
Author

mcmingchang commented Oct 29, 2024

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.

@mcmingchang
Copy link
Author

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants