"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "e9fb2a356384180d92dc60c49b4dd4b5b3c6ee8f"
Unverified Commit 6ab97aeb authored by Ruilong Li(李瑞龙)'s avatar Ruilong Li(李瑞龙) Committed by GitHub
Browse files

Update volrend.py (#271)

Support expected depth option for rendering
parent 676ae91c
...@@ -23,6 +23,7 @@ def rendering( ...@@ -23,6 +23,7 @@ def rendering(
rgb_alpha_fn: Optional[Callable] = None, rgb_alpha_fn: Optional[Callable] = None,
# rendering options # rendering options
render_bkgd: Optional[Tensor] = None, render_bkgd: Optional[Tensor] = None,
expected_depths: bool = True,
) -> Tuple[Tensor, Tensor, Tensor, Dict]: ) -> Tuple[Tensor, Tensor, Tensor, Dict]:
"""Render the rays through the radience field defined by `rgb_sigma_fn`. """Render the rays through the radience field defined by `rgb_sigma_fn`.
...@@ -49,6 +50,7 @@ def rendering( ...@@ -49,6 +50,7 @@ def rendering(
ray indices} and returns the post-activation rgb (..., 3) and opacity ray indices} and returns the post-activation rgb (..., 3) and opacity
values (...,). The shape `...` is the same as the shape of `t_starts`. values (...,). The shape `...` is the same as the shape of `t_starts`.
render_bkgd: Background color. Tensor with shape (3,). render_bkgd: Background color. Tensor with shape (3,).
expected_depths: If True, return the expected depths. Else, the accumulated depth is returned.
Returns: Returns:
Ray colors (n_rays, 3), opacities (n_rays, 1), depths (n_rays, 1) and a dict Ray colors (n_rays, 3), opacities (n_rays, 1), depths (n_rays, 1) and a dict
...@@ -150,7 +152,8 @@ def rendering( ...@@ -150,7 +152,8 @@ def rendering(
ray_indices=ray_indices, ray_indices=ray_indices,
n_rays=n_rays, n_rays=n_rays,
) )
depths = depths / opacities.clamp_min(torch.finfo(rgbs.dtype).eps) if expected_depths:
depths = depths / opacities.clamp_min(torch.finfo(rgbs.dtype).eps)
# Background composition. # Background composition.
if render_bkgd is not None: if render_bkgd is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment