How to use the pyntcloud.PyntCloud.from_file function in pyntcloud

To help you get started, we’ve selected a few pyntcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daavoo / pyntcloud / tests / integration / io / test_from_file.py View on Github external
def test_from_file(data_path, extension, color, mesh):
    cloud = PyntCloud.from_file(str(data_path / "diamond{}".format(extension)))
    assert_points_xyz(cloud)
    if color:
        assert_points_color(cloud)
    if mesh:
        assert_mesh(cloud)
github daavoo / pyntcloud / tests / test_io.py View on Github external
def test_read_color_off():
    color_off = PyntCloud.from_file(data_path + '_color.off')

    assert_points_xyz(color_off)
    assert_points_color(color_off)
github daavoo / pyntcloud / tests / test_io.py View on Github external
def test_read_bin():
    arr = PyntCloud.from_file(data_path + '.bin')

    assert_points_xyz(arr)
github daavoo / pyntcloud / tests / test_io.py View on Github external
def test_write_npz():
    data = PyntCloud.from_file(data_path + '.ply')

    data.to_file(data_path + 'written_npz.npz', also_save=["mesh"])

    written_npz = PyntCloud.from_file(data_path + 'written_npz.npz')

    assert all(data.points == written_npz.points)
    assert all(data.mesh == written_npz.mesh)

    os.remove(data_path + 'written_npz.npz')
github daavoo / pyntcloud / tests / test_filters.py View on Github external
def test_xyz_filters():
    """filters.f_xyz.

    - Manually check known result.

    """
    cloud = PyntCloud.from_file(path + "/data/test_data_filters.ply")

    bbox = {
        "min_x": 0.4,
        "max_x": 0.6,
        "min_y": 0.4,
        "max_y": 0.6
    }

    f = cloud.get_filter("BBOX", and_apply=True, **bbox)

    assert f.argmax() == 3
    assert len(cloud.points == 1)
github daavoo / pyntcloud / tests / test_sf.py View on Github external
def test_sf_xyz():
    cloud = PyntCloud.from_file(path + "/data/plane.npz")

    # fit with default values (max_dist=1e-4)
    is_plane = cloud.add_scalar_field("plane_fit")
    assert sorted(cloud.points[is_plane].value_counts()) == [1, 4]

    # fit with higher tolerance -> include outlier
    is_plane = cloud.add_scalar_field("plane_fit", max_dist=0.4)
    assert sorted(cloud.points[is_plane].value_counts()) == [5]

    cloud = PyntCloud.from_file(path + "/data/sphere.ply")

    is_sphere = cloud.add_scalar_field("sphere_fit")
    assert sorted(cloud.points[is_sphere].value_counts()) == [1, 2928]

    is_sphere = cloud.add_scalar_field("sphere_fit", max_dist=26)
    assert sorted(cloud.points[is_sphere].value_counts()) == [2929]
github daavoo / pyntcloud / tests / integration / test_core_class.py View on Github external
def test_split_on(data_path):
    """PyntCloud.split_on.

    - Raise KeyError on invalid scalar field
    - Raise ValueError on invalid save_format
    - and_return should return list of PyntClouds
    - Implicitily check save_path is working

    """
    cloud = PyntCloud.from_file(str(data_path / "mnist.npz"))
    vg_id = cloud.add_structure("voxelgrid", n_x=2, n_y=2, n_z=2)

    voxel_n = cloud.add_scalar_field("voxel_n", voxelgrid_id=vg_id)

    with pytest.raises(KeyError):
        cloud.split_on("bad_sf")

    with pytest.raises(ValueError):
        cloud.split_on(voxel_n, save_format="bad_format")

    output = cloud.split_on(voxel_n, save_path="tmp_out")

    assert output is None

    output = cloud.split_on(voxel_n, and_return=True, save_path="tmp_out")
github mauriceqch / pcc_geo_cnn / src / pc_io.py View on Github external
def load_pc(path, p_min, p_max):
    logger.debug(f"Loading PC {path}")
    pc = PyntCloud.from_file(path)
    ret = df_to_pc(pc.points, p_min, p_max)
    logger.debug(f"Loaded PC {path}")

    return ret