简体   繁体   English

在 Python 中使用点云库

[英]Using Point Cloud Library in Python

Hello I am trying to use Point Cloud Library in Python and as I am new to this C++ library and Python I am following the tutorial on http://strawlab.github.io/python-pcl/#pcl.PointCloud您好,我正在尝试在 Python 中使用点云库,因为我是这个 C++ 库和 Python 的新手,所以我正在关注http://strawlab.github.io/python-pcl/#pcl.PointCloud上的教程

However whenever I try to import pcl and define a module such as pcl.PointCloud() I get the following error;但是,每当我尝试导入 pcl 并定义诸如pcl.PointCloud()类的模块时,都会出现以下错误;

AttributeError: 'module' object has no attribute 'PointCloud'

I have used sys.path.append to point to the correct directory where the PCL files have been installed as they are not in site packages.我已经使用sys.path.append指向安装 PCL 文件的正确目录,因为它们不在站点包中。 It says on the above link that the C++ code has already got Python bindings but I am unsure exactly what files I am trying to call in Python.它在上面的链接上说 C++ 代码已经有了 Python 绑定,但我不确定我想在 Python 中调用哪些文件。 Does anybody know how to overcome this error and load these modules?有人知道如何克服这个错误并加载这些模块吗?

Thanks, Andrew谢谢,安德鲁

Try this,尝试这个,

sudo add-apt-repository ppa:sweptlaser/python3-pcl
sudo apt update
sudo apt install python3-pcl

After you've done that then you should be able to run:完成后,您应该能够运行:

python3 -c 'import pcl'

and it will return with no error (as opposed to ModuleNotFoundError: No module named 'pcl' ).并且它将无错误地返回(与ModuleNotFoundError: No module named 'pcl'相反)。

Tested on:测试:

Ubuntu 18.04 LTS Ubuntu 18.04 LTS

Python 3.6.9蟒蛇 3.6.9

Reference: https://askubuntu.com/a/1170661/922137参考: https : //askubuntu.com/a/1170661/922137

Try skipping the parentheses:尝试跳过括号:

from pcl import PointCloud

And then create an instance of PointCloud, for example, p :然后创建一个 PointCloud 实例,例如p

p = PointCloud()

Hope it helps!希望能帮助到你!

根据此页面,您似乎需要 PCL 1.5.1 和 cython 0.16: http ://strawlab.github.io/python-pcl/

"""https://blog.pollithy.com/python/numpy/pointcloud/tutorial-pypcd""" """https://blog.pollithy.com/python/numpy/pointcloud/tutorial-pypcd"""

python3.6 -m pip install --user git+https://github.com/DanielPollithy/pypcd.git python3.6 -m pip install --user git+https://github.com/DanielPollithy/pypcd.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM