Convert Figma logo to code with AI

OpenKinect logolibfreenect

Drivers and libraries for the Xbox Kinect device on Windows, Linux, and OS X

3,561
1,146
3,561
142

Top Related Projects

Intel® RealSense™ SDK

A cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.

1,360

OpenNI

Quick Overview

Libfreenect is an open-source library that provides drivers and APIs for the Microsoft Kinect and Kinect for Xbox 360 devices. It allows developers to access and control Kinect sensors, including RGB and depth cameras, motor, accelerometer, and LED, on various platforms such as Linux, macOS, and Windows.

Pros

  • Cross-platform compatibility (Linux, macOS, Windows)
  • Supports both C and Python programming languages
  • Active community and ongoing development
  • Low-level access to Kinect hardware features

Cons

  • Limited to first-generation Kinect devices (not compatible with Kinect v2 or Azure Kinect)
  • May require additional setup and dependencies compared to official SDKs
  • Documentation could be more comprehensive
  • Performance may vary depending on the system and configuration

Code Examples

  1. Initializing and accessing the Kinect device:
freenect_context *f_ctx;
freenect_device *f_dev;

freenect_init(&f_ctx, NULL);
freenect_open_device(f_ctx, &f_dev, 0);
  1. Capturing RGB and depth data:
freenect_set_video_callback(f_dev, video_cb);
freenect_set_depth_callback(f_dev, depth_cb);

freenect_start_video(f_dev);
freenect_start_depth(f_dev);
  1. Controlling the Kinect motor:
freenect_set_tilt_degs(f_dev, angle);
freenect_update_tilt_state(f_dev);
  1. Accessing accelerometer data:
freenect_update_tilt_state(f_dev);
freenect_raw_tilt_state* state = freenect_get_tilt_state(f_dev);
double dx, dy, dz;
freenect_get_mks_accel(state, &dx, &dy, &dz);

Getting Started

  1. Install dependencies:

    sudo apt-get install libfreenect-dev
    
  2. Clone the repository:

    git clone https://github.com/OpenKinect/libfreenect.git
    
  3. Build the library:

    cd libfreenect
    mkdir build && cd build
    cmake ..
    make
    
  4. Run an example:

    ./bin/freenect-glview
    

For more detailed instructions and examples, refer to the project's documentation and example files in the repository.

Competitor Comparisons

Intel® RealSense™ SDK

Pros of librealsense

  • Supports a wider range of Intel RealSense devices
  • More actively maintained with frequent updates
  • Comprehensive documentation and examples

Cons of librealsense

  • Limited to Intel RealSense devices only
  • Larger codebase and potentially more complex to use
  • May have higher system requirements

Code Comparison

libfreenect example:

freenect_context *f_ctx;
freenect_device *f_dev;
freenect_init(&f_ctx, NULL);
freenect_open_device(f_ctx, &f_dev, 0);
freenect_start_depth(f_dev);

librealsense example:

rs2::pipeline pipe;
rs2::config cfg;
cfg.enable_stream(RS2_STREAM_DEPTH);
pipe.start(cfg);
auto frames = pipe.wait_for_frames();
auto depth = frames.get_depth_frame();

Both libraries provide APIs for accessing depth data from their respective devices. libfreenect focuses on simplicity with a C API, while librealsense offers a more feature-rich C++ interface with additional configuration options and stream types.

A cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.

Pros of Azure-Kinect-Sensor-SDK

  • More comprehensive and up-to-date documentation
  • Better integration with Azure cloud services
  • Supports newer Kinect hardware with improved depth sensing capabilities

Cons of Azure-Kinect-Sensor-SDK

  • Limited to Windows and Linux platforms
  • Requires more powerful hardware to run effectively
  • Less community-driven development compared to libfreenect

Code Comparison

Azure-Kinect-Sensor-SDK:

k4a_device_t device = NULL;
k4a_device_open(K4A_DEVICE_DEFAULT, &device);
k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
k4a_device_start_cameras(device, &config);

libfreenect:

freenect_context *f_ctx;
freenect_device *f_dev;
freenect_init(&f_ctx, NULL);
freenect_open_device(f_ctx, &f_dev, 0);
freenect_set_video_mode(f_dev, freenect_find_video_mode(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB));

Both SDKs provide similar functionality for initializing and configuring the Kinect device. Azure-Kinect-Sensor-SDK offers more modern and flexible configuration options, while libfreenect has a simpler API that may be easier for beginners to use.

1,360

OpenNI

Pros of OpenNI

  • Broader device support, including multiple depth sensors and manufacturers
  • More comprehensive SDK with higher-level features like skeleton tracking
  • Better cross-platform compatibility, including mobile devices

Cons of OpenNI

  • More complex setup and configuration process
  • Larger codebase and potentially steeper learning curve
  • Less active community support and development (project is no longer maintained)

Code Comparison

OpenNI example (initializing and reading depth data):

#include <OpenNI.h>

openni::Device device;
openni::VideoStream depthStream;
device.open(openni::ANY_DEVICE);
depthStream.create(device, openni::SENSOR_DEPTH);
depthStream.start();

libfreenect example (initializing and reading depth data):

#include <libfreenect.h>

freenect_context *f_ctx;
freenect_device *f_dev;
freenect_init(&f_ctx, NULL);
freenect_open_device(f_ctx, &f_dev, 0);
freenect_start_depth(f_dev);

Both libraries provide similar functionality for accessing depth data from Kinect devices, but OpenNI offers a more abstracted and feature-rich API, while libfreenect provides a simpler, more direct interface to the hardware. OpenNI's broader device support and additional features come at the cost of increased complexity, while libfreenect focuses on simplicity and ease of use specifically for Kinect devices.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

libfreenect

libfreenect is a userspace driver for the Microsoft Kinect. It runs on Linux, OSX, and Windows and supports

  • RGB and Depth Images
  • Motors
  • Accelerometer
  • LED
  • Audio

Notice: If you have the newer Kinect v2 (XBox One), use OpenKinect/libfreenect2 instead.

Build Instructions

To build libfreenect, you'll need

  • libusb >= 1.0.18 (Windows needs >= 1.0.22)
  • CMake >= 3.12.4
  • python >= 2.7 or >= 3.3 (only if BUILD_PYTHON=ON or BUILD_PYTHON2=ON or BUILD_PYTHON3=ON or BUILD_REDIST_PACKAGE=OFF)

For the examples, you'll need

  • OpenGL (included with OSX)
  • glut (included with OSX)
  • pthreads-win32 (Windows)

Fetch & Build

git clone https://github.com/OpenKinect/libfreenect
cd libfreenect
mkdir build
cd build
cmake -L .. # -L lists all the project options
make

# if you don't have `make` or don't want color output
# cmake --build .

Use CMake options to control what gets built. For example, to build the Python wrapper (defaults to system Python):

cmake .. -DBUILD_PYTHON=ON
make

Or the Python 3 wrapper:

cmake .. -DBUILD_PYTHON3=ON
make

You can specify a build with debug symbols:

cmake .. -DCMAKE_BUILD_TYPE=debug
# or with optimizations
# cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo

You can build .deb, .rpm, and/or .tgz packages with cpack:

cmake .. -DBUILD_CPACK_DEB=ON -DBUILD_CPACK_RPM=ON -DBUILD_CPACK_TGZ=ON
cpack

For audio support, you must upload firmware to the device. Newer Kinect models may require audio firmware for motor and LED support. The best method is to insert firmware at runtime just after calling freenect_init().

Alternately, firmware for Kinect model 1414 can be downloaded automatically by specifying:

cmake .. -DBUILD_REDIST_PACKAGE=OFF

Note that firmware may not be legal to redistribute in your jurisdiction!

OSX

If you don't have a package manager, install Homebrew. For a manual build, see the wiki.

Homebrew

brew install libfreenect
# or get the very latest:
# brew install --HEAD libfreenect

MacPorts

sudo port install git-core cmake libusb libtool

Continue with Fetch & Build.

Linux

Remember to install the udev rules. For a manual build, see the wiki.

Ubuntu/Debian/Mint

The version packaged in Ubuntu may be very old. To install newer packaged builds, see the wiki. Continue with this section for a manual build.

sudo apt-get install git cmake build-essential libusb-1.0-0-dev

# only if you are building the examples:
sudo apt-get install freeglut3-dev libxmu-dev libxi-dev

Continue with Fetch & Build.

There is also a debian branch for packaging purposes.

Gentoo Linux

There are dev-libs/libfreenect ebuilds in the overboard repo.

Arch Linux

There is a libfreenect PKGBUILD in the AUR. Alternately, the libfreenect-git PKGBUILD builds the very latest.

Windows

As of libusb 1.0.22, libusbK isochronous transfers are now supported natively. There is no longer a need to compile a custom version of libusb.

Use Zadig to install the libusbK driver for each device you wish to use. Follow Fetch & Build or use Github and CMake GUI tools. Remember to supply paths to CMake so it can find dependencies. For example:

cmake .. -DLIBUSB_1_INCLUDE_DIR="C:\path\to\libusb\include" -DLIBUSB_1_LIBRARY="C:\path\to\libusb\libusb.lib"

Wrappers

Interfaces to various languages are provided in wrappers/. Wrappers are not guaranteed to be API stable or up to date.

  • C (using a synchronous API)
  • C++
  • C#
  • python
  • ruby
  • actionscript
  • Java (JNA)

Fakenect

Using fakenect, you can record a session to a directory and play it back later.

mkdir session
fakenect-record ./session

To use a fakenect recorded stream, just provide the fakenect lib as a pre loaded library with LD_PRELOAD and indicates the recorded files directory with FAKENECT_PATH.

  • Sample with python wrappers :
    LD_PRELOAD="/usr/local/lib/fakenect/libfakenect.so" FAKENECT_PATH="./session" python ./wrappers/python/demo_cv_sync.py
  • Sample with C bin :
    LD_PRELOAD="/usr/local/lib/fakenect/libfakenect.so" FAKENECT_PATH="./session" freenect-glview

Code Contributions

In order of importance:

  • Make sure to sign commits: git commit -s
  • Use a feature branch in your own fork and target master with pull requests
  • Tab indentation, no trailing whitespace

Maintainers

Ongoing Development and Maintenance by the OpenKinect Community

http://www.openkinect.org

  • Original Code and Engineering: Hector Martin (marcan)
  • Community Lead: Josh Blake (JoshB)
  • Integration: Kyle Machulis (qDot)

License

The libfreenect project is covered under a dual Apache v2/GPL v2 license. The licensing criteria are listed below, as well as at the top of each source file in the repo.

This file is part of the OpenKinect Project. http://www.openkinect.org

Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB
file for details.

This code is licensed to you under the terms of the Apache License,
version 2.0, or, at your option, the terms of the GNU General Public
License, version 2.0. See the APACHE20 and GPL2 files for the text of
the licenses, or the following URLs:
http://www.apache.org/licenses/LICENSE-2.0
http://www.gnu.org/licenses/gpl-2.0.txt

If you redistribute this file in source form, modified or unmodified,
you may:

- Leave this header intact and distribute it under the same terms,
  accompanying it with the APACHE20 and GPL2 files, or
- Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
- Delete the GPL v2 clause and accompany it with the APACHE20 file

In all cases you must keep the copyright notice intact and include a
copy of the CONTRIB file.

Binary distributions must follow the binary distribution requirements
of either License.

More Information

Information about the OpenKinect project can be found at http://www.openkinect.org

For questions, support, and discussion, check out the google groups mailing list at http://groups.google.com/group/openkinect

Or the IRC channel at #openkinect on Freenode

We are also on twitter at http://twitter.com/openkinect