Pytorch3d: How to get the positions of 2d verts after render from the 3D verts

Created on 10 Sep 2020  路  4Comments  路  Source: facebookresearch/pytorch3d

Hi, I am now using pytorch3d on 3D face reconstruction, but there are some small problems, I cannot get 2D landmarks from 3D vertexs
the codes follows blew:

verts, faces, aux = load_obj(trg_obj)
mesh = Meshes([verts], [faces.verts_idx], face_color)
images = renderer(mesh)

but how to get 2d verts after render from the 3D verts

Thanks

how to

Most helpful comment

Hi, if you want to get the vertices on screen, you can just use transform in the rasterizer.

verts, faces, aux = load_obj(trg_obj)
mesh = Meshes([verts], [faces.verts_idx], face_color)
mesh_on_screen = renderer.rasterizer.transform(mesh)

# Visualize vetex positions on screen
verts_on_screen = mesh_on_screen.verts_packed().detach().cpu().numpy()
plt.plot(verts_on_screen[:, 0], verts_on_screen[:, 1], 'ro')

Thanks,

All 4 comments

Hi, if you want to get the vertices on screen, you can just use transform in the rasterizer.

verts, faces, aux = load_obj(trg_obj)
mesh = Meshes([verts], [faces.verts_idx], face_color)
mesh_on_screen = renderer.rasterizer.transform(mesh)

# Visualize vetex positions on screen
verts_on_screen = mesh_on_screen.verts_packed().detach().cpu().numpy()
plt.plot(verts_on_screen[:, 0], verts_on_screen[:, 1], 'ro')

Thanks,

Thanks @matsuren for replying to this! Yes you can transform the 3D vertices using the rasterizer.transform which will apply the camera transformations passed into the rasterizer.

@matsuren thanks

Closing this issue! Feel free to reopen if you have more questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

unlugi picture unlugi  路  3Comments

aluo-x picture aluo-x  路  3Comments

eliemichel picture eliemichel  路  3Comments

cihanongun picture cihanongun  路  3Comments

NotAnyMike picture NotAnyMike  路  3Comments