PCL
库是用来处理三维点云非常方便的库,库本身是C++的,现在有Python封装的版本:python-pcl
,在安装过程中有一些注意事项及错误解决,本博客记录下自己的安装过程,供大家参考。
源码:https://github.com/strawlab/python-pcl
1、安装依赖
sudo apt-get install cmake g++ libboost1.58-all-dev libeigen3-dev libflann-dev python libusb-1.0–0-dev libudev-dev freeglut3-dev doxygen graphviz libpng12-dev libgtest-dev libxmu-dev libxi-dev libpcap-dev libqhull-dev libvtk5-qt4-dev python-vtk libvtk-java
2、安装PCL
默认已经安装好PCL1.8.1
如何在ubuntu16.04下安装PCL1.8
3、Python依赖库安装
pip install --upgrade pip
pip install cython==0.25.2
pip install numpy
4、安装python-pcl
git clone https://github.com/strawlab/python-pcl.git
cd python-pcl
sudo python setup.py build_ext -i
sudo python setup.py install
1、
Package pcl_2d-1.8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pcl_2d-1.8.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pcl_2d-1.8', required by 'pcl_features-1.8', not found
Package pcl_2d-1.8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pcl_2d-1.8.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pcl_2d-1.8', required by 'pcl_features-1.8', not found
Package pcl_2d-1.8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pcl_2d-1.8.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pcl_2d-1.8', required by 'pcl_features-1.8', not found
Package pcl_2d-1.8 was not found in the pkg-config search path.
Perhaps you
should add the directory containing `pcl_2d-1.8.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pcl_2d-1.8', required by 'pcl_features-1.8', not found
Package pcl_2d-1.8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pcl_2d-1.8.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pcl_2d-1.8', required by 'pcl_features-1.8', not found
running build
running build_py
running build_ext
skipping 'pcl/_pcl_180.cpp' Cython extension (up-to-date)
building 'pcl._pcl' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET=1 -I/home/kx/.local/lib/python2.7/site-packages/numpy/core/include -I/usr/include/ni -I/usr/include/python2.7 -c pcl/_pcl_180.cpp -o build/temp.linux-x86_64-2.7/pcl/_pcl_180.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from pcl/_pcl_180.cpp:455:0:
pcl/boost_shared_ptr_assign.h:1:29: fatal error: pcl/point_cloud.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
原因:在PCL 1.8中 pcl_2d-1.8已经被移除了,所以往后的编译会出现错误,解決办法如下:
cd /usr/lib/pkgconfig
chmod 777 pcl_features-1.8.pc
sudo gedit pcl_features-1.8.pc
将第10行最后的pcl_2d-1.8
删除
2、执行python setup.py build_ext -i
最后报错
致命错误: can't create build/temp.linux-x86_64-2.7/pcl/_pcl_180.o: 权限不够
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
解决办法一:找到你的pcl-1.8安装头文件,将其复制成pcl文件夹
sudo cp -r /usr/include/pcl-1.8/* /usr/include/pcl
参考:https://github.com/strawlab/python-pcl/issues/238
解决办法二:使用sudo命令
sudo python setup.py build_ext -i
3、执行python setup.py install
出错
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-19233.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python2.7/dist-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://setuptools.readthedocs.io/en/latest/easy_install.html
Please make the appropriate changes for your system and try again.
解决办法:
sudo python setup.py install
4、from pcl import pcl_visualization报错:ImportError: No module named pcl_visualization
解决办法:
需要对python-pcl源码中的setup.py文件进行修改,在557
行左右增加:
# VTK use?
ext_args['include_dirs'].append('/usr/include/vtk-5.10')
其中vtk-5.10需要根据你自己电脑中的vtk文件夹名字进行修改;
在629
行左右,找到
elif pcl_version == '-1.8':
取消注释:
Extension("pcl.pcl_visualization", ["pcl/pcl_visualization.pyx"], language="c++",
**ext_args),
重新执行
python setup.py build_ext -i
python setup.py install
References:
[1] https://github.com/strawlab/python-pcl
[2] https://medium.com/@ss4365gg/成功在ubuntu-16-04環境中安裝-pcl-1-8-1-python-pcl-a016b711bc4
[3] https://blog.csdn.net/Rinono/article/details/80070134