1. 程式人生 > >Ubuntu14.04下搭建Kinect V2的環境以及出現的問題解決方案

Ubuntu14.04下搭建Kinect V2的環境以及出現的問題解決方案

請各位注意是kinect V2,kinect有兩個版本,V1和V2

一、安裝

1、Download libfreenect2 source

git clone [email protected].com:DongdongBai/libfreenect2.git
cd libfreenect2

2、Download upgrade deb files

cd depends; ./download_debs_trusty.sh

3、Install build tools

sudo apt-get install build-essential cmake pkg-config

4、先安裝Nvidia顯示卡驅動和cuda,然後原始碼編譯Opencv(本步驟的順序不可以顛倒,因為Opencv在編譯時會查詢顯示卡驅動的版本(是使用整合顯示卡還是獨立顯示卡呢,以及獨立顯示卡驅動的版本),如果先裝Opencv,則Opencv會使用系統的預設的繼承顯示卡驅動,後面安裝Nvidia驅動將導致Opencv無法正常使用)

5、Install libusb. The version must be >= 1.0.20.

sudo dpkg -i debs/libusb*deb

6、Install TurboJPEG

sudo apt-get install libturbojpeg libjpeg-turbo8
-dev

7、 Install OpenGL

sudo dpkg -i debs/libglfw3*deb
sudo apt-get install -f
sudo apt-get install libgl1-mesa-dri-lts-vivid

如果最後一步出現依賴錯誤,直接忽略,無需做任何處理

8、Build

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

9、執行Cmake時出現

CMake Warning at CMakeLists.txt:405 (ADD_LIBRARY):
  Cannot generate a safe runtime search path for target freenect2 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda-7.5/lib64

  Some of these libraries may not be found correctly.


CMake Warning at CMakeLists.txt:451 (ADD_LIBRARY):
  Cannot generate a safe runtime search path for target freenect2-openni2
  because files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda-7.5/lib64

  Some of these libraries may not be found correctly.


CMake Warning at examples/CMakeLists.txt:76 (ADD_EXECUTABLE):
  Cannot generate a safe runtime search path for target Protonect because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda-7.5/lib64

  Some of these libraries may not be found correctly.

解決方法:在專案的cmake_modules資料夾中的FindOpenCL.cmake中新增下面兩句話即可(本教程中clone原始碼的CMakeLists.txt已經做了更改,不回出現上述問題,請放心使用):

SET(OpenCL_INCLUDE_DIR /usr/local/cuda/include/ )
SET(OpenCL_LIBRARY  /usr/local/cuda-7.5/lib64/libOpenCL.so)

10、編譯時如果出現以下錯誤:


/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: identifier "nullptr" is undefined

/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: expected a ";"

/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h(190): error: expected a ";"

/usr/include/c++/4.8/exception(63): error: expected a ";"

/usr/include/c++/4.8/exception(68): error: expected a ";"

/usr/include/c++/4.8/exception(76): error: expected a ";"

/usr/include/c++/4.8/exception(83): error: expected a ";"

/usr/include/c++/4.8/exception(93): error: expected a "{"

/usr/include/c++/4.8/bits/exception_ptr.h(64): error: function "std::current_exception" returns incomplete type "std::__exception_ptr::exception_ptr"

/usr/include/c++/4.8/bits/exception_ptr.h(64): error: expected a "{"

/usr/include/c++/4.8/bits/exception_ptr.h(79): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(81): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(82): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(84): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(86): error: declaration is incompatible with previous "std::current_exception"
(64): here

/usr/include/c++/4.8/bits/exception_ptr.h(86): error: use of a local type to declare a function

/usr/include/c++/4.8/bits/exception_ptr.h(86): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(87): error: use of a local type to declare a function

/usr/include/c++/4.8/bits/exception_ptr.h(90): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(92): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(95): error: incomplete type is not allowed

/usr/include/c++/4.8/bits/exception_ptr.h(95): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(116): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(126): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(143): error: use of a local type to declare a function

/usr/include/c++/4.8/bits/exception_ptr.h(144): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(147): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(152): error: use of a local type to declare a function

/usr/include/c++/4.8/bits/exception_ptr.h(153): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(156): error: use of a local type to declare a function

/usr/include/c++/4.8/bits/exception_ptr.h(157): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(160): error: use of a local type to declare a function

/usr/include/c++/4.8/bits/exception_ptr.h(161): error: expected a ";"

/usr/include/c++/4.8/bits/exception_ptr.h(169): error: expected a ";"

/usr/include/c++/4.8/bits/nested_exception.h(57): error: incomplete type is not allowed

/usr/include/c++/4.8/bits/nested_exception.h(60): error: expected a ";"

/usr/include/c++/4.8/bits/nested_exception.h(66): error: expected a ";"

/usr/include/c++/4.8/bits/nested_exception.h(70): error: identifier "rethrow_exception" is undefined

/usr/include/c++/4.8/bits/nested_exception.h(73): error: function "std::nested_exception::nested_ptr" returns incomplete type "std::__exception_ptr::exception_ptr"

/usr/include/c++/4.8/new(95): error: expected a "{"

/usr/include/c++/4.8/new(110): error: identifier "__p" is undefined

/usr/include/c++/4.8/new(111): error: expected a "{"

/usr/include/c++/4.8/new(115): error: expected a "{"

/usr/include/c++/4.8/new(116): error: expected a "{"

/usr/local/cuda-7.5/include/common_functions.h(102): warning: exception specification is incompatible with that of previous function "operator new[](std::size_t, void *)"
/usr/include/c++/4.8/new(111): here

/usr/local/cuda-7.5/include/common_functions.h(103): warning: exception specification is incompatible with that of previous function "operator delete(void *, void *)"
/usr/include/c++/4.8/new(115): here

/usr/local/cuda-7.5/include/common_functions.h(104): warning: exception specification is incompatible with that of previous function "operator delete[](void *, void *)"
/usr/include/c++/4.8/new(116): here

/usr/include/c++/4.8/bits/cpp_type_traits.h(184): error: identifier "char16_t" is undefined

/usr/include/c++/4.8/bits/cpp_type_traits.h(191): error: identifier "char32_t" is undefined

/usr/include/c++/4.8/bits/cpp_type_traits.h(191): error: class "std::__is_integer<<error-type>>" has already been defined

/usr/include/c++/4.8/bits/cpp_type_traits.h(314): error: namespace "std::__gnu_cxx" has no member "__normal_iterator"

/usr/include/c++/4.8/bits/cpp_type_traits.h(314): error: expected a ">"

/usr/include/c++/4.8/cmath(80): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(80): error: expected a ";"

/usr/include/c++/4.8/cmath(105): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(105): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(105): error: expected a ";"

/usr/include/c++/4.8/cmath(124): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(124): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(124): error: expected a ";"

/usr/include/c++/4.8/cmath(143): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(143): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(143): error: expected a ";"

/usr/include/c++/4.8/cmath(162): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(162): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(162): error: expected a ";"

/usr/include/c++/4.8/cmath(183): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(183): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(183): error: expected a ";"

/usr/include/c++/4.8/cmath(202): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(202): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(202): error: expected a ";"

/usr/include/c++/4.8/cmath(221): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(221): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(221): error: expected a ";"

/usr/include/c++/4.8/cmath(240): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(240): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(240): error: expected a ";"

/usr/include/c++/4.8/cmath(259): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(259): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(259): error: expected a ";"

/usr/include/c++/4.8/cmath(278): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(278): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(278): error: expected a ";"

/usr/include/c++/4.8/cmath(297): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(297): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(297): error: expected a ";"

/usr/include/c++/4.8/cmath(328): error: "constexpr" is not a function or static data member

/usr/include/c++/4.8/cmath(337): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(337): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(337): error: expected a ";"

/usr/include/c++/4.8/cmath(356): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(356): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(356): error: expected a ";"

/usr/include/c++/4.8/cmath(375): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(375): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(375): error: expected a ";"

/usr/include/c++/4.8/cmath(406): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(406): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(406): error: expected a ";"

/usr/include/c++/4.8/cmath(443): error: inline specifier allowed on function declarations only

/usr/include/c++/4.8/cmath(443): error: variable "std::constexpr" has already been defined

/usr/include/c++/4.8/cmath(443): error: expected a ";"

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_00001206_00000000-7_cuda_kde_depth_packet_processor.cpp1.ii".
Compilation terminated.
CMake Error at cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o.cmake:264 (message):
  Error generating file
  /home/bdd/libfreenect2-master/build/CMakeFiles/cuda_compile.dir/src/./cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o


make[2]: *** [CMakeFiles/cuda_compile.dir/src/./cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o] Error 1
make[1]: *** [CMakeFiles/freenect2.dir/all] Error 2
make: *** [all] Error 2

將專案中的cuda關閉即可,即將CMakeLists.txt中的第35行的OPTION(ENABLE_CUDA “Enable CUDA support” ON)的ON改為OFF即可(本教程中clone原始碼的CMakeLists.txt已經做了更改,不回出現上述問題,請放心使用)。

二、驗證安裝是否成功及問題解決方法

在build下面有個bin資料夾,放置生成的輸出檔案,插上kinect,然後執行。此時黃燈變成白色的,表示有驅動。注意:只能用於USB3的介面,好在臺式機和筆記本都有3.0的口。

./bin/Protonect gl
./bin/Protonect cl
./bin/Protonect cpu

但是如果提示許可權不夠,failed to open Kinect V2 Access denied,設定執行:sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/, 然後重新插拔Kinect2.

Ros介面安裝

1、對於已經安裝了Ros Indigo的Ubuntu14.04來說,使用下面的命令

cd ~/catkin_ws/src/
git clone [email protected]:DongdongBai/iai_kinect2.git
cd iai_kinect2
sudo rosdep install -r --from-paths .
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"
rospack profile

注意:針對於上述命令中最後一行指令, 需要說明的是, 如果前面libfreenect2你安裝的位置不是$HOME/freenect2或/usr/local這兩個標準路徑下下, 需要提供引數指定libfreenect2所在路徑:

catkin_make -Dfreenect2_DIR=path_to_freenect2/lib/cmake/freenect2 -DCMAKE_BUILD_TYPE="Release"

2、sudo rosdep install -r –from-paths . 出現如下問題:

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies (ROS distro is not set. Make sure `ROS_DISTRO` environment variable is set, or use `--rosdistro` option to specify the distro, e.g. `--rosdistro indigo`):
kinect2_viewer: Cannot locate rosdep definition for [cv_bridge]
kinect2_registration: Cannot locate rosdep definition for [cv_bridge]
kinect2_bridge: Cannot locate rosdep definition for [cv_bridge]
kinect2_calibration: Cannot locate rosdep definition for [cv_bridge]
Continuing to install resolvable dependencies...
#All required rosdeps installed successfully

這個問題是正常情況,不是錯誤,請大家直接忽視!

3、接下來可以測試了。

roslaunch kinect2_bridge kinect2_bridge.launch

然後重新開一個新的終端

rosrun kinect2_viewer kinect2_viewer

顯示如下圖所示。Good Luck and enjoy it!

相關推薦

Ubuntu14.04搭建Kinect V2環境以及出現的問題解決方案

請各位注意是kinect V2,kinect有兩個版本,V1和V2 一、安裝 1、Download libfreenect2 source git clone [email protected].com:DongdongBai/l

ESP32搭建3.ubuntu14.04搭建esp32開發環境 (最新版)

終端 pat 權限 技術 實例 為我 tro component 直接 硬件為樂鑫出品的ESP32一款集成了wifi和藍牙的集成模塊。 1.首先ctrl+alt+t打開終端,sudo -s選擇用root權限登陸 。 2. 輸入指令:sudo apt-get install

Ubuntu14.04搭建LAMP環境

1.安裝apache sudo apt-get install apache2 在瀏覽器中開啟 http://localhost/ 或者 http://127.0.0.1 ,如果有頁面出現,就說明安裝成功。然後可以重啟apache: sudo /etc/init.d/apache2 re

Ubuntu14.04嵌入式交叉編譯環境arm-linux-gcc-4.3.3搭建過程

需要做嵌入式的開發,照著板子的教程安裝arm-linux-gcc-4.3.3交叉編譯工具,安裝完驗證時發現安裝失敗 (報錯,錯誤與下面參考文章1中第6步一樣,照他說的那條命令去裝32位的庫,但是安裝失

虛擬機器中在Ubuntu14.04搭建QT交叉編譯環境--2014/8/14

一、Ubuntu安裝及配置 在windows上下載VMware10.0.2 並安裝,在網上找永久金鑰啟用。開啟後是中文版 在Ubuntu官網上下載ubuntu-14.04.1-desktop-i386 開啟虛擬機器,並建立新的虛擬機器,記憶體1g,硬碟20g 。虛擬磁碟檔案

Ubuntu14.04使用觸摸屏以及筆記本擴展觸摸屏設置方法

單選 當前 分辨 識別 aid 檢查 分辨率 ubuntu14 photos   今天拿到了一塊觸摸屏,在win10和Ubuntu14.04下測試其使用。觸摸屏品牌為朗歌斯,型號為LS530TM,是一塊15寸電阻觸摸顯示屏。   Windows下的使用很方便,顯示屏上一共三

Ubuntu18.04搭建TensorFlow-GPU環境詳細過程

網上關於Ubuntu16.04及14.04安裝cuda、cudnn等的教程較多,Ubuntu18.04的介紹很少。本文主要介紹Ubuntu18.04下如何安裝英偉達驅動以及cuda、cudnn和Anaconda等程式設計環境。 博主硬體為ThinkPadT450(GeFor

【Linux-Android開發記(一)】Ubuntu 12.04搭建Android開發環境

之前寫過一個系列日誌【Linux菜鳥成長記】Ubuntu 10.04系類教程 。從Ubuntud安裝,到常用設定,再到JDK安裝,Eclipse安裝等。 從這篇日誌開始轉為在Ubuntu進行Android開發的系列日誌,將從基礎的SDK安裝開始,慢慢進入: 環境:Ubunt

ubuntu14.04搭建caffe-lstm(cpu版)

caffe-lstm版本: https://github.com/junhyukoh/caffe-lstm 我用的矩陣計算工具是:openblas 遇到的問題是glog和gflags的問題,解決方法在我的部落格裡有。 直接編譯就可以了。

Ubuntu14.04搭建hadoop2.x(單機篇)

一、準備工作 1、安裝Ubuntu14.04的作業系統,在此不再詳細講述。 2、下載hadoop包,可以直接去 官網 下載。 3、截至到我寫這篇部落格時,最新版本為2.7.1,在此為了方便大家熟悉安裝和配置過程,仍然使用2.4.0的版本來介紹。

Ubuntu 12.04搭建Qt開發環境

Qt開發環境的搭建,具體可按整個專案的開發環境來決定... 例如:本人的電腦主系統是Win7,並且公司提供專門的伺服器來編譯專案,這樣就可以將程式的編輯與編譯分開了。這次是在虛擬機器裡的Ubuntu下搭建一個開發環境,僅當練練手。好,不羅嗦了...  /* -------

Ubuntu16.04搭建python開發環境

準備工作:安裝虛擬機器,並下載安裝Ubuntu16.04系統 1.ubuntu預設root使用者沒有啟用,啟用root使用者,就要為root使用者建立密碼 $sudo passwd root 2、修改主機名 $vi /etc/hostname 3、安裝ssh服務 $sudo

騰訊雲Ubuntu16.04搭建Java開發環境(工具,JDK,Eclipse,MySQL,Tomcat)

工具使用 1.WinSCP:用來傳輸檔案 2.PuTTY:用來開啟命令列 JDK環境配置 1.首先配置jdk環境,到官網下載jdk的linux版本 2.建立目錄/usr/local/java用於存放jdk檔案 mkdir /usr/local/jav

ubuntu14.04無法登入或迴圈登入的解決方法

初學Linux,一開始總是遇到很多問題,故開此部落格,以總結經驗。 遇到的問題:linux系統在開機輸入密碼後,桌面無法正常顯示,所有圖示都消失,右鍵無顯示,但guest模式可以登入。 嘗試解決的方法

Opencv3.3在Ubuntu14.04環境搭建

安裝過程: 第一步:安裝gcc/g++/gdb/make 等基本程式設計工具 sudo apt-get install build-essential 第二步:安裝opencv所依賴的庫、cmake和相關外掛,主要是為了能夠支援讀寫圖片以及視訊等。 sudo apt-

Ubuntu14.04安裝opencv及ROS Indigo配置Kinect V2

Ubuntu14.04下安裝opencv及ROS Indigo下配置Kinect V2 本篇文章是我在配置Kinect V2時的一些記錄,參考了一些前人的經驗部落格,並把遇到的問題記錄了下來。但之前儲存在了word裡面,出現了一些亂碼,這是我盡力修改了之後的結果,但也難免哪裡會出錯,還請

Ubuntu14.04arm-linux-gcc交叉編譯環境搭建

Ubuntu下arm-linux-gcc交叉編譯環境搭建 系統:Ubuntu 14.04 32bit 1、網上下載 arm-linux-gcc-4.4.3.tar.gz 2、解壓

Hadoop2.7.2高可用(HA)環境Hbase高可用(HA)環境搭建(在Ubuntu14.04以root使用者進行配置)

Hadoop2.7.2高可用(HA)環境下Hbase高可用(HA)環境的搭建 轉載請註明出處:http://blog.csdn.net/qq_23181841/article/details/75095370 (在Ubuntu14.04下以root使用者進行配置) 下載

Kinect v2 環境搭建以及除錯步驟

因為kinect v2 要求機子是64位的...前幾天把32位的電腦重灌了一下變成64位的,然後整理電腦的文件又花了不少時間...今天晚上就搭了一下環境,這裡詳細說一下步驟: 一、配置要求:    

整理 ubuntu14.04lua開發環境搭建及測試

Ubuntu下Lua開發環境安裝: 1、sudo apt-get install lua5.1 2、sudo apt-get install lua5.1-0-dev  (可能需要首先安裝 sudo apt-get install libreadline-dev) 說明: