Skip to content

How to get the uv positions of vertices in a torch tensor effectively? #586

@aGIToz

Description

@aGIToz

Hello all,
Big thanks for your endeavors in bringing machine learning to 3D world !

Here is my question :
I load an obj file.

verts, faces, aux = load_obj("obj.obj")

I can easily check
image

I can also see each face is composed by which nodes and which texture_ids :
image

Above here, one can see that the zeroth face (faces[0]) is constructed of the vertices [1,2,0] and texture_idx [0,1,2].

From the faces.texture_idx and aux.verts_uv I can find uv position of the each face
image

Like above here, I look for position of the zeroth face in the uv plane and aux.verts_idx[0], aux.verts_idx[1] and aux.vert_idx[2] gives me the position of the faces[0] in the uv plane (if I am wrong here then please correct me).

Also by looking at faces.verts_idx[0] and faces_texture_idx[0], I understand that vertex 1 corresponds to texture_idx 0 (and so vertices 2 and 0 to texture_idx 1 and 2 respectively ). Which means that uv position of the vertex 1 is given by aux.verts_uvs[0] i.e. tensor([0.9934, 0.4822]) and hence for the other two vertices 2 and 0, I can get their uv position (again, correct if I am wrong here).

My question is how to get the those uv positions of all the vertices [0, 1, 2, 3, ... 117] in a torch tensor? I can think of way in loops, but is there an effective way get the uv positions of the vertices?

Metadata

Metadata

Assignees

Labels

how toHow to use PyTorch3D in my project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions