MCPcopy Create free account
hub / github.com/Robotics-STAR-Lab/H2-Mapping / render_debug_images

Method render_debug_images

mapping/src/mapping.py:517–585  ·  view source on GitHub ↗
(self, current_frame, batch_size=200000)

Source from the content-addressed store, hash-verified

515
516 @torch.no_grad()
517 def render_debug_images(self, current_frame, batch_size=200000):
518 rgb = current_frame.rgb
519 depth = current_frame.depth
520 rotation = (current_frame.get_ref_pose().cuda() @ current_frame.get_d_pose().cuda())[:3, :3]
521 ind = current_frame.stamp
522 w, h = self.render_res
523 final_outputs = dict()
524
525 decoder = self.decoder.cuda()
526 map_states = {}
527 for k, v in self.map_states.items():
528 map_states[k] = v.cuda()
529
530 rays_d = current_frame.get_rays(w, h).cuda()
531 rays_d = rays_d @ rotation.transpose(-1, -2)
532
533 rays_o = (current_frame.get_ref_pose().cuda() @ current_frame.get_d_pose().cuda())[:3, 3]
534 rays_o = rays_o.unsqueeze(0).expand_as(rays_d)
535
536 rays_o = rays_o.reshape(1, -1, 3).contiguous()
537 rays_d = rays_d.reshape(1, -1, 3)
538 torch.cuda.empty_cache()
539
540 batch_size = batch_size
541 ray_mask_list = []
542 color_list = []
543 depth_list = []
544 # To prevent memory overflow, batch_size can be given according to the video memory
545 for batch_iter in range(0, rays_o.shape[1], batch_size):
546 final_outputs = render_rays(
547 rays_o[:, batch_iter:batch_iter + batch_size, :].clone(),
548 rays_d[:, batch_iter:batch_iter + batch_size, :].clone(),
549 map_states,
550 decoder,
551 self.step_size,
552 self.voxel_size,
553 self.sdf_truncation,
554 self.max_voxel_hit,
555 self.max_distance,
556 chunk_size=500000000,
557 return_raw=True,
558 eval=True
559 )
560 if final_outputs["color"] == None:
561 ray_mask_list.append(final_outputs["ray_mask"])
562 continue
563 ray_mask_list.append(final_outputs["ray_mask"])
564 depth_list.append(final_outputs["depth"])
565 color_list.append(final_outputs["color"])
566
567 ray_mask_input = torch.cat(ray_mask_list, dim=1)
568
569 if len(depth_list) == 0:
570 return None, None, None
571
572 depth_input = torch.cat(depth_list)
573 color_input = torch.cat(color_list, dim=0)
574

Callers 3

mapping_stepMethod · 0.95
runMethod · 0.95
eval_color.pyFile · 0.80

Calls 6

render_raysFunction · 0.90
fill_inFunction · 0.90
get_ref_poseMethod · 0.80
get_d_poseMethod · 0.80
log_imagesMethod · 0.80
get_raysMethod · 0.45

Tested by

no test coverage detected