Posts Tagged ‘Kinect’

The objective of this tutorial is –
1) To install OpenNI, Nite (drivers that help  getting data from the kinect) in Ubuntu 12.04.
2) To set up Processing and  SimpleOpenNI ( OpenNI and Nite wrapper for Processing  ) using which you can get started with Kinect coding.

What you need?

Kinect with usb cable and a computer with Ubuntu installed. It is not recommended to run Ubuntu as a wubi installer from Windows when working with Kinect. Better install Ubuntu  in a new partition and run it.

1) Installing OpenNI and NITE

1) I highly recommend installing 32 bit versions of all  even if yours is a 64 bit system.  Download OpenNI_Nite installer package from here. eg: I downloaded OpenNI_NITE_Installer-Linux32-0.27.zip . Now extract the zip file to a folder.

Tip:

Instead of navigating to different folders using cd command you can enable Open in terminal  option when you right click in any folder. To get that open terminal and type:

sudo apt-get install nautilus-open-terminal

After installing type : killall nautilus && nautilus in terminal to activate the change immediately.


2) Navigate to OpenNI-Bin-Dev-Linux-x86-v1.5.4.0 folder ( version could have changed if you are seeing at a later point in time) in the unzipped folder using terminal and type the following command  to install –

sudo ./install.sh
 
 
 

3) Navigate to NITE-Bin-Dev-Linux-x86-v1.5.2.21 folder ( version could have changed if you are seeing at a later point in time) in the unzipped folder and type the following command  to install –

sudo ./install.sh
 

4) Navigate to Kinect folder and then to Sensor-Bin-Linux-x86-v5.1.2.1 folder ( version could have changed if you are seeing at a later point in time) in the unzipped folder and type the following command  to install –

sudo ./install.sh
 
Testing the installation:

Connect the kinect and ensure that the green Led on it is blinking. Now, navigate to the unzipped folder OpenNI_NITE_Installer-Linux32-0.27. Then to OpenNI-Bin-Dev-Linux-x86-v1.5.4.0  -> Samples -> Bin -> x86-Release and  try out the following sample in the the terminal.

./NiViewer

The output with my Kinect:

2) Setting up Processing and SimpleOpenNI for Kinect coding

1)Download processing for Linux from here.

2) Install OpenJDK Java7 Runtime by searching it from Ubuntu Software center.

3) Download simpleOpenNI from here and extract it. I downloaded SimpleOpenNI-0.27.zip which works for all platforms.

4) Unzip the downloaded processing folder, navigate to it and run ./processing in terminal.

When started for the first time Processing asks where to place the sketchbook folder. I let it place in the default folder. It’s path in my computer is  /home/sanmarino/sketchbook

Create a folder named libraries inside Sketchbook folder and place the unzipped folder SimpleOpenNI from step3 inside it.

5) Restart processing again . Now you should be able to see SimpleOpenNI as shown under.

Now we are done with installation.

Running processing Demo

In the processing menu under File ->Examples-> SimpleOpenNI(scroll down to see) ->OpenNI you will find DepthImage. Double click on it to bring up the code. Make sure that the kinect is properly connected. Now run the code by pressing the run button (that is right below the File menu). You should be able to see the output.

Now if you want to systematically learn kinect coding using processing and SimpleOpenNI you can follow this book called Making things See. If you just want to try out few other  examples , the codes from the book are available here.

Feel free to comment if any of the steps are unclear and if you face any problem. I shall be glad to offer the help  I can.

Errors in my case:

error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory

Installing freeglut3 from Ubuntu software center fixed it.

It took me sometime to get the installation done so just thought of making a little tutorial that would help other folks. I am assuming that you have Microsoft kinect and the adapter ready with you .

Two competing frameworks to work with Kinect are Microsoft Kinect’s sdk and Prime Sense OpenNI sdk . But since the Microsoft’s sdk is only  for non commercial use, many developers love to use  OpenNI sdk.

In this tutorial we would be installing  OpenNI, SensorKinect and NITE. In simple terms OpenNI and SensorKinect are the drivers that help to access RGB-D data [Depth & Color]  from Kinect . NITE is a skeleton tracking library that can be used by developers to create gesture interactions etc. Hence if you just want to work with depth images and pointclouds you wouldn’t necessarily need to install NITE. So, technically it is optional but most of them install it as it doesn’t take much extra effort.

I have installed 32 bit versions of openNI, sensorKinect and NITE on my 64 bit windows7 laptop. I shall walk you through the steps that I had followed  to install OpenNI drivers successfully.

Step1: Go to http://www.openni.org/Downloads/OpenNIModules.aspx . Select unstable and select windows 32 version. Download and install it.

Step 2: Go to https://github.com/avin2/SensorKinect  , download the zip file and extract it.  Navigate to the Bin folder , find SensorKinect093-Bin-Win32-v5.1.2.1.msi  and install it. Sample path where  the above sensor kinect installation file would be located is C:\Users\Sanmarino\Downloads\avin2-SensorKinect-v0.93-5.1.2.1-0-g15f1975\avin2-SensorKinect-15f1975\Bin.

Step 3:  Go to http://www.openni.org/Downloads/OpenNIModules.aspx. Select openNI compliant middleware binaries, unstable , windows 32  version then download and  install it.

Step 4: Now replace the file SamplesConfig.xml in C:\Program Files (x86)\OpenNI\Data  with the SamplesConfig.xml that is present in avin2-SensorKinect-15f1975\OpenNI\Data folder that you downloaded in step2.

Here you may get “access denied” when you try to replace in  C:\Program Files (x86)\OpenNI\Data  folder. So right click on the Data folder present in C:\Program Files (x86)\OpenNI\  , then select properties –> select security tab –>click edit. Under “Group or user names” select “users(your-computer_name\Users)” , eg: “users(Sanmarino-THINK\Users)” in my case. Now under “Permissions for users” click to allow full control , then click apply and ok.  After this you can replace without any problem. See the picture below if you have any confusion.

Step5:  Download KinectXML’s.zip from https://www.dropbox.com/s/tpl9wtx96xbe6rr/KinectXMLs.zip  and navigate to the NITE folder inside the unzipped KinectXMLs folder. Copy the three files Sample-Scene,Sample-Tracking & Sample-user from the NITE  folder in KinectXMLS and replace the files in C:\Program Files (x86)\PrimeSense\NITE\Data  with these three files. If you encounter “access denied “ problem do the same procedure explained in the step4 to the Data folder inside NITE.

Now restart your system ,  plugin Kinect and wait for the drivers to be installed. Once the drivers are installed properly open device manager[Click windows icon and search for device manager]  in your system . You should be able to see Kinect Audio,Camera & Motor when you expand PrimeSense. If you are unable to see this then refer the Errors encountered section below.

Testing the installation:

 Try out some samples   to ensure that your installation is working perfectly. Double click on NiViewer in C:\Program Files (x86)\OpenNI\Samples\Bin\Release  to see the following output. Here is the output with my kinect –

Also try Sample-SceneAnalysis in C:\Program Files (x86)\PrimeSense\NITE\Samples\Bin\Release to see if the NITE installation is working properly. Here is the output with my kinect –

If everything is working properly then you are done with the installation. If you encountered errors refer to the  section below and see if it helps. Comment if you encounter any problems. I shall offer the help I can.

Errors Encountered:

1) The procedure entry point xnloggetfilename could not be located…..

2) Device: PrimeSense/SensorKinect/5.1.2.1: The device is not connected!

3) A blank screen appears and dissapears immediately when you try to run the samples in NITE or OpenNI.

In my case all the above errors have been caused because of the conflict between Microsoft driver and OpenNI driver.  When I first connected the Kinect to my laptop Microsoft driver has been automatically installed without my knowledge and it kept causing errors like the ones mentioned above. To remove,  open Device Manager  and find Microsoft Kinect. Expand it to find Microsoft Kinect camera , right click and choose uninstall. A windows pops out and  make sure you check the box Delete the driver software for this device so that the Microsoft Driver is not installed again the next time when you unplug and plug in kinect. Then click ok to uninstall. Now uninstall the existing openNI drivers and install them newly again(i.e, Start from Step1 again). The problem should be solved. The following image clarifies the steps mentioned.