def backproject_depth(self, depth):
constant_x = 1.0 / self.focal_x
constant_y = 1.0 / self.focal_y
row, col = depth.shape
coords = np.zeros((row, col, 2), dtype=np.uint)
coords[..., 0] = np.arange(row)[:, None]
coords[..., 1] = np.arange(col)
coords = coords.reshape((-1, 2))
output = np.zeros((len(coords), 3))
values = depth[coords[:, 0], coords[:, 1]]
output[:, 0] = (coords[:, 1] - self.center_x) * values * constant_x
output[:, 1] = (coords[:, 0] - self.center_y) * values * constant_y
output[:, 2] = values
return output
评论列表
文章目录