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

How can I get the closest point on mesh of given points? #193

Closed
linpeisensh opened this issue May 12, 2020 · 11 comments
Closed

How can I get the closest point on mesh of given points? #193

linpeisensh opened this issue May 12, 2020 · 11 comments
Assignees
Labels
how to How to use PyTorch3D in my project

Comments

@linpeisensh
Copy link

Thank you for your excellent work!

Here is my problems:

Is there function in pytorch3d returns closest point on mesh of given points?

If not, is there function returns the distance between all points on mesh and given points?

Is there any advises to my title problem?

Thank you for your time!

@bottler
Copy link
Contributor

bottler commented May 12, 2020

The function loss.point_mesh_distance.point_face_distance gives you the distances of closest points on a mesh to the given points, and the indices of the faces which contain those closest points.

@linpeisensh
Copy link
Author

Thank you for your reply!

After get these faces, should I use sample from these faces and get the closest point?

The function loss.point_mesh_distance.point_face_distance gives you the distances of closest points on a mesh to the given points, and the indices of the faces which contain those closest points.

@linpeisensh
Copy link
Author

Sorry, I run the function loss.point_mesh_distance.point_mesh_edge_distance and only get a distance (as I read in your readthedocs), I have no idea how to use it to get the closest point on mesh of given points.

@gkioxari gkioxari self-assigned this May 12, 2020
@gkioxari gkioxari added the how to How to use PyTorch3D in my project label May 12, 2020
@gkioxari
Copy link
Contributor

Hi @linpeisensh
The point_mesh_distance returns the squared euclidian distance of a point in a pointcloud to the closest face in the meshes. It doesn't expose the index of that face. However, PointFaceDistanceForward does

std::tuple<torch::Tensor, torch::Tensor> PointFaceDistanceForward(

So you will have to call _C.point_face_dist_forward in your code.

m.def("point_face_dist_forward", &PointFaceDistanceForward);

Here is an example how:

dists, idxs = _C.point_face_dist_forward(

@linpeisensh
Copy link
Author

@gkioxari
Thank you for your reply!
I can get this index now.
What I want to get is the closest point on the mesh of given points,.
So I should create a new mesh (only this face) and sample from it to get the closest point. Do you think this works or do you have any better solution.
Thank you!

@gkioxari
Copy link
Contributor

If I understand correctly, your mesh has only one face? If yes, then yeah you can create a tiny mesh consisting of 3 vertices and one triangular face and pass it through this function, along with the points.

@linpeisensh
Copy link
Author

I have an idea now.

Thank you for your reply!

Best

@gkioxari
Copy link
Contributor

Good luck! I am closing this issue :)

@Gaozhongpai
Copy link

@gkioxari
Thank you for your reply!
I can get this index now.
What I want to get is the closest point on the mesh of given points,.
So I should create a new mesh (only this face) and sample from it to get the closest point. Do you think this works or do you have any better solution.
Thank you!

Hi, do you know how to obtain the closest points on the mesh of given points, not just the distances and indices? Thank you very much.

@HelloRicky123
Copy link

@gkioxari
Thank you for your reply!
I can get this index now.
What I want to get is the closest point on the mesh of given points,.
So I should create a new mesh (only this face) and sample from it to get the closest point. Do you think this works or do you have any better solution.
Thank you!

Hi, do you know how to obtain the closest points on the mesh of given points, not just the distances and indices? Thank you very much.

Hi, have you found any solution? Pytorch3d is 100 times faster than trimesh, but I do not know how to get the location here.

@gkioxari
Copy link
Contributor

gkioxari commented Jan 9, 2022

Please check the reply to the issue #1016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
how to How to use PyTorch3D in my project
Projects
None yet
Development

No branches or pull requests

5 participants