MCPcopy Create free account
hub / github.com/cxmomo/RaCFormer / points2depthmap

Method points2depthmap

loaders/pipelines/loading.py:323–346  ·  view source on GitHub ↗
(self, points, height, width)

Source from the content-addressed store, hash-verified

321
322
323 def points2depthmap(self, points, height, width):
324 height, width = height // self.downsample, width // self.downsample
325 # depth_map = torch.zeros((height, width), dtype=torch.float32)
326 # coor = torch.round(points[:, :2] / self.downsample)
327 depth_map = np.zeros((height, width), dtype=np.float32)
328 coor = np.round(points[:, :2] / self.downsample)
329 depth = points[:, 2]
330 kept1 = (coor[:, 0] >= 0) & (coor[:, 0] < width) & (
331 coor[:, 1] >= 0) & (coor[:, 1] < height) & (
332 depth < self.grid_config['depth'][1]) & (
333 depth >= self.grid_config['depth'][0])
334
335 coor, depth = coor[kept1], depth[kept1]
336 ranks = coor[:, 0] + coor[:, 1] * width
337 sort = (ranks + depth / 100.).argsort()
338 coor, depth, ranks = coor[sort], depth[sort], ranks[sort]
339
340 kept2 = np.ones(coor.shape[0], dtype=np.bool)
341 kept2[1:] = (ranks[1:] != ranks[:-1])
342 coor, depth = coor[kept2], depth[kept2]
343 # coor = coor.to(torch.long)
344 coor = coor.astype(np.int64)
345 depth_map[coor[:, 1], coor[:, 0]] = depth
346 return depth_map
347
348 def _load_points(self, pts_filename):
349 """Private function to load point clouds data.

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected