首先貼出這兩個(gè)開源軟件的倉庫地址:
libfreenect2的github地址:https://github.com/OpenKinect/libfreenect2
iai_kinect2的github地址:https://github.com/code-iai/iai_kinect2
首先安裝libfreenect2戚宦,因?yàn)閕ai_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:最后四條命令是用于測(cè)試程序是否編譯安裝成功的.
測(cè)試通過后孩灯,就可以接著安裝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
上面是我計(jì)算機(jī)上的配置烧栋,用戶名需要換成你自己計(jì)算機(jī)上的用戶名.
我在ros-kinetic上編譯安裝iai_kinect2的時(shí)候出現(xiàn)編譯錯(cuò)誤:
/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: rosdep
will 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.