MCPcopy
hub / github.com/nerfstudio-project/gsplat / rasterize_to_pixels_eval3d

Function rasterize_to_pixels_eval3d

gsplat/cuda/_wrapper.py:678–849  ·  view source on GitHub ↗

Rasterizes Gaussians to pixels. Similar to `rasterize_to_pixels()`, but compute the Gaussian responses in the 3D world space instead of the 2D image space. Supports rolling shutter and camera distortion. Returns: A tuple: - **Rendered colors**. [..., C, image_heigh

(
    means: Tensor,  # [..., N, 3]
    quats: Tensor,  # [..., N, 4]
    scales: Tensor,  # [..., N, 3]
    colors: Tensor,  # [..., C, N, channels] or [nnz, channels]
    opacities: Tensor,  # [..., C, N] or [nnz]
    viewmats: Tensor,  # [..., C, 4, 4]
    Ks: Tensor,  # [..., C, 3, 3]
    image_width: int,
    image_height: int,
    tile_size: int,
    isect_offsets: Tensor,  # [..., C, tile_height, tile_width]
    flatten_ids: Tensor,  # [n_isects]
    backgrounds: Optional[Tensor] = None,  # [..., C, channels]
    masks: Optional[Tensor] = None,  # [..., C, tile_height, tile_width]
    camera_model: Literal["pinhole", "ortho", "fisheye", "ftheta"] = "pinhole",
    ut_params: UnscentedTransformParameters = UnscentedTransformParameters(),
    # distortion
    radial_coeffs: Optional[Tensor] = None,  # [..., C, 6] or [..., C, 4]
    tangential_coeffs: Optional[Tensor] = None,  # [..., C, 2]
    thin_prism_coeffs: Optional[Tensor] = None,  # [..., C, 4]
    ftheta_coeffs: Optional[FThetaCameraDistortionParameters] = None,
    # rolling shutter
    rolling_shutter: RollingShutterType = RollingShutterType.GLOBAL,
    viewmats_rs: Optional[Tensor] = None,  # [..., C, 4, 4]
)

Source from the content-addressed store, hash-verified

676
677
678def rasterize_to_pixels_eval3d(
679 means: Tensor, # [..., N, 3]
680 quats: Tensor, # [..., N, 4]
681 scales: Tensor, # [..., N, 3]
682 colors: Tensor, # [..., C, N, channels] or [nnz, channels]
683 opacities: Tensor, # [..., C, N] or [nnz]
684 viewmats: Tensor, # [..., C, 4, 4]
685 Ks: Tensor, # [..., C, 3, 3]
686 image_width: int,
687 image_height: int,
688 tile_size: int,
689 isect_offsets: Tensor, # [..., C, tile_height, tile_width]
690 flatten_ids: Tensor, # [n_isects]
691 backgrounds: Optional[Tensor] = None, # [..., C, channels]
692 masks: Optional[Tensor] = None, # [..., C, tile_height, tile_width]
693 camera_model: Literal["pinhole", "ortho", "fisheye", "ftheta"] = "pinhole",
694 ut_params: UnscentedTransformParameters = UnscentedTransformParameters(),
695 # distortion
696 radial_coeffs: Optional[Tensor] = None, # [..., C, 6] or [..., C, 4]
697 tangential_coeffs: Optional[Tensor] = None, # [..., C, 2]
698 thin_prism_coeffs: Optional[Tensor] = None, # [..., C, 4]
699 ftheta_coeffs: Optional[FThetaCameraDistortionParameters] = None,
700 # rolling shutter
701 rolling_shutter: RollingShutterType = RollingShutterType.GLOBAL,
702 viewmats_rs: Optional[Tensor] = None, # [..., C, 4, 4]
703) -> Tuple[Tensor, Tensor]:
704 """Rasterizes Gaussians to pixels.
705
706 Similar to `rasterize_to_pixels()`, but compute the Gaussian responses in the
707 3D world space instead of the 2D image space. Supports rolling shutter and
708 camera distortion.
709
710 Returns:
711 A tuple:
712
713 - **Rendered colors**. [..., C, image_height, image_width, channels]
714 - **Rendered alphas**. [..., C, image_height, image_width, 1]
715 """
716 batch_dims = means.shape[:-2]
717 num_batch_dims = len(batch_dims)
718 N = means.size(-2)
719 C = viewmats.size(-3)
720 channels = colors.shape[-1]
721 device = means.device
722
723 assert means.shape == batch_dims + (N, 3), means.shape
724 assert quats.shape == batch_dims + (N, 4), quats.shape
725 assert scales.shape == batch_dims + (N, 3), scales.shape
726 assert viewmats.shape == batch_dims + (C, 4, 4), viewmats.shape
727 assert Ks.shape == batch_dims + (C, 3, 3), Ks.shape
728
729 assert colors.ndim in (num_batch_dims + 2, num_batch_dims + 3), colors.shape
730 if colors.ndim == num_batch_dims + 2:
731 raise NotImplementedError("packed mode is not supported yet")
732 assert (
733 colors.shape[:-2] == batch_dims and colors.shape[-1] == channels
734 ), colors.shape
735 else:

Callers 1

rasterizationFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…