Python - 显示 3D 点云
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50965673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python - Display 3D Point Cloud
提问by Employee
I have a .PLY file that contains a 3D Point Cloud: I want to plot it and visualize it in Python. The .PLY file contains ONLY vertex and NOT faces.
我有一个包含 3D 点云的 .PLY 文件:我想绘制它并在 Python 中对其进行可视化。.PLY 文件只包含顶点而不包含面。
Could you indicate me a simple Python library that will take care of plotting the 3D Point Cloud?
你能告诉我一个简单的 Python 库来处理 3D 点云的绘制吗?
It is important to remark that I am not interested in plotting a Mesh, but just the Point Cloud.
重要的是要注意我对绘制网格不感兴趣,而只是对点云感兴趣。
回答by Employee
For anybody wondering for an easy wayto read and display PLY point clouds in PythonI answer my own question reporting what I've found to be the best solution in my case.
对于任何人想知道一个简单的方法来读取和Python中显示PLY点云我回答我的问题的报告什么我发现在我的情况下,最好的解决办法。
Open cmd and type:
打开cmd并输入:
pip install open3d
This will install Open3D on your machine and you will then be able to read and dispaly your PLY point clouds just by executing the following sample script:
这将在您的机器上安装 Open3D,然后您只需执行以下示例脚本即可读取和显示您的 PLY 点云:
import numpy as np
from open3d import *
def main():
cloud = read_point_cloud("cloud.ply") # Read the point cloud
draw_geometries([cloud]) # Visualize the point cloud
if __name__ == "__main__":
main()
回答by victoriousluser
Try pptk(point processing toolkit). The package has a 3-d point cloud viewer that directly takes a 3-column numpy array as input, and is able to interactively visualize 10-100 million points. (It reduces the number of points that needs rendering in each frame by using an octree to cull points outside the view frustum and to approximate groups of far away points as single points)
试试pptk(点处理工具包)。该软件包具有 3-d 点云查看器,可直接将 3 列 numpy 数组作为输入,并且能够交互式可视化 10-1 亿个点。(它通过使用八叉树来剔除视锥体外的点并将远点组近似为单个点,从而减少了每帧中需要渲染的点数)
To install,
安装,
>> pip install pptk
To visualize 100 randomly generated points in Python,
要在 Python 中可视化 100 个随机生成的点,
>> import pptk
>> import numpy as np
>> P = np.random.rand(100,3)
>> v = pptk.viewer(P)
screenshot of pptk viewer visualizing 100 random points
The documentation website also has a tutorialspecifically on visualizing point clouds loaded from .ply files.
文档网站还有一个专门关于可视化从 .ply 文件加载的点云的教程。
回答by David de la Iglesia
You could use https://github.com/daavoo/pyntcloudto visualize the PLY inside a Jupyter notebook:
您可以使用https://github.com/daavoo/pyntcloud来可视化 Jupyter notebook 中的 PLY:
from pyntcloud import PyntCloud
human_face = PyntCloud.from_file("human_face.ply")
human_face.plot()
回答by Danipol
You could use vtk which has python bindings to justdisplay. Code snippet
你可以使用VTK其中有python绑定到只显示。 代码片段
If you want to process your data with numpy etc. I recommend the following steps:
如果你想用 numpy 等处理你的数据,我推荐以下步骤:
- Convert .ply to .pcd (ascii) :
pcl_ply2pcd input.ply output.pcd -format 0
- Use pypcdwhich is a python module for reading and writing .pcd files
- Pypcd returns a numpyndarray which can be used perfectly with matplotlib
- 将 .ply 转换为 .pcd (ascii) :
pcl_ply2pcd input.ply output.pcd -format 0
- 使用pypcd这是一个用于读取和写入 .pcd 文件的 python 模块
- Pypcd 返回一个numpyndarray 可以完美地与matplotlib一起使用
If you want to stay in the pcl world there is a python-pcl module containing bindings to the library.
如果你想留在 pcl 世界,有一个包含库绑定的 python-pcl 模块。
I can elaborate further on any of these if one of these fits your needs.
如果其中一个满足您的需求,我可以进一步详细说明其中任何一个。