MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / pytorch3d_rasterize

Function pytorch3d_rasterize

motion_rep/motion_checker.py:124–153  ·  view source on GitHub ↗

Rasterize to obtain depth buffer.

(
    vertices: torch.Tensor,
    faces: torch.Tensor,
    image_size: Tuple[int, int],
    blur_radius: float = 0.0,
    sigma: float = 1e-8,
    faces_per_pixel: int = 1,
    perspective_correct: bool = False,
    clip_barycentric_coords: bool = True,
    reverse_axis: bool = False,
)

Source from the content-addressed store, hash-verified

122
123
124def pytorch3d_rasterize(
125 vertices: torch.Tensor,
126 faces: torch.Tensor,
127 image_size: Tuple[int, int],
128 blur_radius: float = 0.0,
129 sigma: float = 1e-8,
130 faces_per_pixel: int = 1,
131 perspective_correct: bool = False,
132 clip_barycentric_coords: bool = True,
133 reverse_axis: bool = False,
134) -> torch.Tensor:
135 """Rasterize to obtain depth buffer."""
136 if reverse_axis:
137 fixed_vertices = vertices.clone()
138 fixed_vertices[..., :2] = -fixed_vertices[..., :2]
139 else:
140 fixed_vertices = vertices.clone()
141
142 meshes_screen = Meshes(verts=fixed_vertices.float(), faces=faces.long())
143 pix_to_face, zbuf, bary_coords, dists = rasterize_meshes(
144 meshes_screen,
145 image_size=image_size,
146 blur_radius=blur_radius,
147 faces_per_pixel=faces_per_pixel,
148 perspective_correct=perspective_correct,
149 clip_barycentric_coords=clip_barycentric_coords,
150 bin_size=0,
151 )
152 depth = zbuf.squeeze(-1)
153 return depth
154
155
156def render_depth_maps(

Callers 1

render_depth_mapsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected