编译安装PCL点云库,Kinect2驱动,乐视Astra相机驱动

                                        编译安装PCL点云库

 

官网及文档

源码官网:https://github.com/PointCloudLibrary/pcl

安装方式

方式一:编译源码安装(最稳妥)

1.准备编译环境及工具

sudo apt-get update
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui 
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common
sudo apt-get install libpcap-dev
sudo apt-get install libflann1.9 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install vtk6 libvtk6.3 libvtk6-dev libvtk6.3-qt libvtk6-qt-dev 
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev 
sudo apt-get install mono-complete
sudo apt-get install libopenni-dev libopenni2-dev
sudo apt install pcl-tools
# sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre

2.编译PCL(PointCloudLibrary)

下载源码:

git clone https://gitee.com/mirrors/pcl.git

3.进入下载后的pcl目录,创建并进入release目录,执行编译:

cd pcl
# 切换到指定版本v1.9.1再编译
非git下载可以不用执行这行
git checkout pcl-1.9.1 
# 创建目录
进入源码目录,在源码目录下
mkdir release
# 进入目录
cd release

# 配置cmake 不执行这行,执行下面一行
cmake -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      -DBUILD_GPU=ON \
      -DBUILD_apps=ON \
      -DBUILD_examples=ON ..

# 配置cmake 控制台命令
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=~/pcl_env -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON ..

# 进行编译
make -j8

安装

sudo make install

未安装在这个/usr/local目录下的,安装成功后做一个软链接,方便导库
sudo ln -s ~/pcl_env /usr/local/share/pcl_env

工程引入库

CMakeLists.txt

cmake_minimum_required(VERSION 3.16)
project(pcl1)

set(CMAKE_CXX_STANDARD 14)

# 设置输出根目录为build/Debug
set(OUTPUT_DIRECTORY_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE})
# 设置可执行程序输出到build/Debug/bin目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY_ROOT}/bin" CACHE PATH "Runtime directory" FORCE)
# 设置库文件输出到build/Debug/lib目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY_ROOT}/lib" CACHE PATH "Library directory" FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY_ROOT}/lib" CACHE PATH "Archive directory" FORCE)



find_package(PCL REQUIRED)
# 包含头文件目录
include_directories(${PCL_INCLUDE_DIRS})
# 设置依赖库链接目录
link_directories(${PCL_LIBRARY_DIRS})
# 添加预处理器和编译器标记
add_definitions(${PCL_DEFINITIONS})

add_executable(pcl1 main.cpp)
target_link_libraries(pcl1 ${PCL_LIBRARIES})

 

 

  1. 测试

测试是否成功,打开窗口看到logo点云即为成功安装

在release目录执行以下命令,弹出窗口点云就算成功

pcl_viewer ../test/pcl_logo.pcd

方式二:在线安装(100M下载,释放后1G)

sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-dev  # 或 libpcl-all

问题及处理

问题:没有pcl_viewer

  • 解决:

说明编译的时候,cmake参数有误,或install有问题,可以检查参数后重新执行cmake make

或通过以下命令安装 bash sudo apt install pcl-tools

问题:加载pcd文件异常

描述:执行pcl::io::loadPCDFile("./assets/xxxx.pcd", *cloud) == -1),控制台报错

 
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
  • 解决:

此时,很可能是eigen3有问题,从此处下载离线版eigen3库

http://bitbucket.org/eigen/eigen/get/3.2.0.tar.bz2

http://eigen.tuxfamily.org/index.php?title=Main_Page 在该网站中,可以下载任意版本对应的文件,本例下载了Eigen 3.2.0. tar.bz2 格式压缩文件。 文件名:eigen-eigen-ffa86ffb5570.tar.bz2

执行如下操作:

  1. 卸载原有eigen3:
 
sudo apt-get remove libeigen3-dev --purge
  1. 重装eigen3

 

 
# 解压
tar -jxvf eigen3_3.2.0.orig.tar.bz2
# 重命名
mv eigen-eigen-ffa86ffb5570/ eigen3
# 复制到/usr/local/include/
sudo cp -r eigen3 /usr/local/include/eigen3
# 复制到/usr/include/
sudo cp -r eigen3 /usr/include/eigen3

 

问题:metslib cmake 错误¶

no metslib found.
  • 解决:
 
wget https://www.coin-or.org/download/source/metslib/metslib-0.5.3.tgz
tar xzvf metslib-0.5.3.tgz
cd metslib-0.5.3
./configure
make 
sudo make install

问题:libpq.solibvtkIO.so错误¶

 
[ 13%] Built target pcl_pcd_convert_NaN_nan
[ 13%] Linking CXX executable ../../bin/pcl_pcd_introduce_nan
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_peer_certificate@OPENSSL_1.0.0'
/usr/lib/libvtkIO.so.5.10.1: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `CRYPTO_num_locks@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_get_current_compression@OPENSSL_1.0.0'
//usr/lib/x86_64-linux-gnu/libpq.so.5: undefined reference to `SSL_CTX_free@OPENSSL_1.0.0'
  • 解决:
 
sudo apt-get remove libpq5
sudo apt-get install libpq-dev

问题:make时libproj.so

 
 make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libproj.so', needed by 'lib/libpcl_io.so.1.9.1.99'。 停止。CMakeFiles/Makefile2:499: recipe for target 'io/CMakeFiles/pcl_io.dir/all' failed
  • 解决:

建立软连接, 终端中输入:

sudo ln -s /usr/lib/x86_64-linux-gnu/libproj.so.9 /usr/lib/x86_64-linux-gnu/libproj.so
 

问题:libpng16.so错误¶

 
//home/ty/anaconda3/lib/libpng16.so.16: undefined reference to `inflateValidate@ZLIB_1.2.9'
collect2: error: ld returned 1 exit status
src/CMakeFiles/pcl_test.dir/build.make:253: recipe for target '../build/debug/bin/pcl_test' failed
make[3]: *** [../build/debug/bin/pcl_test] Error 1
  • 解决:

cd /usr/lib/x86_64-linux-gnu
sudo ln -sf ~/anaconda/lib/libpng16.so.16 libpng16.so.16
cd /usr/lib/
sudo ln -sf ~/anaconda/lib/libpng16.so.16 libpng16.so.16
sudo ldconfig

conda remove libpng
sudo apt-get install libpng16-16 --reinstall

 

实在不行编译安装源码:

 
wget https://download.sourceforge.net/libpng/libpng-1.6.37.tar.gz
tar -zxvf libpng-1.6.37.tar.gz
cd libpng-1.6.37/
./configure --prefix=/usr/local/
sudo make && make install

问题:/usr/bin/ld: cannot find -lxxx

  • `/usr/bin/ld: cannot find -lvtkproj4为例
  • 解决:

原因1:libvtkproj4.so的链接不正确或没有链接,注意规则是libxxx.so

 
cd /usr/lib
ll | grep -i vtkproj4
# 输出
lrwxrwxrwx   1 root root       21 4月   5  2016 libvtkproj4.so.5.10 -> libvtkproj4.so.5.10.1
-rw-r--r--   1 root root   312320 4月   5  2016 libvtkproj4.so.5.10.1

说明没有libvtkproj4.so链接,则执行以下命令即可:

 
sudo ln -s libvtkproj4.so.5.10 libvtkproj4.so

原因2:系统缺少对应的so库,即/usr/lib下找不到类似的so

则进行搜索并安装

sudo apt-cache search libvtkproj4-dev
sudo apt-get install libvtkproj4-dev

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------

01-编译安装Kinect2驱动

下载源码

git clone https://gitee.com/Ausar/libfreenect2.git
# github源码在 https://github.com/OpenKinect/libfreenect2
cd libfreenect2

初始化环境

  • 安装编译工具

  • sudo apt-get install build-essential cmake pkg-config
    sudo apt-get install libusb-1.0-0-dev
    sudo apt-get install libturbojpeg libjpeg-turbo8-dev
    sudo apt-get install libglfw3-dev
    sudo apt-get install beignet-dev
    sudo apt-get install libturbojpeg0-dev

编译

在libfreenect2目录中执行:

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install

 用这个安装在home下

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/freenect2
make -j8
make install

cmake .. -DCMAKE_INSTALL_PREFIX=~/freenect2 出现以下问题:

Could NOT find TurboJPEG (missing: TurboJPEG_INCLUDE_DIRS TURBOJPEG_WORKS)
Call Stack (most recent call first):
******************************************
-- Configuring incomplete, errors occurred!
See also "/home/sk/libfreenect2/build/CMakeFiles/CMakeOutput.log"

解决:

sudo apt-get install libturbojpeg0-dev

然后删除 build 重新cmake;

 

配置

配置udev规则以获取访问设备的权限:

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

随后拔插设备

测试

  • 运行测试程序:  ./bin/Protonect

其他

在安装kinect驱动时,如果libusb有问题,需要指定版本,其安装如下,

sudo apt-add-repository ppa:floe/libusb 
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev

----------------------------------------------------------------------------------------------------------------------------------------------------------

Astra相机驱动&SDK¶

Astra(orbbec奥比中光)乐视相机相关驱动,本教程针对WindowsUbuntu14.04=Ubuntu18.04系统版本

官网链接:https://orbbec3d.com/develop/

该深度相机是乐视与奥比中光合作的体感相机,对标微软Kinect,可用于三维重建,SLAM学习,也可以作为免驱UVC摄像头体感摄像头使用

 

相机参数:

 

Linux环境¶

依赖环境¶

 
sudo apt-get install build-essential freeglut3 freeglut3-dev
sudo apt-get install libsfml-dev

相机SDK&Samples¶

  • 执行环境安装
 
tar -zxvf AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-ubuntu1604.tar.gz
cd AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/install
sudo sh ./install.sh

输出结果包含以下两行,注意把倒数第二个路径里的install删掉:

export ASTRA_SDK_INCLUDE=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/install/include export ASTRA_SDK_LIB=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/install/lib

删掉install之后:

export ASTRA_SDK_INCLUDE=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/include export ASTRA_SDK_LIB=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/lib

  • 将输出结果复制到~/.bashrc尾部
 
gedit ~/.bashrc
  • 使之生效
 
source ~/.bashrc

Samples目录中即是示例程序,需要依赖include和lib目录

OpenNI相机测试工具¶

  • 安装OpenNI
 
unzip OpenNI_2.3.0.55.zip
cd OpenNI_2.3.0.55/Linux/OpenNI-Linux-x64-2.3.0.55
chmod +x install.sh
sudo ./install.sh
  • 重新拔插设备
  • 初始化OpenNI环境
 
source OpenNIDevEnvironment
  • 编译运行
 
cd Samples/SimpleViewer
make
cd Bin/x64-Release
./SimpleViewer

Windows环境¶

方式一:¶

安装驱动,运行OpenNI测试Demo

  • 相机驱动:

    http://dl.orbbec3d.com/dist/drivers/win32/astra-win32-driver-4.3.0.10.exe

  • OpenNI:

    http://dl.orbbec3d.com/dist/openni2/OpenNI_2.3.0.63.zip

首先双击安装相机驱动,astra-win32-driver-4.3.0.10.exe,然后解压OpenNI开发包,将相机插上USB口(建议使用USB3.0的插口),双击打开打开Astra OpenNI2 Development Instruction(x64)_V1.3\Tools\OBNiViewer目录下的OBNiViewer应用程序即可

方式二:¶

在VS下运行Demo

  • Orbbec Astra SDK:

    http://dl.orbbec3d.com/dist/astra/v2.0.18/AstraSDK-v2.0.18-05cfa52534-20191108T075451Z-vs2015-win64.zip

  • 使用Windows的AstraSDK需要安装微软的Visual Studio

    https://www.microsoft.com/en-us/download/details.aspx?id=48145

AstraSDK-v2.0.18-05cfa52534-20191108T075451Z-vs2015-win64.zip解压后,从VS打开OrbbecStreamSample示例程序,运行main.cpp即可

 

make报错

Makefile:28: *** OPENNI2_INCLUDE is not defined. Please define it or 'source' the OpenNIDevEnvironment file from the installation。 停止。

解决:

在这个/home/sk/Astra/OpenNI_2.3.0.63/Linux/OpenNI-Linux-x64-2.3.0.63目录下执行

source OpenNIDevEnvironment

在这个/home/sk/Astra/OpenNI_2.3.0.63/Linux/OpenNI-Linux-x64-2.3.0.63/Samples/SimpleViewer目录下执行

make

启动相机报错:

Error - expect color and depth to be in same resolution: D: 640x400, C: 640x480

在奥比中光上下载的最新版的OpenNI版的linux版本中出现Error - expect color and depth to be in same resolution: D: 640x400, C: 640x480 这个错误是因为其OpenNI的设备驱动那里设置读取图像和读取深度图的尺度出现了错误。

解决办法看这篇博客:
https://blog.csdn.net/weixin_42587961/article/details/94359768
 
打开相机

/home/sk/Astra/OpenNI_2.3.0.63/Linux/OpenNI-Linux-x64-2.3.0.63/Samples/SimpleViewer/Bin/x64-Release

./SimpleViewer

./home/sk/Astra/OpenNI_2.3.0.63/Linux/OpenNI-Linux-x64-2.3.0.63/Samples/SimpleViewer/Bin/x64-Releas/SimpleViewer
 

 

你可能感兴趣的:(python,c++,pcl)