Open source drivers for the Kinect for Windows v2 device, focused on macOS and Linux support
0
stars
906
commits
C++
primary language
Aug 6, 2026
updated
Open source cross-platform driver for the Kinect for Windows v2 (K4W2) sensor. It streams color, infrared, and depth over USB 3.0 and registers color to depth so you can build point clouds β on Linux, Windows, and macOS, including Apple Silicon with a Metal GPU pipeline.
π Full documentation and API reference β
This is hbmartin/libfreenect2-metal, an actively maintained fork of OpenKinect/libfreenect2. Clone this repository β upstream has no Metal pipeline and none of the 0.4 APIs described below. See What's different in this fork.
Note: this driver does nothing for Kinect for Windows v1 or Kinect for Xbox 360 sensors. Use libfreenect for those. Not sure which one you have, or why v1 advice keeps not working? See Kinect v1 versus Kinect v2.
libfreenect2/vision.h β a C++17 interface for validated caller-buffer
color conversion, forward and reverse registration maps, coherent depth
selection, and batched metric XYZ lifting.helper_math.h are not required, and CMake does not
search sample paths.Missing features: firmware updates (see issue #460 for WiP) and calibrated directional audio. Native Kinect SDK-style body/skeleton tracking is also out of scope; the supported Python pose-estimation workflow uses MediaPipe plus registered depth and produces estimates rather than sensor-provided joints.
Install for your platform (macOS, Linux, Windows), then open a device and pull registered frames:
#include <libfreenect2/libfreenect2.hpp>
#include <libfreenect2/frame_listener_impl.h>
#include <libfreenect2/registration.h>
int main()
{
libfreenect2::Freenect2 freenect2;
if (freenect2.enumerateDevices() == 0)
return 1;
// Picks the best available pipeline: metal > opengl > cuda > opencl > cpu.
libfreenect2::Freenect2Device *dev =
freenect2.openDevice(freenect2.getDefaultDeviceSerialNumber());
if (dev == 0)
return 1;
libfreenect2::SyncMultiFrameListener listener(
libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth);
dev->setColorFrameListener(&listener);
dev->setIrAndDepthFrameListener(&listener);
if (!dev->start())
return 1;
libfreenect2::Registration registration(dev->getIrCameraParams(),
dev->getColorCameraParams());
libfreenect2::Frame undistorted(512, 424, 4, nullptr,
libfreenect2::Frame::Float);
libfreenect2::Frame registered(512, 424, 4, nullptr,
libfreenect2::Frame::BGRX);
libfreenect2::FrameMap frames;
for (int i = 0; i < 100; ++i)
{
if (!listener.waitForNewFrame(frames, 10 * 1000)) // 10 s timeout
break;
libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
// `registered` now holds color aligned to the 512x424 depth image.
registration.apply(rgb, depth, &undistorted, ®istered);
listener.release(frames);
}
dev->stop();
dev->close();
return 0;
}
Consume the installed library from CMake:
find_package(freenect2 REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE freenect2::freenect2)
If you installed to a non-standard prefix, point CMake at it:
cmake -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2 ..
More: the API walkthrough,
the registration recipes, and
examples/.
Why one controller per sensor, and how to confirm the link negotiated SuperSpeed: USB bandwidth and transfer tuning.
| Tier | Platforms |
|---|---|
| Tested | Ubuntu 22.04/24.04 (GCC/Clang Γ shared/static, sanitizers, fuzzers, coverage); macOS on Apple Silicon (Metal, C++17, Metal/CPU parity on real hardware) |
| Expected to work | Ubuntu 22.04 LTS and newer, Debian 12 and newer, other current distributions with libusb β₯ 1.0.20 and kernel β₯ 5.15; macOS on Intel; Windows 10 and newer |
| Unsupported | Ubuntu 20.04 and older, Debian 11 and older, Windows 8 and older, any USB 2 host, virtual machines, Jetson TK1/TX1 |
Older platforms are not blocked by the build system, but they are untested and some optional-backend packages no longer exist for them.
CMake 3.16 or newer, and a C++17 compiler. CI builds at C++17 with GCC, Clang, and AppleClang.
| Feature | Requirement |
|---|---|
| Metal depth processing | macOS (Apple platforms) |
| OpenGL depth processing | OpenGL 3.1. OpenGL ES is not supported. |
| OpenCL depth processing | OpenCL 1.1 |
| CUDA depth processing | CUDA Toolkit (CUDA 12.3 is covered by compile-only CI) |
| VAAPI JPEG decoding | Intel Ivy Bridge or newer, Linux only |
| VideoToolbox JPEG decoding | macOS only (off by default on Apple Silicon) |
| OpenNI2 integration | OpenNI2 2.2.0.33 |
| Offline conventional calibration | OpenCV 4.5 or newer; opt in with BUILD_CALIBRATION_TOOLS=ON |
Full, platform-specific instructions live in doc/:
Condensed versions:
brew install cmake pkg-config ninja libusb glfw3 jpeg-turbo
git clone https://github.com/hbmartin/libfreenect2-metal.git
cd libfreenect2-metal
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
./build/bin/Protonect
On Apple Silicon, run the build from a native arm64 terminal β arch must
print arm64. A shell or IDE under Rosetta produces x86_64 builds that cannot
link Homebrew's arm64 libraries in /opt/homebrew. CMake detects this at
configure time and stops with instructions. Full detail:
macOS install guide.
sudo apt-get install build-essential cmake pkg-config ninja-build \
libusb-1.0-0-dev libturbojpeg0-dev libglfw3-dev
git clone https://github.com/hbmartin/libfreenect2-metal.git
cd libfreenect2-metal
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$HOME/freenect2
cmake --build build
cmake --install build
# Device access β required, otherwise the sensor is root-only
sudo cp platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
# then unplug and replug the Kinect
./build/bin/Protonect
Minimum supported release is Ubuntu 22.04 LTS. Optional backends (OpenCL, CUDA, VAAPI, OpenNI2), support tiers, and multi-sensor setup: Linux install guide.
depends/: libusb
as depends/libusb, TurboJPEG
to c:\libjpeg-turbo64, and GLFW as
depends/glfw.mkdir build && cd build
cmake .. -G "Visual Studio 16 2019"
cmake --build . --config RelWithDebInfo --target install
.\install\bin\Protonect.exe.Exact driver steps, uninstall instructions, and optional backends: Windows install guide.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./vcpkg integrate install
vcpkg install libfreenect2
Note that the vcpkg port tracks upstream OpenKinect/libfreenect2, not this
fork, so it has no Metal pipeline or 0.4 APIs.
The cuda and cuda_kde pipelines depend only on headers and libraries from
the CUDA Toolkit. NVIDIA's CUDA samples and their former helper_math.h header
are not required, and CMake does not search sample installation paths.
On a machine with an NVIDIA GPU:
cmake -S . -B build-cuda -DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=native
cmake --build build-cuda --target freenect2
For a GPU-less build host or container, specify the architecture explicitly, for
example -DCMAKE_CUDA_ARCHITECTURES=75. CMake 3.23 and newer otherwise defaults
to all-major, so configuration does not need to query a local GPU.
Hosted CI compiles both pipelines with CUDA 12.3 but does not claim runtime validation; compare CUDA and CPU output on real hardware before a release.
Pass these to CMake as -DOPTION=VALUE.
| Option | Default | Effect |
|---|---|---|
BUILD_SHARED_LIBS | ON | Build shared (ON) or static (OFF) libraries |
BUILD_EXAMPLES | ON | Build the example programs |
BUILD_OPENNI2_DRIVER | ON | Build the OpenNI2 driver |
BUILD_TESTING | OFF | Build the unit test suite |
BUILD_CALIBRATION_TOOLS | OFF | Build the headless OpenCV calibration/YAML conversion tool |
ENABLE_METAL | ON on Apple, else OFF | Metal GPU depth processing |
ENABLE_OPENGL | ON | OpenGL depth processing (needs OpenGL 3.1) |
ENABLE_OPENCL | ON | OpenCL depth processing |
ENABLE_CUDA | ON | CUDA depth processing |
ENABLE_VAAPI | ON | VA-API JPEG decoding (Intel, Linux) |
ENABLE_VIDEOTOOLBOX | OFF on Apple Silicon, ON on Intel Mac | VideoToolbox RGB decoder. It crashes on M1 and later, hence the split default; TurboJPEG is used instead. |
ENABLE_TEGRAJPEG | ON | Tegra hardware JPEG support |
ENABLE_PROFILING | OFF | Collect profiling stats (memory consuming) |
BUILD_STREAMER_RECORDER | OFF | Build the streamer_recorder tool |
ENABLE_SANITIZERS | OFF | ASan + UBSan on first-party targets |
An ENABLE_* backend is silently skipped if its dependencies are not found; the
CMake configure summary reports what was actually enabled. Development-only
flags β warnings-as-errors, individual sanitizers, coverage, fuzzing, stdlib
hardening β are documented in
Development and contributing.
| Name | Platform | Requires | Notes |
|---|---|---|---|
cpu | all | β | Always available; terminates the fallback chain |
metal | Apple | ENABLE_METAL | Preferred on Apple Silicon; OpenGL is deprecated by Apple |
opengl | all | OpenGL 3.1 | OpenGL ES is not supported |
opencl | all | OpenCL 1.1 | |
opencl_kde | all | OpenCL 1.1 | KDE depth unwrapping |
cuda | NVIDIA | CUDA Toolkit | |
cuda_kde | NVIDIA | CUDA Toolkit | KDE depth unwrapping |
dump | all | β | Dumps raw frames instead of decoding depth |
Select one at runtime:
LIBFREENECT2_PIPELINE=metal ./Protonect
The older gl and cl spellings are accepted only as aliases through
LIBFREENECT2_PIPELINE; everywhere else use the canonical names above. If the
requested pipeline is unavailable, libfreenect2 logs a warning and falls through
the chain metal β opengl β cuda β opencl β cpu, probing each for a usable
runtime device. The opened device reports the pipeline it actually consumed.
Protonect additionally accepts a pipeline as a positional argument using its
own short vocabulary: cpu, gl, cl, clkde, cuda, cudakde, metal.
Unlike the environment preference, a positional GPU selection is strict:
Protonect exits before opening a sensor when that backend is not compiled or
has no usable runtime device.
To discover pipelines programmatically, getCompiledPacketPipelines() returns
the canonical names built into the library and getAvailablePacketPipelines()
returns those usable on the current machine. Availability probing constructs
each pipeline and can initialize GPU runtimes, so keep it off latency-sensitive
paths.
Other environment variables β logging level and USB buffer tuning β are in the runtime configuration reference.
Built when BUILD_EXAMPLES=ON (the default), into build/bin.
| Program | What it does |
|---|---|
Protonect | The reference viewer and smoke test. Displays color, IR, depth, and registered output. Protonect [-gpu=<id>] [gl|cl|clkde|cuda|cudakde|metal|cpu] [<serial>] |
KinectCapture | Writes frames to disk: continuous capture, timestamp-paired snapshot, or raw stream record. Supports canonical calibration and depth-correction profiles. |
KinectCameraCalibration | Optional headless, recording-driven conventional camera calibration and legacy YAML conversion tool. See calibration profiles. |
KinectDepthCalibration | Fits a per-device linear depth correction profile from live or recorded data over a known-distance ROI. See depth calibration. |
KinectReconnect | Exercises disconnect and recovery handling. KinectReconnect [SERIAL] |
examples/CMakeLists.txt doubles as a standalone build system for an
out-of-tree application linking an installed libfreenect2.
The full site, including the API reference and every guide below, is published at https://hbmartin.github.io/libfreenect2-metal/.
Upgrade
Install and fix
Work with the data
Integrate
Go deeper
Maintain
See the troubleshooting guide first; the upstream troubleshooting wiki still holds useful hardware-specific notes.
Report bugs at https://github.com/hbmartin/libfreenect2-metal/issues. For USB
issues, attach the output of the program run with LIBUSB_DEBUG=3, the relevant
dmesg log, and hardware information from lspci and lsusb -t.
Issues and pull requests are welcome at https://github.com/hbmartin/libfreenect2-metal.
cmake -S . -B build-dev -G Ninja -DBUILD_TESTING=ON -DENABLE_WARNINGS_AS_ERRORS=ON
cmake --build build-dev
ctest --test-dir build-dev --output-on-failure
The repository's Python tooling requires Python 3.12 or newer and uv; it
is not needed to build or use the library. Toolchain requirements, the CI
matrix, sanitizer and fuzzing profiles, formatting rules, and the docs build are
all covered in Development and contributing.
The current version is 0.4.0 (PROJECT_VERSION in CMakeLists.txt). The
library also reports its version, API version, and build revision at runtime;
see Migrating to libfreenect2 0.4.
libfreenect2 is available under your choice of either:
Apache-2.0), orGPL-2.0-only).SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-only
Full texts are in APACHE20 and GPL2; see
LICENSE for the summary. Individual files may carry additional
attribution or redistribution notices that must be preserved. Third-party
components remain under their own licenses, with notices alongside those
components and in depends/LICENSES.txt.
This fork is maintained by Harold Martin.
Upstream libfreenect2 maintainers:
Contributor attributions are collected in CONTRIB.
If you use the KDE depth unwrapping algorithm implemented in this library, please cite the ECCV 2016 paper.
The libfreenect2 wiki and the
mailing list carry
background on the K4W2 USB protocol; what remained useful from the wiki has been
absorbed into doc/ β see
the protocol reference, performance,
USB notes, and troubleshooting.
(The former openkinect.org domain, which hosted the Kinect v1 wiki, has
lapsed and now serves unrelated ads β do not use it.)
(top 30 of 45)
Hacker News (1)
C++
78.2%
C
8.0%
Cuda
4.8%
CMake
3.7%
Objective-C++
1.7%
Metal
1.1%
Open source drivers for the Kinect for Windows v2 device, focused on macOS and Linux support
0
stars
906
commits
C++
primary language
Aug 6, 2026
updated
Open source cross-platform driver for the Kinect for Windows v2 (K4W2) sensor. It streams color, infrared, and depth over USB 3.0 and registers color to depth so you can build point clouds β on Linux, Windows, and macOS, including Apple Silicon with a Metal GPU pipeline.
π Full documentation and API reference β
This is hbmartin/libfreenect2-metal, an actively maintained fork of OpenKinect/libfreenect2. Clone this repository β upstream has no Metal pipeline and none of the 0.4 APIs described below. See What's different in this fork.
Note: this driver does nothing for Kinect for Windows v1 or Kinect for Xbox 360 sensors. Use libfreenect for those. Not sure which one you have, or why v1 advice keeps not working? See Kinect v1 versus Kinect v2.
libfreenect2/vision.h β a C++17 interface for validated caller-buffer
color conversion, forward and reverse registration maps, coherent depth
selection, and batched metric XYZ lifting.helper_math.h are not required, and CMake does not
search sample paths.Missing features: firmware updates (see issue #460 for WiP) and calibrated directional audio. Native Kinect SDK-style body/skeleton tracking is also out of scope; the supported Python pose-estimation workflow uses MediaPipe plus registered depth and produces estimates rather than sensor-provided joints.
Install for your platform (macOS, Linux, Windows), then open a device and pull registered frames:
#include <libfreenect2/libfreenect2.hpp>
#include <libfreenect2/frame_listener_impl.h>
#include <libfreenect2/registration.h>
int main()
{
libfreenect2::Freenect2 freenect2;
if (freenect2.enumerateDevices() == 0)
return 1;
// Picks the best available pipeline: metal > opengl > cuda > opencl > cpu.
libfreenect2::Freenect2Device *dev =
freenect2.openDevice(freenect2.getDefaultDeviceSerialNumber());
if (dev == 0)
return 1;
libfreenect2::SyncMultiFrameListener listener(
libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth);
dev->setColorFrameListener(&listener);
dev->setIrAndDepthFrameListener(&listener);
if (!dev->start())
return 1;
libfreenect2::Registration registration(dev->getIrCameraParams(),
dev->getColorCameraParams());
libfreenect2::Frame undistorted(512, 424, 4, nullptr,
libfreenect2::Frame::Float);
libfreenect2::Frame registered(512, 424, 4, nullptr,
libfreenect2::Frame::BGRX);
libfreenect2::FrameMap frames;
for (int i = 0; i < 100; ++i)
{
if (!listener.waitForNewFrame(frames, 10 * 1000)) // 10 s timeout
break;
libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];
libfreenect2::Frame *depth = frames[libfreenect2::Frame::Depth];
// `registered` now holds color aligned to the 512x424 depth image.
registration.apply(rgb, depth, &undistorted, ®istered);
listener.release(frames);
}
dev->stop();
dev->close();
return 0;
}
Consume the installed library from CMake:
find_package(freenect2 REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE freenect2::freenect2)
If you installed to a non-standard prefix, point CMake at it:
cmake -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2 ..
More: the API walkthrough,
the registration recipes, and
examples/.
Why one controller per sensor, and how to confirm the link negotiated SuperSpeed: USB bandwidth and transfer tuning.
| Tier | Platforms |
|---|---|
| Tested | Ubuntu 22.04/24.04 (GCC/Clang Γ shared/static, sanitizers, fuzzers, coverage); macOS on Apple Silicon (Metal, C++17, Metal/CPU parity on real hardware) |
| Expected to work | Ubuntu 22.04 LTS and newer, Debian 12 and newer, other current distributions with libusb β₯ 1.0.20 and kernel β₯ 5.15; macOS on Intel; Windows 10 and newer |
| Unsupported | Ubuntu 20.04 and older, Debian 11 and older, Windows 8 and older, any USB 2 host, virtual machines, Jetson TK1/TX1 |
Older platforms are not blocked by the build system, but they are untested and some optional-backend packages no longer exist for them.
CMake 3.16 or newer, and a C++17 compiler. CI builds at C++17 with GCC, Clang, and AppleClang.
| Feature | Requirement |
|---|---|
| Metal depth processing | macOS (Apple platforms) |
| OpenGL depth processing | OpenGL 3.1. OpenGL ES is not supported. |
| OpenCL depth processing | OpenCL 1.1 |
| CUDA depth processing | CUDA Toolkit (CUDA 12.3 is covered by compile-only CI) |
| VAAPI JPEG decoding | Intel Ivy Bridge or newer, Linux only |
| VideoToolbox JPEG decoding | macOS only (off by default on Apple Silicon) |
| OpenNI2 integration | OpenNI2 2.2.0.33 |
| Offline conventional calibration | OpenCV 4.5 or newer; opt in with BUILD_CALIBRATION_TOOLS=ON |
Full, platform-specific instructions live in doc/:
Condensed versions:
brew install cmake pkg-config ninja libusb glfw3 jpeg-turbo
git clone https://github.com/hbmartin/libfreenect2-metal.git
cd libfreenect2-metal
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
./build/bin/Protonect
On Apple Silicon, run the build from a native arm64 terminal β arch must
print arm64. A shell or IDE under Rosetta produces x86_64 builds that cannot
link Homebrew's arm64 libraries in /opt/homebrew. CMake detects this at
configure time and stops with instructions. Full detail:
macOS install guide.
sudo apt-get install build-essential cmake pkg-config ninja-build \
libusb-1.0-0-dev libturbojpeg0-dev libglfw3-dev
git clone https://github.com/hbmartin/libfreenect2-metal.git
cd libfreenect2-metal
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$HOME/freenect2
cmake --build build
cmake --install build
# Device access β required, otherwise the sensor is root-only
sudo cp platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
# then unplug and replug the Kinect
./build/bin/Protonect
Minimum supported release is Ubuntu 22.04 LTS. Optional backends (OpenCL, CUDA, VAAPI, OpenNI2), support tiers, and multi-sensor setup: Linux install guide.
depends/: libusb
as depends/libusb, TurboJPEG
to c:\libjpeg-turbo64, and GLFW as
depends/glfw.mkdir build && cd build
cmake .. -G "Visual Studio 16 2019"
cmake --build . --config RelWithDebInfo --target install
.\install\bin\Protonect.exe.Exact driver steps, uninstall instructions, and optional backends: Windows install guide.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./vcpkg integrate install
vcpkg install libfreenect2
Note that the vcpkg port tracks upstream OpenKinect/libfreenect2, not this
fork, so it has no Metal pipeline or 0.4 APIs.
The cuda and cuda_kde pipelines depend only on headers and libraries from
the CUDA Toolkit. NVIDIA's CUDA samples and their former helper_math.h header
are not required, and CMake does not search sample installation paths.
On a machine with an NVIDIA GPU:
cmake -S . -B build-cuda -DENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=native
cmake --build build-cuda --target freenect2
For a GPU-less build host or container, specify the architecture explicitly, for
example -DCMAKE_CUDA_ARCHITECTURES=75. CMake 3.23 and newer otherwise defaults
to all-major, so configuration does not need to query a local GPU.
Hosted CI compiles both pipelines with CUDA 12.3 but does not claim runtime validation; compare CUDA and CPU output on real hardware before a release.
Pass these to CMake as -DOPTION=VALUE.
| Option | Default | Effect |
|---|---|---|
BUILD_SHARED_LIBS | ON | Build shared (ON) or static (OFF) libraries |
BUILD_EXAMPLES | ON | Build the example programs |
BUILD_OPENNI2_DRIVER | ON | Build the OpenNI2 driver |
BUILD_TESTING | OFF | Build the unit test suite |
BUILD_CALIBRATION_TOOLS | OFF | Build the headless OpenCV calibration/YAML conversion tool |
ENABLE_METAL | ON on Apple, else OFF | Metal GPU depth processing |
ENABLE_OPENGL | ON | OpenGL depth processing (needs OpenGL 3.1) |
ENABLE_OPENCL | ON | OpenCL depth processing |
ENABLE_CUDA | ON | CUDA depth processing |
ENABLE_VAAPI | ON | VA-API JPEG decoding (Intel, Linux) |
ENABLE_VIDEOTOOLBOX | OFF on Apple Silicon, ON on Intel Mac | VideoToolbox RGB decoder. It crashes on M1 and later, hence the split default; TurboJPEG is used instead. |
ENABLE_TEGRAJPEG | ON | Tegra hardware JPEG support |
ENABLE_PROFILING | OFF | Collect profiling stats (memory consuming) |
BUILD_STREAMER_RECORDER | OFF | Build the streamer_recorder tool |
ENABLE_SANITIZERS | OFF | ASan + UBSan on first-party targets |
An ENABLE_* backend is silently skipped if its dependencies are not found; the
CMake configure summary reports what was actually enabled. Development-only
flags β warnings-as-errors, individual sanitizers, coverage, fuzzing, stdlib
hardening β are documented in
Development and contributing.
| Name | Platform | Requires | Notes |
|---|---|---|---|
cpu | all | β | Always available; terminates the fallback chain |
metal | Apple | ENABLE_METAL | Preferred on Apple Silicon; OpenGL is deprecated by Apple |
opengl | all | OpenGL 3.1 | OpenGL ES is not supported |
opencl | all | OpenCL 1.1 | |
opencl_kde | all | OpenCL 1.1 | KDE depth unwrapping |
cuda | NVIDIA | CUDA Toolkit | |
cuda_kde | NVIDIA | CUDA Toolkit | KDE depth unwrapping |
dump | all | β | Dumps raw frames instead of decoding depth |
Select one at runtime:
LIBFREENECT2_PIPELINE=metal ./Protonect
The older gl and cl spellings are accepted only as aliases through
LIBFREENECT2_PIPELINE; everywhere else use the canonical names above. If the
requested pipeline is unavailable, libfreenect2 logs a warning and falls through
the chain metal β opengl β cuda β opencl β cpu, probing each for a usable
runtime device. The opened device reports the pipeline it actually consumed.
Protonect additionally accepts a pipeline as a positional argument using its
own short vocabulary: cpu, gl, cl, clkde, cuda, cudakde, metal.
Unlike the environment preference, a positional GPU selection is strict:
Protonect exits before opening a sensor when that backend is not compiled or
has no usable runtime device.
To discover pipelines programmatically, getCompiledPacketPipelines() returns
the canonical names built into the library and getAvailablePacketPipelines()
returns those usable on the current machine. Availability probing constructs
each pipeline and can initialize GPU runtimes, so keep it off latency-sensitive
paths.
Other environment variables β logging level and USB buffer tuning β are in the runtime configuration reference.
Built when BUILD_EXAMPLES=ON (the default), into build/bin.
| Program | What it does |
|---|---|
Protonect | The reference viewer and smoke test. Displays color, IR, depth, and registered output. Protonect [-gpu=<id>] [gl|cl|clkde|cuda|cudakde|metal|cpu] [<serial>] |
KinectCapture | Writes frames to disk: continuous capture, timestamp-paired snapshot, or raw stream record. Supports canonical calibration and depth-correction profiles. |
KinectCameraCalibration | Optional headless, recording-driven conventional camera calibration and legacy YAML conversion tool. See calibration profiles. |
KinectDepthCalibration | Fits a per-device linear depth correction profile from live or recorded data over a known-distance ROI. See depth calibration. |
KinectReconnect | Exercises disconnect and recovery handling. KinectReconnect [SERIAL] |
examples/CMakeLists.txt doubles as a standalone build system for an
out-of-tree application linking an installed libfreenect2.
The full site, including the API reference and every guide below, is published at https://hbmartin.github.io/libfreenect2-metal/.
Upgrade
Install and fix
Work with the data
Integrate
Go deeper
Maintain
See the troubleshooting guide first; the upstream troubleshooting wiki still holds useful hardware-specific notes.
Report bugs at https://github.com/hbmartin/libfreenect2-metal/issues. For USB
issues, attach the output of the program run with LIBUSB_DEBUG=3, the relevant
dmesg log, and hardware information from lspci and lsusb -t.
Issues and pull requests are welcome at https://github.com/hbmartin/libfreenect2-metal.
cmake -S . -B build-dev -G Ninja -DBUILD_TESTING=ON -DENABLE_WARNINGS_AS_ERRORS=ON
cmake --build build-dev
ctest --test-dir build-dev --output-on-failure
The repository's Python tooling requires Python 3.12 or newer and uv; it
is not needed to build or use the library. Toolchain requirements, the CI
matrix, sanitizer and fuzzing profiles, formatting rules, and the docs build are
all covered in Development and contributing.
The current version is 0.4.0 (PROJECT_VERSION in CMakeLists.txt). The
library also reports its version, API version, and build revision at runtime;
see Migrating to libfreenect2 0.4.
libfreenect2 is available under your choice of either:
Apache-2.0), orGPL-2.0-only).SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-only
Full texts are in APACHE20 and GPL2; see
LICENSE for the summary. Individual files may carry additional
attribution or redistribution notices that must be preserved. Third-party
components remain under their own licenses, with notices alongside those
components and in depends/LICENSES.txt.
This fork is maintained by Harold Martin.
Upstream libfreenect2 maintainers:
Contributor attributions are collected in CONTRIB.
If you use the KDE depth unwrapping algorithm implemented in this library, please cite the ECCV 2016 paper.
The libfreenect2 wiki and the
mailing list carry
background on the K4W2 USB protocol; what remained useful from the wiki has been
absorbed into doc/ β see
the protocol reference, performance,
USB notes, and troubleshooting.
(The former openkinect.org domain, which hosted the Kinect v1 wiki, has
lapsed and now serves unrelated ads β do not use it.)
Hacker News (1)
(top 30 of 45)
C++
78.2%
C
8.0%
Cuda
4.8%
CMake
3.7%
Objective-C++
1.7%
Metal
1.1%