Hello world in Kinect with processing

I hope everyone have configured processing and OpenNI. If not go to my first Blog post from here.


First I will processing code for getting depth image and I will explain line by line and properties of images



Copy this code and phase it on processing sketch                                                                          Now Run it  result is something like that below..


Now I will go through line by line so that you can understand the code

  • import SimpleOpenNI.*;

This import the SimpleOpenNI Library  to this program

  • SimpleOpenNI kinect;

This create a object form the SimpleOpenNI so that we can call method in side the SimpleOpenNI. If you are familiar with any of object oriented language like java. You can understand easily.

  • Then the basic structure of processing  processing has  two main method setup() and draw()

setup() will call single time when sketch is running

draw() method call as loop until kill the program

  • size(640*2,480);

this  inbuilt method create window of size 640*2 times 480 because incoming both two images have width and height of  640pix  and 480 pix

  • kinect = new SimpleOpenNI(this);

then initiate the  created object  using   new as in Java

  • then the next two line enable both depth image and the RGB color image so that it can access inside the draw() function


  • Then inside the draw function

kinect.update()  is called .it  update the data to the latest  when every time calls it

  • Then both latest Depth and latest RGB data loads to PImage Object using next two lines
  • then image(PImage,positionX,positionY) function draw the both depth and RGB image on the window using next two line.



Installing OpenNI in Ubuntu 14.04


Hello everyone,

Few month ago, I saw a video , doing cool staff using Kinect , like object tracking localization. So I bought a Kinect in eBay and start coding. Before going on to detail of coding it is really necessary to understand the physics behind the Kinect to get optimum use out of it.

What is a Kinect?

Kinect is a device which was originally build as plug-in device for XBOX gaming. it is use to acquire detail ,color, width, height and also the depth  in the range of 20inch to 20 feet approximately ,using a  inferred net projecting towards to the front object . of cause height ,width and color details are taken using the RGB camera mounted in it and the depth detail taken using Depth camera which is generating  depth values  for each pixel comparing the inferred net projected and reflected inferred net which has  defected due to the depth and curvature of the facing objects.

There are few iteration of Kinect sensor have made. But newer sensors are using different techniques to acquire the depth value. I used xbox360 1414 module (see the bottom of Kinect sensor) which has good compatibility with the OpenNI libraries, if you are purchasing now check before the compatibility of OpenNI or any other library that you planning to use, and also there is a module called xbox360 1413 which is a later iteration as I heard it has some issues with OpenNI library due to hardware change,better check it out.



I dig little bit deeper to the hardware level So I found this video on you-tube. Check it out if you are real like to know what is inside the casing.


USB power Adapter

Kinect come with its own USB power adapter because Kinect need considerable amount of power which cannot supply through the directly from USB connection. If you try without power adapter you  will probability get error message like,

No Kinect connected… or No Kinect connected

.Make sure that you have both component with you.

Power adapter has Y connection at the wire end. At one end there is male USB connector head and the other end has female head which is compatible with the Kinect out coming wire head. And also the little LED green indicator on the Y joint of the wire so that you can check the power Adapter and power supply.

Interfacing with computer

As I mention before Kinect was originally build and introduce for Xbox. After few times of release, programmer’s hackers realized that this device could use more than gaming , all kind 3D sensing  they couldn’t do before, still at that time there was no drivers compatible with computer . So OpenNI drivers were build  to fill the gap. Few years after windows introduce Kinect Studio for free use to the computer. You can use them also if you are using Windows. Kinect studio easily  interface with VB, I haven’t try that yet although I run example provided in Kinect studio.

You can download Kinect Studio latest version from here.



OpenNI is a one of most power full 3D vision base middleware free available in the Internet. Basically Until 2013,PrimeSense  company had developed open source libraries (OpenNI, NITE) for Kinect with amazing capabilities  but In 2013, Apple bought  PrimeSense and despite OpenNI is still open source, NITE2 is no more available for developers which is used for applications such as skeleton, hands, object, gesture tracking. Without NITE, just with libraries OpenNI1.5, you can just control utilities like depth view, LED light and camera motor.  But still the last versions of NITE is available in the Internet.

You can check about NITE   from below link.

Here on wards I will explain you to how to install OpenNI  and NITE into the the processing

  • Installing OpenNI and NITE
  • I highly recommend you to install 32bit version of the OpenNI although you are running on 64bit machine. Because I tried the 64 bit version but it didn’t work out for me. I tried to resolve the problem in various way but it path to nowhere. Also checked the issue on various forms the all suggest that use 32 bit version instead of 64 bit version.
  • First download OpenNI-NITE installer package from here and extract it. https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/simple-openni/OpenNI_NITE_Installer-Linux32-0.27.zip
  • Navigate to the extracted folder OpenNI-Bin-Dev-Linux-x86-vx.x.x.x then install it using  sudo  ./install.sh command as below. If you are using build command first time  it will probably crash and stop the installation. If so go to the error message. It will probably say messing command or library. First in install  particular library related to the  command run it again.



  • Then navigate to the NITE-Bin-Dev-Linux-x86-vx.x.x.x and install it using sudo ./install.sh


  • Finally Kinect folder and then to the Sensor-Bin-Linux-x86-vx.x.x.x and install it also using sudo ./install.sh


  • Now necessary library installation is over .
  • To check whether the installation is correct First plug in the Kinect to computer and plug in the power supply and then navigate into the OpenNI-Bin-Dev-Linux-x86-vx.x.x.x -> Samples -> Bin -> x86-Release run the example NiViewer using ./NiViewer command


If All steps are done correctly you will see window with depth image and the color image together as following. Also you can try other example also.



(2) Configure with processing

Processing is one of most powerful and simple open source language integrated development environment among visual design communities which can easily be used to analyze and process graphical data. Because it is free tons of free libraries are available for various visual task.

Also there are few library regarding Kinect data processing. In this tutorial what I trying to use is SimpleopenNI library which is actually so far very good. Unfortunately at this time SimpleopenNI does not support later release version of processing. But older version of processing works fine. I actually use processing 2.2.1 version for my project.

(I) You can download processing 2.2.1 from below link http://download.processing.org/processing-2.2.1-linux32.tgz

If you trying to use later version of processing check whether SimpleopenNI library is supporting for that.

(II) After downloading unzip the downloaded folder and navigate to the inside the folder and run  ./processing

Processing window will appear


(III)  Then goto Sketch > Import Library… >Add Library                                                                        then the below window will appear


(IV) Then search for SimpleOpenNI library


(Because of I already downloaded the library button is appear as Remove  in your case it will be install )

Click the button to install it then it will automatically download necessary files and  it will configure with your processing libraries.

(V) Now configuration is done.

Now test it.

  1. First plug in the Kinect to your computer also power supply to the Kinect.(now green light in front should blink)
  2. then open processing

Navigate to File > Examples… > SimpleOpenNI > DepthImage   (You can any of other example under SimpleOpenNI) and Run it

Following window with gray scale depth Image and the normal color image will appear


(3)  now ready to program your first Kinect project..