kaolin icon indicating copy to clipboard operation
kaolin copied to clipboard

how to get the non-normalize depth value?

Open HaoZhang990127 opened this issue 2 years ago • 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.

HaoZhang990127 avatar Mar 27 '23 21:03 HaoZhang990127

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

Caenorst avatar Mar 27 '23 22:03 Caenorst

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) 

HaoZhang990127 avatar Mar 27 '23 22:03 HaoZhang990127

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)

Caenorst avatar Mar 27 '23 23:03 Caenorst

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

Thank you for your reply.

HaoZhang990127 avatar Mar 29 '23 12:03 HaoZhang990127

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

Caenorst avatar Mar 30 '23 13:03 Caenorst