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

Function setup_camera

utils/recon_utils.py:4–28  ·  view source on GitHub ↗
(w, h, k, w2c, near=0.01, far=100)

Source from the content-addressed store, hash-verified

2from diff_gaussian_rasterization import GaussianRasterizationSettings as Camera
3
4def setup_camera(w, h, k, w2c, near=0.01, far=100):
5 fx, fy, cx, cy = k[0][0], k[1][1], k[0][2], k[1][2]
6 w2c = torch.tensor(w2c).cuda().float()
7 cam_center = torch.inverse(w2c)[:3, 3]
8 w2c = w2c.unsqueeze(0).transpose(1, 2)
9 opengl_proj = torch.tensor([[2 * fx / w, 0.0, -(w - 2 * cx) / w, 0.0],
10 [0.0, 2 * fy / h, -(h - 2 * cy) / h, 0.0],
11 [0.0, 0.0, far / (far - near), -(far * near) / (far - near)],
12 [0.0, 0.0, 1.0, 0.0]]).cuda().float().unsqueeze(0).transpose(1, 2)
13 full_proj = w2c.bmm(opengl_proj)
14 cam = Camera(
15 image_height=h,
16 image_width=w,
17 tanfovx=w / (2 * fx),
18 tanfovy=h / (2 * fy),
19 # change: rgb和depth合成一个channel输入,这里需要修改,不然在cuda算子里面加起来会报错
20 bg=torch.tensor([0, 0, 0, 0, 0, 0], dtype=torch.float32, device="cuda"),
21 scale_modifier=1.0,
22 viewmatrix=w2c,
23 projmatrix=full_proj,
24 sh_degree=0,
25 campos=cam_center,
26 prefiltered=False
27 )
28 return cam

Callers 2

evalFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected