| 307 | |
| 308 | |
| 309 | def farthest_down_sample(pcd: torch.Tensor, pcd_t: torch.Tensor = None, K: int = 65536): |
| 310 | import open3d as o3d |
| 311 | o3d_pcd = o3d.geometry.PointCloud() |
| 312 | o3d_pcd.points = o3d.utility.Vector3dVector(pcd.view(-1, 3).detach().cpu().numpy()) |
| 313 | o3d_pcd = o3d_pcd.farthest_point_down_sample(K) |
| 314 | return torch.as_tensor(np.array(o3d_pcd.points)).to(pcd.device, pcd.dtype, non_blocking=True).view(pcd.shape[0], -1, 3) |
| 315 | |
| 316 | |
| 317 | def sample_random_points(pcd: torch.Tensor, pcd_t: torch.Tensor = None, K: int = 500): |