MCPcopy Create free account
hub / github.com/Robotics-STAR-Lab/H2-Mapping / get_valid_points

Method get_valid_points

mapping/src/utils/mesh_util.py:46–76  ·  view source on GitHub ↗
(self, frame_poses, depth_maps)

Source from the content-addressed store, hash-verified

44
45 @torch.no_grad()
46 def get_valid_points(self, frame_poses, depth_maps):
47 if isinstance(frame_poses, list):
48 all_points = []
49 print("extracting all points")
50 for i in range(0, len(frame_poses), 5):
51 pose = frame_poses[i]
52 depth = depth_maps[i]
53 points = self.rays_d * depth.unsqueeze(-1)
54 points = points.reshape(-1, 3)
55 points = points @ pose[:3, :3].transpose(-1, -2) + pose[:3, 3]
56 if len(all_points) == 0:
57 all_points = points.detach().cpu().numpy()
58 else:
59 all_points = np.concatenate(
60 [all_points, points.detach().cpu().numpy()], 0)
61 print("downsample all points")
62 all_points = self.downsample_points(all_points)
63 return all_points
64 else:
65 pose = frame_poses
66 depth = depth_maps
67 points = self.rays_d * depth.unsqueeze(-1)
68 points = points.reshape(-1, 3)
69 points = points @ pose[:3, :3].transpose(-1, -2) + pose[:3, 3]
70 if self.depth_points is None:
71 self.depth_points = points.detach().cpu().numpy()
72 else:
73 self.depth_points = np.concatenate(
74 [self.depth_points, points], 0)
75 self.depth_points = self.downsample_points(self.depth_points)
76 return self.depth_points
77
78 @torch.no_grad()
79 def create_mesh(self, decoder, map_states, voxel_size, voxels,

Callers 1

create_meshMethod · 0.95

Calls 1

downsample_pointsMethod · 0.95

Tested by

no test coverage detected