4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 10:34:29 +08:00

Fix edge case of depth colormap (#3139)

If the user sets near_plane as 0.0, the "or" will take the second term (float(torch.min(depth))) instead of using the 0.0 value.  We fix this by checking explicitely for a "None" variable
This commit is contained in:
Feez2403 2024-05-12 03:38:13 +02:00 committed by GitHub
parent 7ba02be8cf
commit ffbd16a375
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,8 +134,8 @@ def apply_depth_colormap(
Colored depth image with colors in [0, 1]
"""
near_plane = near_plane or float(torch.min(depth))
far_plane = far_plane or float(torch.max(depth))
near_plane = near_plane if near_plane is not None else float(torch.min(depth))
far_plane = far_plane if far_plane is not None else float(torch.max(depth))
depth = (depth - near_plane) / (far_plane - near_plane + 1e-10)
depth = torch.clip(depth, 0, 1)