Kinect with OpenNI 2 is a set of two Kinect/PrimeSense examples that use several major scripts, grouped in one folder. It demonstrates how to use Kinect-controlled avatars or utilize Kinect gestures in your Unity projects, by using OpenNI2 and NiTE2. This asset supports 32- and 64-bit builds, works on Windows and (with some kicks and curses) also on MacOS X and can be used in both Unity Pro and Unity Personal editors.
How to Run the Example:
1. Download and install OpenNI 2 and NiTE 2, as explained below.
2. Download import the package.
3. Open and run KinectAvatarsDemo-scene, located in KinectDemos/AvatarsDemo-folder.
4. Open and run KinectGesturesDemo-scene, located in KinectDemos/GesturesDemo-folder.
How to Install OpenNI2 and NiTE2 on Windows:
1. Download and install OpenNI 2 and NiTE2. The OpenNI-website was closed by Apple, when they bought PrimeSense, but here is a working download link: https://bitbucket.org/kaorun55/openni-2.2/src/
2. Drivers for Kinect and PrimeSense sensors are installed during the OpenNI/NiTE installations.
3. If you’re using Kinect-for-Xbox360 sensor, install the Kinect SDK 1.8 as well. Here is the download link: http://www.microsoft.com/en-us/download/details.aspx?id=40278
4. Connect the Kinect or PrimeSense sensor to a USB port of your computer.
5. Windows should find and use the installed drivers automatically. You can see the installed sensor in the ‘Control Panel / Device Manager’ window.
How to Install OpenNI2 and NiTE2 on MacOS X:
1. Download and unpack OpenNI2 and NiTE2 tarballs in /Library-folder. The OpenNI-website was closed by Apple, when they bought PrimeSense, but here is a working download link: https://bitbucket.org/kaorun55/openni-2.2/src/
2. (Optional for v1.3) Open or create ‘
/etc/launchd.conf‘-text file and set the needed environment variables. Add these lines: ‘
setenv OPENNI2_REDIST /Library/OpenNI-MacOSX-x64-2.2/Redist‘ and ‘
setenv NITE2_REDIST /Library/NiTE-MacOSX-x64-2.2/Redist‘. Then restart your Mac.
3. Install Homebrew, as described here.
4. Install libfreenect, like this: ‘
brew install libfreenect‘. More information you can find here.
5. Copy the OpenNI2-Kinect driver ‘
/usr/local/lib/OpenNI2-FreenectDriver/libFreenectDriver.dylib‘ to ‘
6. Open Terminal and run ‘
freenect-glview‘. If the installation so far is correct, it should show the depth and color camera stream. Press Esc to close the application.
If you get errors when running the Unity project on MacOS X:
First off, check if the native OpenNI2/NiTE2 examples work. If they don’t, you missed something in previous section ‘How to install OpenNI2 and NiTE2 on MacOS X’. If the native examples work, do the following:
1. Go to the root folder of the Unity-project (the one that contains Assets-folder). There must be a text file named ‘OpenNI.ini’.
2. Open it with a text editor and modify these lines: ‘Verbosity=0’ and ‘LogToFile=1’.
3. Save and close the ini-file.
4. Open the Unity project and run the example scene. You will get the same error again. Close the scene.
5. Go to the root folder of the Unity-project again. You will have a Log-folder in there and a log-file in it. Take a look at its contents. It will give you detailed information what exactly went wrong.
6. If the Unity editor crashes when you run a demo scene, open the editor log-file located at ~/Library/Logs/Unity/Editor.log. Look for ‘Crash’. The log-messages below it will give you information what may have caused the crash.
7. Last, but not least: I published the source of UnityInterface2-library. Here it is, if you like to go deeper and torture yourself further 🙂 – https://github.com/rfilkov/OpenNi2UnityInterface
The official release of ‘Kinect with OpenNI 2’-package is available in the Unity Asset Store.
The project’s BitBucket-repository is located here. This repository is private and the access is limited to contributors only.
* If you get DllNotFoundException, make sure you have installed OpenNI2, NITE2 and the sensor driver.
* For MacOS X installation, see the ‘How to Install OpenNI2 and NiTE2 on MacOS X’-section above.
* Here is a link to the project’s forum: http://forum.unity3d.com/threads/218035-Kinect-PS-with-OpenNI-2
What”s New in Version 1.3:
1. Added x64 native Unity interface for Windows.
2. Added x64 native Unity interface for Mac (you can see it mirrored, because of the freenect driver).
3. Added calibration poses for player 1 and player 2.
4. Moved Kinect-related classes to KinectController-game objects.
5. Moved demo scenes to KinectDemos-folder.