Driver for Kinect for Windows v2 (K4W2) devices (release and developer preview).
Note: libfreenect2 does not do anything for either Kinect for Windows v1 or Kinect for Xbox 360 sensors. Use libfreenect1 for those sensors.
If you are using libfreenect2 in an academic context, please cite our work using the following DOI:
If you use the KDE depth unwrapping algorithm implemented in the library, please also cite this ECCV 2016 paper.
This driver supports:
- RGB image transfer
- IR and depth image transfer
- registration of RGB and depth images
Missing features:
- firmware updates (see issue #460 for WiP)
Watch the OpenKinect wiki at www.openkinect.org and the mailing list at https://groups.google.com/forum/#!forum/openkinect for the latest developments and more information about the K4W2 USB protocol.
The API reference documentation is provided here https://openkinect.github.io/libfreenect2/.
- USB 3.0 controller. USB 2 is not supported.
Intel and NEC USB 3.0 host controllers are known to work. ASMedia controllers are known to not work.
Virtual machines likely do not work, because USB 3.0 isochronous transfer is quite delicate.
It has been reported to work for up to 5 devices on a high-end PC using multiple separate PCI Express USB3 expansion cards (with NEC controller chip). If you're using Linux, you may have to increase USBFS memory buffers. Depending on the number of Kinects, you may need to use an even larger buffer size. If you're using an expansion card, make sure it's not plugged into an PCI-E x1 slot. A single lane doesn't have enough bandwidth. x8 or x16 slots usually work.
- Windows 7 (buggy), Windows 8, Windows 8.1, and probably Windows 10
- Debian, Ubuntu 14.04 or newer, probably other Linux distros. Recommend kernel 3.16+ or as new as possible.
- Mac OS X
- OpenGL depth processing: OpenGL 3.1 (Windows, Linux, Mac OS X). OpenGL ES is not supported at the moment.
- OpenCL depth processing: OpenCL 1.1
- CUDA depth processing: CUDA (6.5 and 7.5 are tested; The minimum version is not clear.)
- VAAPI JPEG decoding: Intel (minimum Ivy Bridge or newer) and Linux only
- VideoToolbox JPEG decoding: Mac OS X only
- OpenNI2 integration: OpenNI2 2.2.0.33
- Jetson TK1: Linux4Tegra 21.3 or later. Check Jetson TK1 issues before installation. Jetson TX1 is not yet supported as the developers don't have one, but it may be easy to add the support.
First, check https://github.com/OpenKinect/libfreenect2/wiki/Troubleshooting for known issues.
When you report USB issues, please attach relevant debug log from running the program with environment variable LIBUSB_DEBUG=3
, and relevant log from dmesg
. Also include relevant hardware information lspci
and lsusb -t
.
- Joshua Blake joshblake@gmail.com
- Florian Echtler
- Christian Kerl
- Lingzhu Xiang (development/master branch)
-
Install UsbDk driver
- (Windows 7) You must first install Microsoft Security Advisory 3033929 otherwise your USB keyboards and mice will stop working!
- Download the latest x64 installer from https://github.com/daynix/UsbDk/releases, install it.
- If UsbDk somehow does not work, uninstall UsbDk and follow the libusbK instructions.
This doesn't interfere with the Microsoft SDK. Do not install both UsbDK and libusbK drivers
-
(Alternatively) Install libusbK driver
You don't need the Kinect for Windows v2 SDK to build and install libfreenect2, though it doesn't hurt to have it too. You don't need to uninstall the SDK or the driver before doing this procedure.
Install the libusbK backend driver for libusb. Please follow the steps exactly:
- Download Zadig from http://zadig.akeo.ie/.
- Run Zadig and in options, check "List All Devices" and uncheck "Ignore Hubs or Composite Parents"
- Select the "Xbox NUI Sensor (composite parent)" from the drop-down box. (Important: Ignore the "NuiSensor Adaptor" varieties, which are the adapter, NOT the Kinect) The current driver will list usbccgp. USB ID is VID 045E, PID 02C4 or 02D8.
- Select libusbK (v3.0.7.0 or newer) from the replacement driver list.
- Click the "Replace Driver" button. Click yes on the warning about replacing a system driver. (This is because it is a composite parent.)
To uninstall the libusbK driver (and get back the official SDK driver, if installed):
- Open "Device Manager"
- Under "libusbK USB Devices" tree, right click the "Xbox NUI Sensor (Composite Parent)" device and select uninstall.
- Important: Check the "Delete the driver software for this device." checkbox, then click OK.
If you already had the official SDK driver installed and you want to use it:
- In Device Manager, in the Action menu, click "Scan for hardware changes."
This will enumerate the Kinect sensor again and it will pick up the K4W2 SDK driver, and you should be ready to run KinectService.exe again immediately.
You can go back and forth between the SDK driver and the libusbK driver very quickly and easily with these steps.
-
Build libusb
Open a Git shell (GitHub for Windows), or any shell that has access to git.exe and msbuild.exe
cd depends/ .\install_libusb_vs2013.cmd
Or
install_libusb_vs2015.cmd
. If you see some errors, you can always open the cmd files and follow the git commands, and maybe buildlibusb_201x.sln
with Visual Studio by hand. Building with "Win32" is not recommended as it results in lower performance. -
Install TurboJPEG
Download from http://sourceforge.net/projects/libjpeg-turbo/files, extract it to
c:\libjpeg-turbo64
ordepends/libjpeg-turbo64
, or anywhere as specified by the environment variableTurboJPEG_ROOT
. -
Install GLFW
Download from http://www.glfw.org/download.html (64-bit), extract as
depends/glfw
(renameglfw-3.x.x.bin.WIN64
toglfw
), or anywhere as specified by the environment variableGLFW_ROOT
. -
Install OpenCL (optional)
- Intel GPU: Download "Intel® SDK for OpenCL™ Applications 2016" from https://software.intel.com/en-us/intel-opencl (requires free registration) and install it.
-
Install CUDA (optional, Nvidia only)
- Download CUDA Toolkit and install it. You MUST install the samples too.
-
Install OpenNI2 (optional)
Download OpenNI 2.2.0.33 (x64) from http://structure.io/openni, install it to default locations (
C:\Program Files...
). -
Build
The default installation path is
install
, you may change it by editingCMAKE_INSTALL_PREFIX
.mkdir build && cd build cmake .. -G "Visual Studio 12 2013 Win64" cmake --build . --config RelWithDebInfo --target install
Or
-G "Visual Studio 14 2015 Win64"
. -
Run the test program:
.\install\bin\Protonect.exe
, or start debugging in Visual Studio. -
Test OpenNI2 (optional)
Copy freenect2-openni2.dll, and other dll files (libusb-1.0.dll, glfw.dll, etc.) in
install\bin
toC:\Program Files\OpenNI2\Tools\OpenNI2\Drivers
. Then runC:\Program Files\OpenNI\Tools\NiViewer.exe
. Environment variableLIBFREENECT2_PIPELINE
can be set tocl
,cuda
, etc to specify the pipeline.
Use your favorite package managers (brew, ports, etc.) to install most if not all dependencies:
- Make sure these build tools are available: wget, git, cmake, pkg-config. Xcode may provide some of them. Install the rest via package managers.
- Download libfreenect2 source
git clone https://github.com/OpenKinect/libfreenect2.git cd libfreenect2
- Install dependencies: libusb, GLFW
brew update brew install libusb brew install glfw3
- Install TurboJPEG (optional)
brew install jpeg-turbo
- Install CUDA (optional): TODO
- Install OpenNI2 (optional)
brew tap brewsci/science brew install openni2 export OPENNI2_REDIST=/usr/local/lib/ni2 export OPENNI2_INCLUDE=/usr/local/include/ni2
- Build
mkdir build && cd build cmake .. make make install
- Run the test program:
./bin/Protonect
- Test OpenNI2.
make install-openni2
(may need sudo), then runNiViewer
. Environment variableLIBFREENECT2_PIPELINE
can be set tocl
,cuda
, etc to specify the pipeline.
Note: Ubuntu 12.04 is too old to support. Debian jessie may also be too old, and Debian stretch is implied in the following.
- Download libfreenect2 source
git clone https://github.com/OpenKinect/libfreenect2.git cd libfreenect2
- (Ubuntu 14.04 only) Download upgrade deb files
cd depends; ./download_debs_trusty.sh
- Install build tools
sudo apt-get install build-essential cmake pkg-config
- Install libusb. The version must be >= 1.0.20.
- (Ubuntu 14.04 only)
sudo dpkg -i debs/libusb*deb
- (Other)
sudo apt-get install libusb-1.0-0-dev
- (Ubuntu 14.04 only)
- Install TurboJPEG
- (Ubuntu 14.04 to 16.04)
sudo apt-get install libturbojpeg libjpeg-turbo8-dev
- (Debian/Ubuntu 17.10 and newer)
sudo apt-get install libturbojpeg0-dev
- (Ubuntu 14.04 to 16.04)
- Install OpenGL
- (Ubuntu 14.04 only)
sudo dpkg -i debs/libglfw3*deb; sudo apt-get install -f
- (Odroid XU4) OpenGL 3.1 is not supported on this platform. Use
cmake -DENABLE_OPENGL=OFF
later. - (Other)
sudo apt-get install libglfw3-dev
- (Ubuntu 14.04 only)
- Install OpenCL (optional)
- Intel GPU
- (Ubuntu 14.04 only)
sudo apt-add-repository ppa:floe/beignet; sudo apt-get update; sudo apt-get install beignet-dev; sudo dpkg -i debs/ocl-icd*deb
- (Other)
sudo apt-get install beignet-dev
- For older kernels,
# echo 0 >/sys/module/i915/parameters/enable_cmd_parser
is needed. See more known issues at https://www.freedesktop.org/wiki/Software/Beignet/.
- (Ubuntu 14.04 only)
- AMD GPU: Install the latest version of the AMD Catalyst drivers from https://support.amd.com and
apt-get install opencl-headers
. - Mali GPU (e.g. Odroid XU4): (with root)
mkdir -p /etc/OpenCL/vendors; echo /usr/lib/arm-linux-gnueabihf/mali-egl/libmali.so >/etc/OpenCL/vendors/mali.icd; apt-get install opencl-headers
. - Verify: You can install
clinfo
to verify if you have correctly set up the OpenCL stack.
- Intel GPU
- Install CUDA (optional, Nvidia only):
- (Ubuntu 14.04 only) Download
cuda-repo-ubuntu1404...*.deb
("deb (network)") from Nvidia website, follow their installation instructions, includingapt-get install cuda
which installs Nvidia graphics driver. - (Jetson TK1) It is preloaded.
- (Nvidia/Intel dual GPUs) After
apt-get install cuda
, usesudo prime-select intel
to use Intel GPU for desktop. - (Other) Follow Nvidia website's instructions. You must install the samples package.
- (Ubuntu 14.04 only) Download
- Install VAAPI (optional, Intel only)
- (Ubuntu 14.04 only)
sudo dpkg -i debs/{libva,i965}*deb; sudo apt-get install -f
- (Other)
sudo apt-get install libva-dev libjpeg-dev
- Linux kernels 4.1 to 4.3 have performance regression. Use 4.0 and earlier or 4.4 and later (Though Ubuntu kernel 4.2.0-28.33~14.04.1 has backported the fix).
- (Ubuntu 14.04 only)
- Install OpenNI2 (optional)
- (Ubuntu 14.04 only)
sudo apt-add-repository ppa:deb-rob/ros-trusty && sudo apt-get update
(You don't need this if you have ROS repos), thensudo apt-get install libopenni2-dev
- (Other)
sudo apt-get install libopenni2-dev
- (Ubuntu 14.04 only)
- Build (if you have run
cd depends
previously,cd ..
back to the libfreenect2 root directory first.)You need to specifymkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 make make install
cmake -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2
for CMake based third-party application to find libfreenect2. - Set up udev rules for device access:
sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
, then replug the Kinect. - Run the test program:
./bin/Protonect
- Run OpenNI2 test (optional):
sudo apt-get install openni2-utils && sudo make install-openni2 && NiViewer2
. Environment variableLIBFREENECT2_PIPELINE
can be set tocl
,cuda
, etc to specify the pipeline.