Python - Display 3D Point Cloud [closed]

萝らか妹 提交于 2020-03-17 07:09:02

问题


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.

Could you indicate me a simple Python library that will take care of plotting the 3D Point Cloud?

It is important to remark that I am not interested in plotting a Mesh, but just the Point Cloud.


回答1:


For anybody wondering for an easy way to read and display PLY point clouds in Python I answer my own question reporting what I've found to be the best solution in my case.

Open cmd and type:

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:

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()



回答2:


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)

To install,

>> pip install pptk

To visualize 100 randomly generated points in Python,

>> 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 tutorial specifically on visualizing point clouds loaded from .ply files.




回答3:


You could use https://github.com/daavoo/pyntcloud to visualize the PLY inside a Jupyter notebook:

from pyntcloud import PyntCloud

human_face = PyntCloud.from_file("human_face.ply")

human_face.plot()



回答4:


You could use vtk which has python bindings to just display. Code snippet

If you want to process your data with numpy etc. I recommend the following steps:

  1. Convert .ply to .pcd (ascii) : pcl_ply2pcd input.ply output.pcd -format 0
  2. Use pypcd which is a python module for reading and writing .pcd files
  3. Pypcd returns a numpy ndarray which can be used perfectly with matplotlib

If you want to stay in the pcl world there is a python-pcl module containing bindings to the library.

I can elaborate further on any of these if one of these fits your needs.



来源:https://stackoverflow.com/questions/50965673/python-display-3d-point-cloud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!