NVIDIAGameWorks/kaolin

how to get the non-normalize depth value?

HaoZhang990127 opened this issue · 5 comments

Hi,

Thank you for you amazing project.
Now when I use
depth_map, _ = kal.render.mesh.rasterize(dims[1], dims[0], face_vertices_camera[:, :, :, -1], face_vertices_image, face_vertices_camera[:, :, :, -1:])#torch.Size([1, 1024, 1024, 1])

to get depth map, I find the depth is in the range of 0 to 1, how can I get the non-normalize depth map with true distance?

Thank you.

Hi @HaoZhang990127 , the rasterization is not normalizing the values that are interpolated, how have you produced the face_vertices_camera values?

Hi,
thank you for your reply,
this is face_vertices_camera function

face_vertices_camera, face_vertices_image, face_normals = kal.render.mesh.prepare_vertices(
                verts.to(self.device), faces.to(self.device), self.camera_projection, camera_transform=camera_transform)

this is self.camera_projection
kal.render.camera.generate_perspective_projection(np.pi / 3).to(device)

this is camera_transform

camera_transform = self.get_camera_from_view(torch.tensor(elev), torch.tensor(azim), r=radius,
                                                look_at_height=look_at_height).to(self.device) 

the face_vertices_camera is only post extrinsics, so the depth you are seeing is not normalized.

Do mind that the current depth that you are display is the distance to camera plane, depending the definition of "depth" you may have to interpolate the whole face_camera instead of z and then compute the norm (torch.linalg.norm)

i find that i normalize the vertices of mesh, it cause the rendered depth in range 0 to 1.

Thank you for your reply.

Can you try to move the camera away from the model ? you should see the depth increase