之前決定將ElasticFusion在Kinect v2上覆現後,碰到了諸多問題,經過將近兩個禮拜的摸索,現在將自己的心得寫下,幫助大家少走彎路。
這一節我們先說libfreenect2配置,爲什麼要配置libfreenect2呢,那是因爲可以將kinect v2的圖像信息經過openni2讀取出來。
1.首先我們要下載libfreenect2源碼,地址:
https://github.com/OpenKinect/libfreenect2/
這裏切記,下載master版本,(我之前下載的2.0版本,通過install_libusb_vs201X.cmd這些命令時沒有出現libusb文件夾,折騰了我好久)
2.接下來安裝UsbDk,地址:https://github.com/daynix/UsbDk/releases 直接點擊安裝即可。
3.不過,雖然官網上說安裝UsbDk和安裝libusbk兩個選一個,我個人還是建議安裝libusbk的。
· libusbk地址:http://zadig.akeo.ie/ 下載 Zadig。
· 在Zadig界面Options選項中選擇“List all Devices” ,取消“Ignore Hubs or Composite Parents”。
· 在第一個選項框中選擇”Xbox NUI Sensor(composite parent)” 或“Xbox NUI Sensor” 。箭頭指向的框體中選擇libusbk(v3.0.7.0或者更新版本)。
最後點擊 “Replace Driver”或“Install Driver”。因爲我之前已經安裝過了所以是replace ,到這裏libusbk就安裝完成。
4.接下來我們生成libfreenect2解決方案
下載並安裝git:https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/Git-2.12.2.2-64-bit.exe
安裝時記得選擇Run git from the Windows Command Prompt和Check out Windows style, commit Unix-style line endings 。
地址:https://sourceforge.net/projects/libjpeg-turbo/files/ ,我下載的是1.53。
直接安裝即可,然後設置環境變量:TurboJPEG_ROOT 地址:C:\libjpeg-turbo64(默認應該是安裝在這個路徑下)。
6.安裝64位GLFW
地址:http://www.glfw.org/download.html 下載後解壓到/depends/glfw下,並設置環境變量:GLFW_ROOT
7.安裝opencl
地址: https://software.intel.com/en-us/intel-opencl 這個需要註冊一下才能下載。直接安裝即可
8.安裝openni2
地址:http://structure.io/openni 按照默認設置就好
9.用CMake進行構建
在libfreenect2解壓路徑下新建build文件夾,
Where is the source code設置爲..\解壓路徑
Where to build the binaries設置爲 ..\解壓路徑\build
按“Configure”,彈出的窗口選擇Visual Studio 12 2013 Win64
之後“Generate”
用VS2013打開libfreenect2.sln ,將INSTALL設爲啓動項,生成項目。
隨後打開..\解壓路徑\build\bin\Debug中打開Protonect.exe 就可以看到成果圖了。