Python library for working with 3D point clouds.
Project description
pyntcloud is a Python 3 library for working with 3D point clouds leveraging the power of the Python scientific stack.
pip install pyntcloud
Quick Overview
You can access most of pyntcloud’s functionality from its core class: PyntCloud.
With PyntCloud you can perform complex 3D processing operations with minimum lines of code. For example you can:
Load a PLY point cloud from disk.
Add 3 new scalar fields by converting RGB to HSV.
Build a grid of voxels from the point cloud.
Build a new point cloud keeping only the nearest point to each occupied voxel center.
Save the new point cloud in numpy’s NPZ format.
With the following concise code:
from pyntcloud import PyntCloud
cloud = PyntCloud.from_file("some_file.ply")
cloud.add_scalar_field("hsv")
voxelgrid_id = cloud.add_structure("voxelgrid", n_x=32, n_y=32, n_z=32)
new_cloud = cloud.get_sample("voxelgrid_nearest", voxelgrid_id=voxelgrid_id, as_PyntCloud=True)
new_cloud.to_file("out_file.npz")
Integration with other libraries
pyntcloud offers seamless integration with other 3D processing libraries.
You can create / convert PyntCloud instances from / to many 3D processing libraries using the from_instance / to_instance methods:
import open3d as o3d
from pyntcloud import PyntCloud
# FROM Open3D
original_triangle_mesh = o3d.io.read_triangle_mesh("diamond.ply")
cloud = PyntCloud.from_instance("open3d", original_triangle_mesh)
assert cloud.mesh is not None
assert np.allclose(cloud.mesh.values, original_triangle_mesh.triangles)
assert np.allclose(cloud.xyz, original_triangle_mesh.vertices)
assert {'red', 'green', 'blue'}.issubset(cloud.points.columns)
assert np.allclose(cloud.points[['red', 'green', 'blue']].values / 255., original_triangle_mesh.vertex_colors)
assert {'nx', 'ny', 'nz'}.issubset(cloud.points.columns)
assert np.allclose(cloud.points[['nx', 'ny', 'nz']].values, original_triangle_mesh.vertex_normals)
# TO Open3D
cloud = PyntCloud.from_file("diamond.ply")
converted_triangle_mesh = cloud.to_instance("open3d", mesh=True) # mesh=True by default
assert isinstance(converted_triangle_mesh, o3d.geometry.TriangleMesh)
assert np.allclose(cloud.xyz, converted_triangle_mesh.vertices)
assert np.allclose(cloud.mesh.values, converted_triangle_mesh.triangles)
import pyvista as pv
from pyntcloud import PyntCloud
# FROM PyVista
original_point_cloud = pv.read("diamond.ply")
cloud = PyntCloud.from_instance("pyvista", original_point_cloud)
assert np.allclose(cloud.xyz, original_point_cloud.points)
assert {'red', 'green', 'blue'}.issubset(cloud.points.columns)
assert np.allclose(cloud.points[['red', 'green', 'blue']].values, original_point_cloud.point_arrays["RGB"])
assert {'nx', 'ny', 'nz'}.issubset(cloud.points.columns)
assert np.allclose(cloud.points[['nx', 'ny', 'nz']].values, original_point_cloud.point_arrays["Normals"])
# TO PyVista
cloud = PyntCloud.from_file("diamond.ply")
converted_triangle_mesh = cloud.to_instance("open3d", mesh=True)
assert isinstance(converted_triangle_mesh, pv.PolyData)
assert np.allclose(cloud.xyz, converted_triangle_mesh.points)
assert np.allclose(cloud.mesh.values, converted_triangle_mesh.faces[:, 1:])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyntcloud-0.1.0.tar.gz
.
File metadata
- Download URL: pyntcloud-0.1.0.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bef8bf3aa44c0013a5cf16316ea192c57870e337d6436be2a874f06b78806565 |
|
MD5 | 185ab70211dbab98412c3d234542fe57 |
|
BLAKE2b-256 | 8efa16c1272ff00375902256ae0c51deddd6771fc4415092280c188d371882a3 |
File details
Details for the file pyntcloud-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pyntcloud-0.1.0-py3-none-any.whl
- Upload date:
- Size: 351.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65c3a829bb54988b8ce1be1b191b6468eb65c28e2b4fbd15942fd5ced6d2e7f |
|
MD5 | fb4a5ccdebd2fe4c560dfd2334fed581 |
|
BLAKE2b-256 | 70758343daa3e4a8c96fa808251eea4240e9bf1aa4723a6104ca8ea8f582bdbc |