Reconstruct a mesh from the point cloud. Args: bidx: the batch index. method: 'poisson': use Poisson surface reconstruction 'alpha': use Alpha shapes 'ball': use Ball pivoting recomp
(
self,
bidx: int,
method: str,
recompute_normal: bool,
alpha: float = 0.03,
ball_radii: T.List[float] = (0.005, 0.01, 0.02, 0.04),
poisson_depth: int = 8,
)
| 358 | return o3d_pcds |
| 359 | |
| 360 | def get_mesh( |
| 361 | self, |
| 362 | bidx: int, |
| 363 | method: str, |
| 364 | recompute_normal: bool, |
| 365 | alpha: float = 0.03, |
| 366 | ball_radii: T.List[float] = (0.005, 0.01, 0.02, 0.04), |
| 367 | poisson_depth: int = 8, |
| 368 | ) -> 'Mesh': |
| 369 | """ |
| 370 | Reconstruct a mesh from the point cloud. |
| 371 | |
| 372 | Args: |
| 373 | bidx: |
| 374 | the batch index. |
| 375 | method: |
| 376 | 'poisson': use Poisson surface reconstruction |
| 377 | 'alpha': use Alpha shapes |
| 378 | 'ball': use Ball pivoting |
| 379 | recompute_normal: |
| 380 | whether to recompute the vertex normal (assuming no normal at the points) |
| 381 | alpha: |
| 382 | alpha value used by alpha shapes |
| 383 | ball_radii: |
| 384 | radii used by ball pivot. |
| 385 | radii of the individual balls that are pivoted on the point cloud. |
| 386 | When the ball touches three points, a triangle is created. |
| 387 | poisson_depth: |
| 388 | depth used by poisson reconstruction. |
| 389 | A higher depth value means a mesh with more details. |
| 390 | """ |
| 391 | |
| 392 | o3d_pcd: o3d.geometry.PointCloud = self.get_o3d_pcds( |
| 393 | estimate_normal_if_not_exist=True, |
| 394 | )[bidx] |
| 395 | |
| 396 | if recompute_normal: |
| 397 | o3d_pcd.estimate_normals() |
| 398 | |
| 399 | if method == 'alpha': |
| 400 | o3d_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_alpha_shape( |
| 401 | o3d_pcd, alpha) |
| 402 | elif method == 'ball': |
| 403 | o3d_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting( |
| 404 | o3d_pcd, o3d.utility.DoubleVector(ball_radii), |
| 405 | ) |
| 406 | elif method == 'poisson': |
| 407 | o3d_mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson( |
| 408 | o3d_pcd, depth=poisson_depth) |
| 409 | else: |
| 410 | raise NotImplementedError |
| 411 | |
| 412 | return Mesh( |
| 413 | mesh=o3d_mesh, |
| 414 | scale=None, |
| 415 | center_w=None, |
| 416 | preprocess_mesh=False, |
| 417 | ) |
no test coverage detected