Mac OS 安裝 Kinect 2 SDK 的步驟

Step 1: Download libfreenect2 source code
git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2

Step 2: 安裝最新版 Command Line Tools (for Xcode 9.2)
(例如:Command_Line_Tools_macOS_10.13_for_Xcode_9.2)
Download from Apple Developers:
https://developer.apple.com/downloads/index.action

Step 3: Install dependencies: libusb, GLFW
brew update
brew install libusb
brew tap homebrew/versions
brew install glfw3
brew install pkg-config

Step 4: Install TurboJPEG (optional)
brew tap homebrew/science
brew install jpeg-turbo

Step 5: Install CUDA (Optional)
安裝步驟請看另一篇文章:Mac OS 安裝Cuda及Cudnn

Step 6: Install OpenNI2 (Optional)
brew install openni2

Step 7: Set Environment Variable:
export OPENNI2_REDIST=/usr/local/lib/ni2
export OPENNI2_INCLUDE=/usr/local/include/ni2

Step 8: Install Command_Line_Tools (for Xcode 8.3.3,這一版才有支援Cuda)
CommandLineToolsforXcode_8.3.2.dmg
Download from Apple Developers:
https://developer.apple.com/downloads/index.action

Step 9: Build (要安裝到/usr/local/freenect2,而不要安裝到 /usr/local/lib,以避免與libtiff 等的版本不同產生衝突而造成錯誤)
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/freenect2 -DENABLE_OPENGL=ON -DBUILD_OPENNI2_DRIVER=ON ..
make
sudo make install

Step 10: Run the test program:
./bin/Protonect
Environment variable LIBFREENECT2_PIPELINE can be set to cl, cuda, etc to specify the pipeline.

Ex:
LIBFREENECT2_PIPELINE=cl|cuda|cpu ./UserViewer
LIBFREENECT2_PIPELINE=cuda ./UserViewer