def test_data_helper(): # create fake data to test xyz = rng.random((100, 3)) tmp_dir.mkdir(exist_ok=True) # save fake cloud to read in as different return types file_name = tmp_dir / Path('test_xyz.ply') # test writing xyz data as las pcio.write(xyz, file_name, verbose=True) # test reading ply file as numpy return type obj = pcio.read(file_name, return_type='numpy') assert isinstance(obj, pcio.data_helper.rtypes['numpy']) assert np.allclose(obj, xyz) del obj # test reading ply file as o3d return type obj = pcio.read(file_name, return_type='o3d') assert isinstance(obj, pcio.data_helper.rtypes['o3d']) del obj # test reading ply file as pandas return type obj = pcio.read(file_name, return_type='pandas') assert isinstance(obj, pcio.data_helper.rtypes['pandas']) del obj cleanup() return
def test_data_helper_rgb(): # create fake data to test xyz = rng.random((100, 3)) rgb = rng.uniform(low=0, high=1, size=xyz.shape) tmp_dir.mkdir(exist_ok=True) xyz_rgb = np.hstack((xyz, rgb)) # save fake cloud to read in as different return types file_name = tmp_dir / Path('test_xyz_rgb.ply') # test writing xyz data as las pcio.write(xyz_rgb, file_name, verbose=True) # test reading ply file as numpy return type obj = pcio.read(file_name, return_type='numpy') assert isinstance(obj, pcio.data_helper.rtypes['numpy']) del obj # test reading ply file as o3d return type obj = pcio.read(file_name, return_type='o3d') assert isinstance(obj, pcio.data_helper.rtypes['o3d']) del obj # test reading ply file as pandas return type obj = pcio.read(file_name, return_type='pandas') assert isinstance(obj, pcio.data_helper.rtypes['pandas']) del obj cleanup() return
def test_las(): # create fake data to test xyz = rng.random((100, 3)) rgb = rng.uniform(low=0, high=1, size=xyz.shape) tmp_dir.mkdir(exist_ok=True) file_name = tmp_dir / Path('test_xyz.las') # test writing xyz data as las pcio.write(xyz, file_name, verbose=True) # test reading las file new_xyz = pcio.read(file_name) assert np.allclose(xyz, new_xyz, atol=1e-05) cleanup() # test with rgb xyz_rgb = np.hstack((xyz, rgb)) tmp_dir.mkdir(exist_ok=True) file_name = tmp_dir / Path('test_xyz_rgb.las') # test writing xyz data as las pcio.write(xyz_rgb, file_name, verbose=True) # test reading las file new_xyz_rgb = pcio.read(file_name) assert new_xyz_rgb.shape == xyz_rgb.shape # test xyz assert np.allclose(xyz_rgb[:, :3], new_xyz_rgb[:, :3], atol=1e-05) # test rgb assert np.allclose(xyz_rgb[:, 3:] * 2**8, new_xyz_rgb[:, 3:], atol=1e-0) cleanup() return
def test_asc(): # create fake data to test xyz = rng.random((100, 3)) rgb = rng.uniform(low=0, high=1, size=xyz.shape) tmp_dir.mkdir(exist_ok=True) file_name = tmp_dir / Path('test_xyz.asc') # test writing .asc file with xyz pcio.write(xyz, file_name, verbose=True) # test reading .asc file with xyz new_xyz = pcio.read(file_name) assert np.allclose(xyz, new_xyz, atol=1e-05) xyz_rgb = np.hstack((xyz, rgb)) file_name = tmp_dir / Path('test_xyz_rgb.asc') # test writing xyz data as asc pcio.write(xyz_rgb, file_name, verbose=True) # test reading asc file with xyz and rgb new_xyz_rgb = pcio.read(file_name) assert new_xyz_rgb.shape == xyz_rgb.shape # test xyz assert np.allclose(xyz_rgb[:, :3], new_xyz_rgb[:, :3], atol=1e-05) # test rgb assert np.allclose(xyz_rgb[:, 3:], new_xyz_rgb[:, 3:], atol=1e-0) cleanup()
def test_o3d_xyz(): # create fake data to test xyz = rng.random((100, 3)) rgb = rng.uniform(low=0, high=1, size=xyz.shape) tmp_dir.mkdir(exist_ok=True) file_name = tmp_dir / Path('test_xyz.xyz') # test writing xyz data as xyz pcio.write(xyz, file_name, verbose=True) # test reading las file new_xyz = pcio.read(file_name) assert np.allclose(xyz, new_xyz, atol=1e-05) cleanup() return
def test_o3d_xyzrgb(): xyz = rng.random((100, 3)) rgb = rng.uniform(low=0, high=1, size=xyz.shape) tmp_dir.mkdir(exist_ok=True) xyz_rgb = np.hstack((xyz, rgb)) file_name = tmp_dir / Path('test_xyz_rgb.xyzrgb') # test writing xyz rgb data as xyz pcio.write(xyz_rgb, file_name, verbose=True) # test reading xyz rgb file new_xyz_rgb = pcio.read(file_name) assert new_xyz_rgb.shape == xyz_rgb.shape # test xyz assert np.allclose(xyz_rgb[:, :3], new_xyz_rgb[:, :3], atol=1e-05) # test rgb assert np.allclose(xyz_rgb[:, 3:], new_xyz_rgb[:, 3:], atol=1e-0) cleanup()