Given point cloud (scene representation) and camera rays, compute intersection points, surface normal, rgb, etc. Procedure: - find neighboring points using pr - run pointersect model cached_info: a dictionary containing the grid_cell_to_point information.
(
point_cloud: PointCloud,
camera_rays: Ray,
model: SimplePointersect,
k: int, # number of neighbor points to use
t_min: float = 1.0e-8,
t_max: float = 1.0e10,
max_pr_chunk_size: int = -1, # max n_points * n_rays to process in a chunk
max_model_chunk_size: int = -1, # max n_points * n_rays to process in a chunk
pr_grid_size: int = 100,
pr_grid_width: float = 2.2,
pr_grid_center: float = 0.,
pr_ray_radius: float = 0.1,
th_hit_prob: float = 0.5, # > th, hit
printout: bool = False,
cached_info: T.Union[T.Dict[str, torch.Tensor], None] = None,
random_drop_rgb_rate: float = 0.,
random_drop_sample_feature_rate: float = 0.,
rgb_drop_val: float = 0.5,
rgb_render_method: str = 'blending_weights',
enable_timing: bool = False,
)
| 33 | |
| 34 | |
| 35 | def intersect_pcd_and_ray( |
| 36 | point_cloud: PointCloud, |
| 37 | camera_rays: Ray, |
| 38 | model: SimplePointersect, |
| 39 | k: int, # number of neighbor points to use |
| 40 | t_min: float = 1.0e-8, |
| 41 | t_max: float = 1.0e10, |
| 42 | max_pr_chunk_size: int = -1, # max n_points * n_rays to process in a chunk |
| 43 | max_model_chunk_size: int = -1, # max n_points * n_rays to process in a chunk |
| 44 | pr_grid_size: int = 100, |
| 45 | pr_grid_width: float = 2.2, |
| 46 | pr_grid_center: float = 0., |
| 47 | pr_ray_radius: float = 0.1, |
| 48 | th_hit_prob: float = 0.5, # > th, hit |
| 49 | printout: bool = False, |
| 50 | cached_info: T.Union[T.Dict[str, torch.Tensor], None] = None, |
| 51 | random_drop_rgb_rate: float = 0., |
| 52 | random_drop_sample_feature_rate: float = 0., |
| 53 | rgb_drop_val: float = 0.5, |
| 54 | rgb_render_method: str = 'blending_weights', |
| 55 | enable_timing: bool = False, |
| 56 | ) -> T.Dict[str, T.Union[PointersectRecord, T.Dict[str, torch.Tensor], torch.Tensor, None]]: |
| 57 | """ |
| 58 | Given point cloud (scene representation) and camera rays, |
| 59 | compute intersection points, surface normal, rgb, etc. |
| 60 | |
| 61 | Procedure: |
| 62 | - find neighboring points using pr |
| 63 | - run pointersect model |
| 64 | |
| 65 | |
| 66 | cached_info: |
| 67 | a dictionary containing the grid_cell_to_point information. |
| 68 | """ |
| 69 | |
| 70 | if hasattr(model, 'dim_point_feature'): |
| 71 | pass |
| 72 | else: |
| 73 | # model is DDP, we use the actual model |
| 74 | model = model.module |
| 75 | |
| 76 | b = point_cloud.xyz_w.size(0) |
| 77 | _b, *m_shape, _ = camera_rays.origins_w.shape |
| 78 | assert _b == b |
| 79 | stime_total = timer() |
| 80 | |
| 81 | pr_params = dict( |
| 82 | ray_radius=pr_ray_radius, |
| 83 | grid_size=pr_grid_size, |
| 84 | grid_center=pr_grid_center, |
| 85 | grid_width=pr_grid_width, |
| 86 | ) |
| 87 | |
| 88 | ori_device = point_cloud.xyz_w.device |
| 89 | device_cpu = torch.device('cpu') |
| 90 | model_device = next(model.parameters()).device |
| 91 | pr_device = model_device |
| 92 | timing_info = dict() |
no test coverage detected