Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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()