问题
I want to show the coordinates while visualizing a point cloud in open3D with Python. According to the documentation, I wrote the following code, in which the third line is supposed to create a coordinate. (Suppose point_cache
is a np.array
with shape (442368, 3)
)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(point_cache)
mesh_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.6, origin=[-2, -2, -2])
o3d.visualization.draw_geometries([pcd, mesh_frame])
But it showed the following error, suggesting there is no an attribute called create_coordinate_frame
in TriangleMesh
.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-2e528bfc7404> in <module>
1 pcd = o3d.geometry.PointCloud()
2 pcd.points = o3d.utility.Vector3dVector(point_cache)
----> 3 mesh_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.6, origin=[-2, -2, -2])
4 o3d.visualization.draw_geometries([pcd, mesh_frame])
AttributeError: type object 'open3d.open3d.geometry.TriangleMesh' has no attribute 'create_coordinate_frame'
I wonder why this error occurs since the third line is identically the same as the documentation.
My version of open3D is as follows.
[Frost@CC’s Mac ~]$ python3 -m pip show open3d
Name: open3d
Version: 0.8.0.0
Summary: ['Open3D is an open-source library that supports rapid development of software that deals with 3D data.']
Home-page: http://www.open3d.org
Author: Open3D Team
Author-email: info@open3d.org
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires: notebook, widgetsnbextension, ipywidgets, numpy
Required-by:
回答1:
The attribute create_coordinate_frame does not exist; the one you mean is create_mesh_coordinate_frame. This will not work for you either, as it is intended for meshes and not point clouds.
To view a point cloud with axes, I suggest utilizing PyGEL 3D (pygel, gel3D, GEL - all the same). Try with this inside a Jupyter notebook:
from PyGEL3D import gel
from PyGEL3D import js
m = gel.ply_load('filename.ply') # Also try gel.wrl_load() for WRL files ;-)
m_points = m.positions() # Extract (n, 3) array (or list) of n points
js.display(m, smooth=False) # Note we do not need to extract points to view cloud
If you're not using Jupyter Notebook, remove the last line with js.display. Replace it with this:
viewer = gel.GLManifoldViewer()
viewer.display(m)
来源:https://stackoverflow.com/questions/58174767/python-open3d-no-attribute-create-coordinate-frame