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
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.
Most helpful comment
Hi, if you want to get the vertices on screen, you can just use
transformin the rasterizer.Thanks,