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 authored and GitHub committed 2024-05-11 21:38:13 -04:00
1 parent 7ba02be8cf
commit ffbd16a375
1 file changed
+2 -2
+2 -2
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)