让点云变得再次有趣
.. image:: https://github.com/daavoo/pyntcloud/workflows/pyncloud%20C.I./badge.svg :target: https://github.com/daavoo/pyntcloud/actions :alt: Github Actions C.I.
.. image:: https://readthedocs.org/projects/pyntcloud/badge/?version=latest :target: https://pyntcloud.readthedocs.io/en/latest/?badge=latest :alt: 文档状态
.. image:: https://anaconda.org/conda-forge/pyntcloud/badges/version.svg
:target: https://anaconda.org/conda-forge/pyntcloud
.. image:: https://mybinder.org/badge.svg :target: https://mybinder.org/v2/gh/daavoo/pyntcloud/master :alt: 启动 Binder
.. image:: https://zenodo.org/badge/69888255.svg :target: https://zenodo.org/badge/latestdoi/69888255
.. image:: https://raw.githubusercontent.com/daavoo/pyntcloud/master/docs/images/pyntcloud_logo.png :alt: pyntcloud 徽标
pyntcloud 是一个 Python 3 库,用于利用 Python 科学栈处理 3D 点云。
- 示例_ (我们鼓励您通过启动
Binder <https://mybinder.org/v2/gh/daavoo/pyntcloud/master>
_ 试用这些示例。) - 文档_
.. _示例: https://github.com/daavoo/pyntcloud/tree/master/examples .. _文档: http://pyntcloud.readthedocs.io/en/latest/
安装
.. code-block:: bash
conda install pyntcloud -c conda-forge
或者:
.. code-block:: bash
pip install pyntcloud
快速概览
您可以通过其核心类 PyntCloud 访问 pyntcloud 的大部分功能。
利用 PyntCloud,您可以用最少的代码行执行复杂的 3D 处理操作。例如,您可以:
- 从磁盘加载 PLY 点云。
- 通过将 RGB 转换为 HSV 来添加 3 个新标量字段。
- 从点云构建体素网格。
- 构建一个新点云,仅保留每个已占用体素中心的最近点。
- 以 numpy 的 NPZ 格式保存新点云。
使用以下简洁的代码:
.. code-block:: python
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")
与其他库的集成
pyntcloud 提供与其他 3D 处理库的无缝集成。
您可以使用 from_instance
/ to_instance
方法从/到许多 3D 处理库创建/转换 PyntCloud 实例:
Open3D <https://www.open3d.org>
_
.. code-block:: python
import open3d as o3d
from pyntcloud import PyntCloud
# 来自 Open3D
original_triangle_mesh = o3d.io.read_triangle_mesh("diamond.ply")
cloud = PyntCloud.from_instance("open3d", original_triangle_mesh)
# 转到 Open3D
cloud = PyntCloud.from_file("diamond.ply")
converted_triangle_mesh = cloud.to_instance("open3d", mesh=True) # mesh=True 是默认值
PyVista <https://docs.pyvista.org>
_
.. code-block:: python
import pyvista as pv
from pyntcloud import PyntCloud
# 来自 PyVista
original_point_cloud = pv.read("diamond.ply")
cloud = PyntCloud.from_instance("pyvista", original_point_cloud)
# 转到 PyVista
cloud = PyntCloud.from_file("diamond.ply")
converted_triangle_mesh = cloud.to_instance("pyvista", mesh=True)