MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / GaussianRasterizer

Class GaussianRasterizer

gaussian_renderer/diff_gaussian_rasterization.py:239–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237 debug : bool
238
239class GaussianRasterizer(nn.Module):
240 def __init__(self, raster_settings):
241 super().__init__()
242 self.raster_settings = raster_settings
243
244 def markVisible(self, positions):
245 # Mark visible points (based on frustum culling for camera) with a boolean
246 with torch.no_grad():
247 raster_settings = self.raster_settings
248 visible = _C.mark_visible(
249 positions,
250 raster_settings.viewmatrix,
251 raster_settings.projmatrix)
252
253 return visible
254
255 def forward(self, means3D, means2D, opacities, shs = None, colors_precomp = None, flow_2d = None, ts=None,
256 scales = None, scales_t=None,
257 rotations = None, rotations_r=None,
258 cov3D_precomp = None):
259
260 raster_settings = self.raster_settings
261
262 if (shs is None and colors_precomp is None) or (shs is not None and colors_precomp is not None):
263 raise Exception('Please provide excatly one of either SHs or precomputed colors!')
264
265 if ((scales is None or rotations is None) and cov3D_precomp is None) or ((scales is not None or rotations is not None) and cov3D_precomp is not None):
266 raise Exception('Please provide exactly one of either scale/rotation pair or precomputed 3D covariance!')
267
268 if self.raster_settings.rot_4d and cov3D_precomp is None and (
269 rotations_r is None or scales_t is None or ts is None):
270 raise Exception(
271 'Please provide exactly rotations_r and scales_t and ts if rot_4d and cov3D_precomp is None!')
272
273 if shs is None:
274 shs = torch.Tensor([])
275 if colors_precomp is None:
276 colors_precomp = torch.Tensor([])
277 if flow_2d is None:
278 flow_2d = torch.Tensor([])
279
280 if ts is None:
281 ts = torch.Tensor([])
282 if scales is None:
283 scales = torch.Tensor([])
284 if scales_t is None:
285 scales_t = torch.Tensor([])
286 if rotations is None:
287 rotations = torch.Tensor([])
288 if rotations_r is None:
289 rotations_r = torch.Tensor([])
290 if cov3D_precomp is None:
291 cov3D_precomp = torch.Tensor([])
292
293 # Invoke C++/CUDA rasterization routine
294 return rasterize_gaussians(
295 means3D,
296 means2D,

Callers 1

renderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected