运行的代码如下:
import open3d
import numpy as np
pcd = open3d.geometry.PointCloud()
np_points = np.random.rand(100,3)
pcd.points = open3d.utility.Vector3dVector(np_points)
open3d.visualization.draw_geometries([pcd.points])
报错如下:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-40-8343a9238af4> in <module>()
8 pcd.points = open3d.utility.Vector3dVector(np_points)
9
---> 10 open3d.visualization.draw_geometries([pcd.points])
TypeError: draw_geometries(): incompatible function arguments. The following argument types are supported:
1. (geometry_list: List[open3d.open3d.geometry.Geometry], window_name: str = 'Open3D', width: int = 1920, height: int = 1080, left: int = 50, top: int = 50) -> None
Invoked with: [std::vector<Eigen::Vector3d> with 100 elements.
Use numpy.asarray() to access data.]
Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.
若将代码改为如下:
import open3d
import numpy as np
pcd = open3d.geometry.PointCloud()
np_points = np.random.rand(100,3)
pcd.points = open3d.utility.Vector3dVector(np_points)
#open3d.visualization.draw_geometries([pcd.points])
open3d.visualization.draw_geometries([pcd])
则报错如下:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-51-41237a2b406f> in <module>()
8 pcd.points = open3d.utility.Vector3dVector(np_points)
9
---> 10 open3d.visualization.draw_geometries([pcd])
RuntimeError: [Open3D ERROR] GLFW Error: X11: The DISPLAY environment variable is missing0;m
open3d版本为0.9.0.0
python版本3.6.9
解决方式
1.参数geometry_list列表里应为Geometry类型
2.open3d在GoogleColab上不能进行可视化,在自己本机电脑即可
参考如下
I got a Error = [ GLFW Error: X11: The DISPLAY environment variable is missing ]
http://www.open3d.org/docs/release/python_api/open3d.visualization.draw_geometries.html
步骤
- 在windows系统打开cmd,并安装open3d
pip install open3d-python
- 修改上述部分代码
import open3d
import numpy as np
pcd = open3d.geometry.PointCloud()
#np_points = np.random.rand(100,3)
np_points = np.random.rand(4000,3)
pcd.points = open3d.utility.Vector3dVector(np_points)
#open3d.visualization.draw_geometries([pcd.points])
open3d.visualization.draw_geometries([pcd])
- 在pycharm里运行
- 效果如图