MCPcopy Index your code
hub / github.com/apple/ml-pointersect / sample_new_points_using_pointersect

Function sample_new_points_using_pointersect

pointersect/inference/infer.py:1686–1775  ·  view source on GitHub ↗

Sample new points from the current point cloud. Args: num_points: number of points to sample method: method to generate querying rays model: width_px: height_px: fov: Returns: new point cloud: (b, num_poi

(
        point_cloud: PointCloud,
        num_points: int,
        model_filename: str,
        method: str = 'uniform_camera',
        model: SimplePointersect = None,
        k: int = 40,
        width_px: int = 10,
        height_px: int = 10,
        fov: float = 60.,  # degree
        max_ray_chunk_size: int = 10000,
)

Source from the content-addressed store, hash-verified

1684
1685
1686def sample_new_points_using_pointersect(
1687 point_cloud: PointCloud,
1688 num_points: int,
1689 model_filename: str,
1690 method: str = 'uniform_camera',
1691 model: SimplePointersect = None,
1692 k: int = 40,
1693 width_px: int = 10,
1694 height_px: int = 10,
1695 fov: float = 60., # degree
1696 max_ray_chunk_size: int = 10000,
1697) -> PointCloud:
1698 """
1699 Sample new points from the current point cloud.
1700
1701 Args:
1702 num_points:
1703 number of points to sample
1704 method:
1705 method to generate querying rays
1706 model:
1707 width_px:
1708 height_px:
1709 fov:
1710
1711 Returns:
1712 new point cloud: (b, num_points)
1713 """
1714
1715 if method == 'uniform_camera':
1716 # adjust resolution settings
1717 n_imgs = max(1, num_points // (width_px * height_px))
1718 n_pixels_per_img = num_points / n_imgs
1719 width_px = max(2, math.floor(n_pixels_per_img / (width_px * height_px) * width_px))
1720 width_px = max(2, width_px - (width_px % 2))
1721 height_px = max(2, math.floor(n_pixels_per_img / width_px))
1722 height_px = max(2, height_px - (height_px % 2))
1723
1724 # get mesh scale and center
1725 if not point_cloud.included_point_at_inf:
1726 xyz_max = point_cloud.xyz_w.max(dim=-2)[0] # (b, 3)
1727 xyz_min = point_cloud.xyz_w.min(dim=-2)[0] # (b, 3)
1728 else:
1729 xyz_max = point_cloud.xyz_w[:, 1:].max(dim=-2)[0] # (b, 3)
1730 xyz_min = point_cloud.xyz_w[:, 1:].min(dim=-2)[0] # (b, 3)
1731 cs = (xyz_max.mean(dim=0) + xyz_min.mean(dim=0)) / 2 # (3,)
1732 s = (xyz_max - xyz_min).max().detach().cpu().item() / 2
1733
1734 # create uniformly placed camera
1735 camera = CameraTrajectory(
1736 mode='random',
1737 n_imgs=n_imgs,
1738 total=1,
1739 params=dict(
1740 max_angle=180,
1741 min_r=2 * s,
1742 max_r=2 * s + 1.e-9,
1743 origin_w=cs.detach().cpu().numpy().tolist(),

Callers

nothing calls this directly

Calls 7

CameraTrajectoryClass · 0.90
get_cameraMethod · 0.80
deviceMethod · 0.80
get_pcdMethod · 0.80
detachMethod · 0.45
get_rgbd_imageMethod · 0.45

Tested by

no test coverage detected