Return a list of b o3d pcds containing xyz and rgb.
(
self,
estimate_normal_if_not_exist: bool = False,
)
| 317 | return new_point_cloud |
| 318 | |
| 319 | def get_o3d_pcds( |
| 320 | self, |
| 321 | estimate_normal_if_not_exist: bool = False, |
| 322 | ) -> T.List[o3d.geometry.PointCloud]: |
| 323 | """Return a list of b o3d pcds containing xyz and rgb.""" |
| 324 | |
| 325 | o3d_pcds = [] |
| 326 | for i in range(self.xyz_w.size(0)): |
| 327 | |
| 328 | xyz_w = self.extract_valid_attr( |
| 329 | arr=self.xyz_w, |
| 330 | bidx=i, |
| 331 | ) # (n, 3) |
| 332 | if xyz_w is not None: |
| 333 | xyz_w = xyz_w.detach().cpu().numpy() # (n, 3) |
| 334 | rgb = self.extract_valid_attr( |
| 335 | arr=self.rgb, |
| 336 | bidx=i, |
| 337 | ) # (n, 3) |
| 338 | if rgb is not None: |
| 339 | rgb = rgb.detach().cpu().numpy() # (n, 3) |
| 340 | normal_w = self.extract_valid_attr( |
| 341 | arr=self.normal_w, |
| 342 | bidx=i, |
| 343 | ) # (n, 3) |
| 344 | if normal_w is not None: |
| 345 | normal_w = normal_w.detach().cpu().numpy() # (n, 3) |
| 346 | |
| 347 | o3d_pcd = o3d.geometry.PointCloud() |
| 348 | o3d_pcd.points = o3d.utility.Vector3dVector(xyz_w) # (n, 3) |
| 349 | if rgb is not None: |
| 350 | o3d_pcd.colors = o3d.utility.Vector3dVector(rgb) # (n, 3) |
| 351 | if normal_w is not None: |
| 352 | o3d_pcd.normals = o3d.utility.Vector3dVector(normal_w) # (n, 3) |
| 353 | |
| 354 | if estimate_normal_if_not_exist and normal_w is None: |
| 355 | o3d_pcd.estimate_normals() # default parameter (number of neighbor points = 30), random direction |
| 356 | |
| 357 | o3d_pcds.append(o3d_pcd) |
| 358 | return o3d_pcds |
| 359 | |
| 360 | def get_mesh( |
| 361 | self, |
no test coverage detected