(
rays_o,
rays_d,
map_states,
sdf_network,
step_size,
voxel_size,
truncation,
max_voxel_hit,
max_distance,
chunk_size=-1,
profiler=None,
return_raw=False,
eval=False
)
| 258 | |
| 259 | |
| 260 | def render_rays( |
| 261 | rays_o, |
| 262 | rays_d, |
| 263 | map_states, |
| 264 | sdf_network, |
| 265 | step_size, |
| 266 | voxel_size, |
| 267 | truncation, |
| 268 | max_voxel_hit, |
| 269 | max_distance, |
| 270 | chunk_size=-1, |
| 271 | profiler=None, |
| 272 | return_raw=False, |
| 273 | eval=False |
| 274 | ): |
| 275 | centres = map_states["voxel_center_xyz"] |
| 276 | childrens = map_states["voxel_structure"] |
| 277 | |
| 278 | if profiler is not None: |
| 279 | profiler.tick("ray_intersect") |
| 280 | """ |
| 281 | intersections (dict):min_depth:(1,N_rays,N_hit_voxels) depth in camera coordinate if ray intersect voxel |
| 282 | max_depth: (1,N_rays,N_hit_voxels) |
| 283 | intersected_voxel_id: (1,N_rays,N_hit_voxels) |
| 284 | hits:(1,N_rays),Whether each ray hits a voxel |
| 285 | """ |
| 286 | intersections, hits = ray_intersect( |
| 287 | rays_o, rays_d, centres, |
| 288 | childrens, voxel_size, max_voxel_hit, max_distance) |
| 289 | if profiler is not None: |
| 290 | profiler.tok("ray_intersect") |
| 291 | if hits.sum() == 0 and eval == True: |
| 292 | ray_mask = torch.zeros_like(hits).bool().cuda() |
| 293 | rgb = torch.zeros_like(rays_o).squeeze(0).cuda() |
| 294 | depth = torch.zeros((rays_o.shape[1],)).cuda() |
| 295 | return { |
| 296 | "weights": None, |
| 297 | "color": None, |
| 298 | "depth": None, |
| 299 | "z_vals": None, |
| 300 | "sdf": None, |
| 301 | "ray_mask": ray_mask, |
| 302 | "raw": None if return_raw else None |
| 303 | } |
| 304 | |
| 305 | else: |
| 306 | assert (hits.sum() > 0) |
| 307 | |
| 308 | ray_mask = hits.view(1, -1) # Whether each ray hits a voxel |
| 309 | intersections = { |
| 310 | name: outs[ray_mask].reshape(-1, outs.size(-1)) |
| 311 | for name, outs in intersections.items() |
| 312 | } # min_depth max_depth intersected_voxel_id: (N_rays,N_hit_voxels) |
| 313 | |
| 314 | rays_o = rays_o[ray_mask].reshape(-1, 3) # remove rays which don't hit voxel |
| 315 | rays_d = rays_d[ray_mask].reshape(-1, 3) |
| 316 | |
| 317 | """ |
no test coverage detected