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

Function render_arkitscenes

pointersect/inference/main.py:1848–1898  ·  view source on GitHub ↗

Render the lidar scans in ARKitScenes dataset. Args: ply_filenames: list of ply filenames containing the point cloud

(
        ply_filenames: T.List[str],
        arkitscenes_indiv_voxel_downsampling: bool = True,
        **kwargs,
)

Source from the content-addressed store, hash-verified

1846
1847
1848def render_arkitscenes(
1849 ply_filenames: T.List[str],
1850 arkitscenes_indiv_voxel_downsampling: bool = True,
1851 **kwargs,
1852):
1853 """
1854 Render the lidar scans in ARKitScenes dataset.
1855
1856 Args:
1857 ply_filenames:
1858 list of ply filenames containing the point cloud
1859
1860 """
1861
1862 # load the point clouds
1863 voxel_downsample_cell_width = kwargs.get('voxel_downsample_cell_width', -1)
1864 voxel_downsample_sigma = kwargs.get('voxel_downsample_sigma', 0.5)
1865
1866 all_point_clouds = []
1867 for i in range(len(ply_filenames)):
1868 ply_filename = ply_filenames[i]
1869 o3d_pcd: o3d.geometry.PointCloud = o3d.io.read_point_cloud(ply_filename)
1870
1871 point_cloud = PointCloud.from_o3d_pcd(o3d_pcd=o3d_pcd)
1872 max_xyz = point_cloud.xyz_w.max(dim=1)[0][0] # (3,)
1873 min_xyz = point_cloud.xyz_w.min(dim=1)[0][0] # (3,)
1874 size_xyz = max_xyz - min_xyz # (3,)
1875 print(f'max_xyz: = {max_xyz}')
1876 print(f'min_xyz: = {min_xyz}')
1877 print(f'num_cells = {size_xyz / voxel_downsample_cell_width}')
1878
1879 if arkitscenes_indiv_voxel_downsampling:
1880 point_cloud = point_cloud.voxel_downsampling(
1881 cell_width=voxel_downsample_cell_width,
1882 sigma=voxel_downsample_sigma,
1883 )
1884 all_point_clouds.append(point_cloud)
1885
1886 input_point_cloud = PointCloud.cat(point_clouds=all_point_clouds, dim=1) # (b=1, n)
1887
1888 # shift point cloud to center
1889 delta_xyz_w = input_point_cloud.xyz_w[0].mean(dim=0) # (3,)
1890 input_point_cloud.xyz_w = input_point_cloud.xyz_w - delta_xyz_w.reshape(1, 1, 3)
1891
1892 if 'input_point_cloud' in kwargs:
1893 del kwargs['input_point_cloud']
1894
1895 render_point_cloud(
1896 input_point_cloud=input_point_cloud,
1897 **kwargs,
1898 )
1899
1900
1901def render_point_cloud(

Callers 1

launchFunction · 0.85

Calls 6

render_point_cloudFunction · 0.85
getMethod · 0.80
from_o3d_pcdMethod · 0.80
voxel_downsamplingMethod · 0.80
catMethod · 0.45
reshapeMethod · 0.45

Tested by

no test coverage detected