(self, cameraHandle, timestamp=0, render_mode="RGB")
| 107 | return means_motion, rotations, self.scales, opacity, colors_precomp |
| 108 | |
| 109 | def render(self, cameraHandle, timestamp=0, render_mode="RGB"): |
| 110 | means_t, quats_t, scales_t, opa_t, colors_t = self.slice_dyngs_to_3dgs(timestamp) |
| 111 | |
| 112 | c2w = get_c2w(cameraHandle) |
| 113 | c2w = torch.from_numpy(c2w).float().to(self.device) |
| 114 | viewmat = c2w.inverse() |
| 115 | |
| 116 | # W = 1920 |
| 117 | # H = int(W/cameraHandle.aspect) |
| 118 | # focal_x = W/2/np.tan(cameraHandle.fov/2) |
| 119 | # focal_y = H/2/np.tan(cameraHandle.fov/2) |
| 120 | |
| 121 | W, H = 1920, 1080 |
| 122 | focal_length = H / 2.0 / np.tan(cameraHandle.fov / 2.0) |
| 123 | focal_x = focal_length |
| 124 | focal_y = focal_length |
| 125 | K = np.array( |
| 126 | [ |
| 127 | [focal_x, 0.0, W / 2.0], |
| 128 | [0.0, focal_y, H / 2.0], |
| 129 | [0.0, 0.0, 1.0], |
| 130 | ] |
| 131 | ) |
| 132 | K = torch.from_numpy(K).float().to(self.device) |
| 133 | |
| 134 | render_colors, render_alphas, meta = self.rasterization_fn( |
| 135 | means_t, # [N, 3] |
| 136 | quats_t, # [N, 4] |
| 137 | scales_t, # [N, 3] |
| 138 | opa_t, # [N] |
| 139 | colors_t, # [N, S, 3] |
| 140 | viewmat[None], # [1, 4, 4] |
| 141 | K[None], # [1, 3, 3] |
| 142 | W, |
| 143 | H, |
| 144 | # sh_degree=sh_degree, |
| 145 | render_mode="RGB+ED", |
| 146 | # this is to speedup large-scale rendering by skipping far-away Gaussians. |
| 147 | # radius_clip=3, |
| 148 | ) |
| 149 | |
| 150 | if render_mode == "RGB": |
| 151 | render = render_colors[0, ..., 0:3].cpu().numpy() |
| 152 | elif render_mode == "ED": |
| 153 | render = 1 / render_colors[0, ..., 3:].repeat_interleave(3, dim=-1).cpu().numpy() |
| 154 | return render |
| 155 | |
| 156 | class ViserViewer: |
| 157 | def __init__(self, port): |
nothing calls this directly
no test coverage detected