在googlecolab使用open3d库时的open3d.visualization.draw_geometries()函数报错及解决方法

运行的代码如下:

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

步骤
  1. 在windows系统打开cmd,并安装open3d
pip install open3d-python
  1. 修改上述部分代码
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])
  1. 在pycharm里运行

在这里插入图片描述

  1. 效果如图
    在这里插入图片描述
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值