MCPcopy Create free account
hub / github.com/IRMVLab/SemGauss-SLAM / get_pointcloud

Function get_pointcloud

utils/keyframe_selection.py:10–37  ·  view source on GitHub ↗
(depth, intrinsics, w2c, sampled_indices)

Source from the content-addressed store, hash-verified

8
9
10def get_pointcloud(depth, intrinsics, w2c, sampled_indices):
11 CX = intrinsics[0][2]
12 CY = intrinsics[1][2]
13 FX = intrinsics[0][0]
14 FY = intrinsics[1][1]
15
16 # Compute indices of sampled pixels
17 xx = (sampled_indices[:, 1] - CX)/FX
18 yy = (sampled_indices[:, 0] - CY)/FY
19 depth_z = depth[0, sampled_indices[:, 0], sampled_indices[:, 1]]
20
21 # Initialize point cloud
22 pts_cam = torch.stack((xx * depth_z, yy * depth_z, depth_z), dim=-1)
23 pts4 = torch.cat([pts_cam, torch.ones_like(pts_cam[:, :1])], dim=1)
24 c2w = torch.inverse(w2c)
25 pts = (c2w @ pts4.T).T[:, :3]
26
27 # Remove points at camera origin
28 A = torch.abs(torch.round(pts, decimals=4))
29 B = torch.zeros((1, 3)).cuda().float()
30 _, idx, counts = torch.cat([A, B], dim=0).unique(
31 dim=0, return_inverse=True, return_counts=True)
32 mask = torch.isin(idx, torch.where(counts.gt(1))[0])
33 invalid_pt_idx = mask[:len(A)]
34 valid_pt_idx = ~invalid_pt_idx
35 pts = pts[valid_pt_idx]
36
37 return pts
38
39
40def keyframe_selection_overlap(gt_depth, w2c, intrinsics, keyframe_list, k, pixels=1600):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected