MCPcopy
hub / github.com/zju3dv/4K4D / test_manual_pulsar_rendering

Function test_manual_pulsar_rendering

tests/pulsar_points_rendering_tests.py:113–139  ·  view source on GitHub ↗
(pcd=pcd, feat=feat, radius=radius)

Source from the content-addressed store, hash-verified

111
112
113def test_manual_pulsar_rendering(pcd=pcd, feat=feat, radius=radius):
114 if isinstance(radius, torch.Tensor): radius = radius[..., 0] # remove last dim to make it homogenous for float and tensor
115 batch = add_batch(to_cuda(camera.to_batch()))
116 K, R, T = batch.K, batch.R, batch.T
117 C = -R.mT @ T
118
119 acc = torch.ones_like(feat[..., :1])
120 depth: torch.Tensor = (pcd - C.mT).norm(dim=-1, keepdim=True) # world space depth
121 feat = torch.cat([feat, acc, depth], dim=-1) # B, N, 3 + C
122
123 pcd = pcd @ R.mT + T.mT # apply w2c conversion
124
125 T = torch.zeros_like(T)
126 R = torch.zeros_like(R)
127 R[..., torch.arange(3), torch.arange(3)] = 1.0 # identity
128 cam_params = get_pulsar_camera_params(R, T[..., 0], K, torch.as_tensor([HEIGHT, WIDTH], device=pcd.device)[None], batch.meta.n.item())
129
130 # NOTE: DOUBLE CHECK MAX DEPTH USAGE
131 feat = pulsar(pcd, feat, radius, cam_params, 5e-5, batch.meta.f.item(), batch.meta.n.item(), torch.zeros(5, device=pcd.device)).flip(1)
132
133 rgb_map, acc_map, dpt_map = feat[..., :3], feat[..., 3:4], feat[..., 4:5]
134 dpt_map = dpt_map + (1 - acc_map) * depth.max()
135 rgb_map, acc_map, dpt_map = torch.cat([rgb_map, acc_map], dim=-1), torch.cat([acc_map, acc_map, acc_map, acc_map], dim=-1), torch.cat([dpt_map, dpt_map, dpt_map, acc_map], dim=-1)
136
137 save_image('test_manual_pulsar_rendering_rgb.png', rgb_map[0].detach().cpu().numpy())
138 save_image('test_manual_pulsar_rendering_dpt.png', dpt_map[0].detach().cpu().numpy())
139 save_image('test_manual_pulsar_rendering_acc.png', acc_map[0].detach().cpu().numpy())
140
141
142def test_pulsar_rendering(pcd=pcd, feat=feat, radius=radius):

Callers

nothing calls this directly

Calls 7

add_batchFunction · 0.90
to_cudaFunction · 0.90
get_pulsar_camera_paramsFunction · 0.90
save_imageFunction · 0.90
to_batchMethod · 0.80
numpyMethod · 0.80
cpuMethod · 0.80

Tested by

no test coverage detected