facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.7k stars 1.3k forks source link

Create Mesh from faces and vertices #1633

Closed juliuskuehn1 closed 1 year ago

juliuskuehn1 commented 1 year ago

Hello,

I want to visualize meshes. I only have their faces and vertices in arrays. So, is it possible to create a mesh with pytorch3d that is not being loaded from file (like an .obj) but only from their faces and vertices?

bottler commented 1 year ago

Yes, this is very easy. See the doc in pytorch3d/structures/meshes.py.

Basically you need to make pytorch tensors from your arrays. Then if faces are a (N,3) int64 tensor and verts are (V, 3) float32 tensor you can write mesh = Meshes(verts=[verts], faces=[faces]).

You can visualise with plotly with plot_batch_individually(mesh)

juliuskuehn1 commented 1 year ago

Thank you