MCPcopy Create free account
hub / github.com/apple/ml-pointersect / rasterize_surfel

Method rasterize_surfel

pointersect/inference/structures.py:720–940  ·  view source on GitHub ↗

Render the point cloud using surfel rasterization. Args: camera: camera (b, q) point_size: size of the points default_rgb: the color of the points when `self.rgb` is None render_normal_m

(
            self,
            camera: 'Camera',
            point_size: float = 1.,
            default_rgb: T.List[float] = (0.5, 0.5, 0.5),
            render_normal_map: bool = True,
            rgb_shading_mode: str = 'raw',
            # o3d_normal_radius: float = 0.1,
            # o3d_normal_max_nn: int = 30,
    )

Source from the content-addressed store, hash-verified

718 self.valid_mask[:, 0] = 0
719
720 def rasterize_surfel(
721 self,
722 camera: 'Camera',
723 point_size: float = 1.,
724 default_rgb: T.List[float] = (0.5, 0.5, 0.5),
725 render_normal_map: bool = True,
726 rgb_shading_mode: str = 'raw',
727 # o3d_normal_radius: float = 0.1,
728 # o3d_normal_max_nn: int = 30,
729 ) -> 'RGBDImage':
730 """
731 Render the point cloud using surfel rasterization.
732
733 Args:
734 camera:
735 camera (b, q)
736 point_size:
737 size of the points
738 default_rgb:
739 the color of the points when `self.rgb` is None
740 render_normal_map:
741 whether to rasterize normal_w (as rgb color of points).
742 If `self.normal_w` is None, use o3d to estimate with default
743 parameters (max_nn = 30).
744 rgb_shading_mode:
745 'raw': use the rgb values, this is the same as uniform lighting
746 'directional': assume directional light comes from the camera center
747 'half': 0.5 uniform + 0.5 directional
748 # o3d_normal_radius:
749 # search radius (in meter) to use in o3d vertex normal estimation
750 # o3d_normal_max_nn:
751 # max number of neighboring points to use in o3d vertex normal estimation
752
753 Returns:
754 """
755
756 if isinstance(default_rgb, (int, float)):
757 default_rgb = [float(default_rgb)] * 3
758 assert len(default_rgb) == 3
759
760 b = camera.H_c2w.size(0)
761 q = camera.H_c2w.size(1)
762 assert b == self.xyz_w.size(0)
763
764 # get o3d pcds
765 estimate_normal = render_normal_map or rgb_shading_mode in {'directional', 'half'}
766 o3d_pcds = self.get_o3d_pcds(
767 estimate_normal_if_not_exist=estimate_normal,
768 )
769
770 intrinsic = camera.intrinsic.detach().cpu().numpy() # (b, q, 3, 3)
771 H_w2c = camera.get_H_w2c().detach().cpu().numpy() # (b, q, 4, 4)
772 H_c2w = camera.H_c2w.detach().cpu().numpy() # (b, q, 4, 4)
773
774 # render each b
775 all_imgs = []
776 all_depths = []
777 all_hit_maps = []

Callers 1

main_renderFunction · 0.80

Calls 6

get_o3d_pcdsMethod · 0.95
RGBDImageClass · 0.85
sizeMethod · 0.80
get_H_w2cMethod · 0.80
detachMethod · 0.45
reshapeMethod · 0.45

Tested by

no test coverage detected