2018-01-02:Ubuntu16.04下安装libfreenect2和iai_kinect2

首先贴出这两个开源软件的仓库地址:
libfreenect2的github地址:https://github.com/OpenKinect/libfreenect2
iai_kinect2的github地址:https://github.com/code-iai/iai_kinect2

首先安装libfreenect2,因为iai_kinect2是依赖于前者的.

mkdir -p ~/catkin_ws/src/
cd ~/catkin_ws/
catkin_make
cd src
git clone https://github.com/OpenKinect/libfreenect2.git
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 libva-dev libjpeg-dev
sudo apt-get install libopenni2-dev
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -DENABLE_CXX11=ON
make
make install
sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
./bin/Protonect
./bin/Protonect gl
./bin/Protonect cl
./bin/Protonect cpu

Note:最后四条命令是用于测试程序是否编译安装成功的.


测试通过后,就可以接着安装iai_kinect2了.

cd ~/catkin_ws/src/
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"
rospack profile
source devel/setup.bash
roslaunch kinect2_bridge kinect2_bridge.launch
rosrun kinect2_viewer kinect2_viewer kinect2 sd cloud

不想后面太麻烦,可以直接在home目录下的.bashrc文件下添加类似如下的语句:
source /home/Your-user-name/catkin_ws/devel/setup.bash
上面是我计算机上的配置,用户名需要换成你自己计算机上的用户名.


我在ros-kinetic上编译安装iai_kinect2的时候出现编译错误:

/opt/ros/kinetic/include/opencv-3.2.0-dev/opencv2/flann/saving.h:113:63: error: exception handling disabled, use -fexceptions to enable
throw FLANNException("Invalid index file, cannot read");

解决办法是:把 iai_kinect2/kinect2_registration/CMakeLists.txt的66行:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
注释并保存,然后重新编译便可通过.

Note: rosdepwill output errors on not being able to locate [kinect2_bridge] and [depth_registration]. That is fine because they are all part of the iai_kinect2 package and rosdep does not know these packages.

你可能感兴趣的:(2018-01-02:Ubuntu16.04下安装libfreenect2和iai_kinect2)