Install
We have to install following software to use Kinect with processing.- OpenNI : The library for using Kinect
- NITE : The library for recognizing gesture and etc.
- SensorKinect : device driver
- Simple-OpneNI : The library to use Kinect with processing
https://code.google.com/p/simple-openni/downloads/list
- Download OpenNI_NITE_Installer-xxx-0.27.zip
- After unpack the zip file, install openNI with double clicking openni-xxx-1.5.4.0-dev.msi
- Install NITE with double clicking nite-xxx-1.5.2.21-dev.msi
- Install device driver with double clicking SensorKinect092-Bin-xxx-v5.1.2.1.msi
- Download SimpleOpenNI-0.27.zip and unpack it
- Copy the got folder to libraries under processing’s root folder
Let’s try a little bit interesting sample
Let’s write program for detecting user and paint it.The program’s result is like following.import SimpleOpenNI.*; SimpleOpenNI context; color[] userColors = { color(255,0,0), color(0,255,0), color(0,0,255), color(255,255,0), color(255, 0, 255), color(0, 255, 255) }; void setup() { context = new SimpleOpenNI(this); context.setMirror(false); context.enableDepth(); context.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL); size(context.depthWidth(), context.depthHeight()); } void draw() { context.update(); image(context.depthImage(), 0, 0); int[] userMap = null; int userCount = context.getNumberOfUsers(); if (userCount > 0) { userMap = context.getUsersPixels(SimpleOpenNI.USERS_ALL); } loadPixels(); for (int y=0; y<context.depthHeight(); y++) { for (int x=0; x<context.depthWidth(); x++) { int index = x + y * context.depthWidth(); if (userMap != null && userMap[index] > 0) { int colorIndex = userMap[index] % userColors.length; pixels[index] = userColors[colorIndex]; } } } updatePixels(); }
Similar program is written by following book.