Hacking the Xbox 360 Kinect for the CIRCUIT Studio Fritz Barnewolt Steven Boehm Jacob Frederick
Outline The information contained in this manual is limited to the basic functions and operations of the Kinect. The manual begins with an Initial Setup section. This section contains the code that needs to be written in Processing before the Kinect can be hacked. Following this section are actual pieces of code that are required for simple functions of the Kinect. There is also a general trouble shooting section and a section that explains how to access sample code that is already in the Processing library. The information presented here will focus on using the SimpleOpenNI library for hacking the Kinect. First-Time Installation 1. Plug in the Xbox 360 Kinect to an open USB port as well as a wall socket 2. Allow Microsoft to search for and download any necessary drivers (a notification in the system tray allows you to monitor this) 3. Download the 64 or 32 bit Processing for Windows (https://processing.org/download/?processing) 4. Open the program Processing 5. In the top menu go to Sketch Import Library Add Library
6. Search kinect, locate SimpleOpenNI and select the install button (this could take up to five minutes) Introductory Functions Initial Set-Up Required for Every Program: Open a new Processing file. The following code needs to be included at the beginning of every Processing file. The code can vary depending on what library you are importing, but we will be using the SimpleOpenNI library so type: import SimpleOpenNI.*; SimpleOpenNI context; This code imports the SimpleOpenNI library and makes an instance of a new SimpleOpenNI object, called context.
Executing a Processing File: A file is executed by clicking the Run button shown in figure below. A file will also be executed by using the shortcut, Ctrl + R. Sample Code The following sections will have segments of code that will perform specific functions. These segments can be pasted directly into your Processing file as needed. Please note that the segments of code are not complete Processing files, meaning that they will not execute
correctly on their own. In order to make these segments work indepently, you need to include the code from the Initial Set-Up Required for Every Program section. Simple Use As a Webcam/Setup for RGB camera: Most uses of the Kinect will require it to have the camera activated. It is a good idea to include the following code in every processing file. You will be able to build off of this code to perform more advanced functions on the Kinect. void setup( ) size(1600,600); context = new SimpleOpenNI(this); context.setmirror(true); context.enablergb(); } //This setup method is what turns on the Kinect and allows us to view the RGB camera void draw( ) context.update(); background(200,0,0); image(context.rgbimage(),0, 0); } //This draw method actually creates the viewing window to watch the Kinect s camera //and refreshes the RGB image Depth Map: This code will display the depth map and as well as enable the camera. void setup() context = new SimpleOpenNI(this); // enable depthmap generation context.enabledepth();
// enable camera image generation context.enablergb(); background(200,0,0); size(context.depthwidth() + context.rgbwidth() + 10, context.rgbheight()); } void draw() // update the cam context.update(); // draw depthimagemap image(context.depthimage(),0,0); // draw camera image(context.rgbimage(),context.depthwidth() + 10,0); } Adjust Camera Angle: float deg = 15; context.tilt(deg); //Tilts the Kinect s camera to whatever angle deg is set to up to a max of 30 degrees //This code goes in the setup method Accessing Sample Code The Kinect already has several sample programs loaded in the Simple OpenNI library. These samples are an easy way to perform simple functions on the Kinect. The sample code can be accessed using the following steps: Go to the processing window File Examples Contributed Libraries SimpleOpenNI OpenNI choose one of the many sample programs provided.
Basic Troubleshooting Issues If the computer does not recognize the Kinect, make sure that the Kinect s power and USB cords are plugged in. This manual was written for XBOX 360 Kinects, NOT Windows Kinects. The Windows Kinect is set up differently and might not be compatible with all of the information in this manual. If an error message appears that mentions compatibility issues with the 64 bit version of Processing, uninstall the 64 bit version on your computer and install the 32 bit version. If you cannot find the explicit instructions for what you need to do in this manual, refer to the Accessing Sample Code section. SimpleOpneNI is an open source language. As a result there are lots of resources on the internet that you can easily access. The following are a couple of good resources to start with: o http://channel9.msdn.com/coding4fun/kinect http://www.kinecthacks.com/ https://github.com/openkinect/libfreenect