def load_depth(path, confidence=None, filter_level=0): if path[-4:] == '.npy': depth_mm = np.load(path) elif path[-4:] == '.png': depth_mm = np.array(Image.open(path)) depth_m = depth_mm.astype(np.float32) / 1000.0 if confidence is not None: depth_m[confidence < filter_level] = 0.0 return o3d.geometry.Image(depth_m)