IntroductionPlaying Kinect games is a really great experience. Programming for Kinect is even greater!Browsing the web, you can find many cool "hacks" (CLNUI, OpenKinect) which allow Kinectbe used by a PC rather than an XBOX. Via these hacks, we gain access to Kinects cameras(color and depth), LED, accelerometer and motor. Obtaining both the raw and the depth image, itis easier to build Machine Vision applications. But the main problem remains: Kinect magic is itssoftware and the device simply cannot give us all those body-tracking algorithms by itself.Fortunately, PrimeSense, the company behind Kinect, released OpenNI framework and NITEmiddleware. This means that we can now have access to features such as real-time skeletontracking, gesture recognition, wave detection and much more!OpenNI and NITE installation can be painful if not done properly. Lets do it step by step:Step 0Uninstall any previews drivers, such as CLNUI. Look at the end of this post if you want to seehow you can have multiple drivers installed.
Step 1Download and install the latest stable or unstable OpenNI Binaries from OpenNI website.Step 2 Download Kinect Drivers and unzip . Run the precompiled SensorKinect-Win-OpenSource32-5.0.1.exe file from the“……..avin2-SensorKinect-28738dcBin” DirectoryDrivers are now installed in your PC.Step 3Download and install the latest stable or unstable OpenNI Compliant Middleware Binaries(NITE) from OpenNI website.During installation, provide the following (free) PrimeSense key:0KOIk2JeIBYClPWVnMoRKn5cdY4=
Step 5 Plug in your Kinect device and connect its USB port with your PC. Wait until the driver software is found and applied. Navigate to the Device Manager (Control Panel). You should see something like the following:Step 6Copy the XML files from "avin2-SensorKinect-28738dcOpenNIData"into "c:ProgramFilesOpenNI Data" (overwrite files)
Step 7Navigate to C:Program FilesOpenNISamplesBinRelease (or C:Program Files(x86)OpenNISamplesBinRelease) and try out the existing demo applications. Try the demosfound in C:Program FilesPrime SenseNITESamplesBinRelease (or C:Program Files(x86)Prime SenseNITESamplesBinRelease), too. If they work properly, then you are done!Congratulations!Test #1: Run the NiViewer sample to make sure depth & image streams areworking.Test #2: Run the OpenNI/NiUserTracker sample play with the skeleton. Dontforget to start with the calibration pose! (Explained in the PDFs)Test #3: Try the NITE/Sample-PointViewer sample for the hand tracking demo.If they do not work, make sure that you have replaced the XML files I mentioned in step 5 withthe ones I provided you. If the demos still do not work, try installing the stable version ofOpenNI, middleware and hardware binaries. Personally, I have successfully installed OpenNIand NITE (both stable and unstable releases) in a 32-bit desktop and a 64-bit laptop followingthe methodology I described.Step 8You have successfully installed Kinect in your Windows PC! Read the documentation andfamiliarize yourself with the OpenNI and NITE API.
Visual Studio UserMake sure you set the path for compilation,go to Control PanelSystem and SecuritySystem->Advance system settings-> “advanced”tab-> Environment Variablesunder variable for “users” select “NEW…” 1. Variable name :OPEN_NI_INCLUDE Variable value : C:Program Files (x86)OpenNIInclude 2. Variable name :OPEN_NI_LIB Variable value :C:Program Files (x86)OpenNILib 3. Variable name :PRIME_SENSOR_INCLUDE Variable value :C:Program Files (x86)Prime SenseNITEInclude 4. Variable name :PRIME_SENSOR_LIB Variable value :C:Program Files (x86)Prime SenseNITELIBUnder system variable find “Path” click “edit..”Make sure you have added the path under your Variable value ( this is my computer which 64-bits, 32-bits users path might different)C:Program FilesOpenNIbin64;C:Program FilesPrimeSenseNITEbin64;C:Program Files (x86)OpenNIbin;C:Program Files (x86)PrimeSenseNITEbin;Creating an empty project that uses OpenNIin Visual Studio1. Open a new project or an existing one with which you want to use OpenNI.2. In the Visual Studio menu, open the Project menu and choose Project properties.3. In the C/C++ section, under the General node, select =>Additional Include Directories andadd "$(OPEN_NI_INCLUDE)". This is an environment variable that points to the location of theOpenNIInclude directory. (The default location is: C:Program filesOpenNIInclude.)4. In the Linker section, under the General node, select Additional Library Directories and add"$(OPEN_NI_LIB)". This is an environment variable that points to the location of the OpenNIinclude directory. (The default location is: C:Program filesOpenNILib.)5. In the Linker section, under the Input node, select Additional Dependencies and addOpenNI.lib.6. If you wish to use an XML file to configure OpenNI, you can start from the basic XML filethat can be found in the OpenNI Data folder. (The default location is: C:ProgramfilesOpenNIData.) For further information about OpenNI xml scripts, see Xml Scripts.7. Ensure that you add the Additional Include and Library directories to both your Release andDebug configurations.
8. Your code files should include XnOpenNI.h if using the C interface, or XnCppWrapper.h ifusing the C++ interface.Installing Multiple DriversHeres how to achieve this: Open Device Manager Right click Kinect Camera under PrimeSensor. Select "Update driver software" Select "Browse my computer for driver software" and "Let me pick from a list of device drivers on my computer". Select the driver of your preference (e.g. CLNUI). You are done!