/ofxKinect

openFrameworks wrapper for the xbox kinect

Primary LanguageCMIT LicenseMIT

ofxKinect

Copyright (c) 2010, 2011 ofxKinect Team

MIT License.

For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "LICENSE.txt," in this distribution.

See https://github.com/ofTheo/ofxKinect for documentation as well as the OF forums.

This project uses libfreenect, copyrighted by the Open Kinect Project using the Apache License v2. See the file "APACHE20" in libs/libfreenect.

Description

ofxKinect is an Open Frameworks addon for the Xbox Kinect that runs on Linux and OS X. OpenFrameworks is a cross platform open source toolkit for creative coding in C++.

http://www.openframeworks.cc/

Installation

To use ofxKinect, first you need to download and install Open Frameworks.

To get a copy of the repository you can download the source from http://github.com/ofTheo/ofxKinect or, alternatively, you can use git clone:

git clone git://github.com/ofTheo/ofxKinect.git

The addon should sit in openFrameworks/addons/ofxKinect/.

Which version to use?

If you are using a stable version (0062, 007, ...) of OpenFrameworks then you want to use a git tag of ofxKinect for that version. You can select the tag in the Github menu or clone and check it out using git.

For example, the following commands will clone ofxKinect and switch to the OF 0062 tagged version:

git clone git://github.com/ofTheo/ofxKinect.git
cd ofxKinect
git checkout 0062

Using the latest ofxKinect

The master branch of ofxKinect will work with the current master of OpenFrameworks and can be considered unstable. The develop branch is used for testing new features and bugfixes before they are applied to master.

If you want to work with the latest unstable (still in development) ofxKinect, download the source from the develop branch https://github.com/ofTheo/ofxKinect/tree/develop or via git clone:

git clone git://github.com/ofTheo/ofxKinect.git -b develop

Warning: The develop branch will be in flux, so don't be suprised if things do not always work as expected!

Running the Example Project

The example projects are in the example folder.

OSX

Xcode3: Open the Xcode project and hit "Build and Run". You might want to choose "Release" instead of "Debug" for faster performance.

Xcode4: Open the Xcode project, select the "ofxKinectExample" scheme, and hit "Run".

Linux

Install the libusb-1.0 library. On Ubuntu, you can do this with:

sudo apt-get install libusb1.0-0-dev

Open the Code::Blocks .cbp and hit F9 to build. Optionally, you can build the example with the Makefile.

To run it, use the terminal:

make
cd bin
./example_debug

Also, you should create some udev rules in order to run the app without root privileges. As the root user, write this to /etc/udev/rules.d/51-kinect.rules (this works on Ubuntu 10.10):

SUBSYSTEM=="usb", SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02ae", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02ad", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02b0", MODE="0660", GROUP="plugdev"

Windows

Precompiled libfreenect Kinect drivers and an example Visual Studio 2010 solution as well as a Codeblocks workspace are included.

Make sure to install or update the libfreenect Kinect camera, motor, and audio drivers through Windows Device Manager by pointing it to the driver folder:

libs/libusb/win/inf

You may need to manually update each driver individually if you've plugged it in before. ofxKinect will not work if the drivers are not installed.

How to Create a New ofxKinect Project

To develop your own project based on ofxKinect, simply copy the example project and rename it. You probably want to put it in your apps folder, for example, after copying:

openFrameworks/addons/ofxKinect/example/ => openFrameworks/apps/myApps/example/

Then after renaming:

openFrameworks/apps/myApps/myKinectProject/

Mac (Xcode):

Rename the project in Xcode (do not rename the .xcodeproj file in Finder!): XCode Menu->Project->Rename (Xcode3) / Slow double click the project name and rename (Xcode4)

Codeblocks (Win & Linux):

Close Codeblocks and rename the *.cbp and *.workspace files to the same name as the project folder. Open the workspace and readd the renamed project file.

Windows (Visual Studio):

Close Visual Studio and rename the *.sln file. Open the solution, right click on the project in the project broswer and select "Rename ...".

Adding ofxKinect to an Existing Project

If you want to add ofxKinect to another project, you need to make sure you include the src folder and the :

openFrameworks/addons/ofxKinect/src

as well as search paths for the addons (ofxOpenCv) and libs (freenect, libusb) required by ofxKinect.

Don't forget to include the ofxOpenCv addon sources and oepncv libraries.

Mac (Xcode):

In the Xcode project browser:

  • add the ofxKinect sources to the project:
    • create a new group "ofxKinect"
    • drag these directories from ofxKinect into this new group: ofxKinect/src & ofxKinect/libs
  • add a search path to the libusb headers: ../../../addons/ofxKinect/libs/libusb/include/libusb-1.0 to your project Target build settings
    • Xcode3: under Targets->YourApp->Build->Header Search Paths (make sure All Configurations and All Settings are selected) and add the path
    • Xcode4: add the lib path to your Project.xconfig, see the example
  • add the path to the libusb precompiled library: ../../../addons/ofxKinect/libs/libusb/osx/libs/usb-1.0.a
    • Xcode3: under Targets->YourApp->Build->Library Search Paths (make sure All Configurations and All Settings are selected) and add the path
    • Xcode4: add the lib path to your Project.xconfig, see the example

Linux (Makefiles & Codeblocks):

Edit the Makefile config files:

  • edit addons.make in your project folder and add the following line to the end of the file:
    ofxKinect
  • edit config.make in your project folder and change the lines for USER_LIBS to:
      USER_LIBS = -lusb-1.0
      

Windows (VS & Codeblocks)

Add the project search paths

For libusb & freenect, link to the precompiled freenect library in:

../../../addons/ofxKinect/libs/libfreenect/lib/vs2010/freenect.lib

Windows (Visual Studio):

  • add the ofxPd sources to the project:
    • right click on the addons folder in your project tree and create a new filter named "ofxKinect"
    • drag the src directory from the ofxKinect addon folder in Explorer into the ofxKinect folder in your project tree
  • add header and library search paths:
    • right lick on your project and select "Properties"
    • choose "Debug" from the "Configurations" drop down box
    • under C/C++->General, add the following to the "Additional Include Directories":
      ..\\..\\..\addons\ofxKinect\src
      ..\\..\\..\addons\ofxPd\libs\libsfreenect
      
    • under Linker->General, add the following to the "Additional Library Directories":
      ..\..\..\addons\ofxKinect\libs\libfreenect\lib\vs2010
      
    • repeat for the "Release" configuration

Windows (Codeblocks):

  • add the ofxPd sources to the project:
    • right-click on your project in the project tree
    • select "Add Files Recursively ..."
    • navigate and choose the ofxKinect/src folder
  • add search paths and libraries to link:
    • right-click on your project in the project tree
    • select "Build options..."
    • make sure the project name is selected in the tree (not release or debug)
    • select the "Search diectories" tab, click add the search paths:
      ..\\..\\..\addons\ofxKinect\src
      ..\\..\\..\addons\ofxPd\libs\libsfreenect
      
    • select the "Linker settings" tab, add the following to Link libraries:
      m
      pthread
      
    • select the "Linker settings" tab, add the following to Other liker options:
      ../../../addons/ofxKinect/libs/libfreenect/lib/vs2010/freenect.lib
      

Notes

Using multiple kinects

ofxKinect supports multiple kinects, however stability is based on the bandwidth of your usb hardware. If you only require the depth image, it is recommended to disable the video grabbing of the rgb/ir images from your devices:

kinect.init(false, false);  // disable video image (faster fps)

Developing ofxKinect

Feel free to log bug reports and issues to the ofxKinect Github page: https://github.com/ofTheo/ofxKinect/issues

If you wish to help in ofxKinect dvelopment, please refer to the wiki: https://github.com/ofTheo/ofxKinect/wiki/Developing-ofxKinect