Setting Kinect Sensor with Matlab

This blog is intended to help users setup Matlab environment to work with Microsoft Kinect sensor which is has RGB-D Camera, 4 Array Microphone, Tilt motors etc. We have tested the procedure with Kinect for Windows type hardware in our lab and use Matlab 2012a version.

Matlab kinectfront-lg

Install Microsoft Visual Studio 2010(Express Edition)  on to your computer.from this link by choosing all in one ISO option.

After installing Visual Studio open Matlab. First of all mex compiler should be setup in Matlab using the following command.

 mex -setup
// choose Visual Studio 2010 compiler from the options.

After setting the compiler options user may need to restart Matlab environment.

Install OpenNI-NITE ver 0.27 from here. User have to choose between 32 and 64 bit versions depending upon the Operating System used. For example for Windows 64-bit OS select OpenNI_NITE_Installer-win64-0.27.zip.

download_openni

Install openni-win64-1.5.4.0-dev.msi, nite-win64-1.5.2.21-dev.msi, and finally primesense driver for kinect sensor SensorKinect092-Bin-Win64-v5.1.2.1.msi to the default directory. User may also need C++ distributable sensor-win64-5.1.2.1-redist.msi which located in the same directory to be installed.

Now connect the Kinect Sensor to your USB port. Make sure Kinect’s power adapter is pluged in.

Note : User need to remove Kinect for Windows driver which comes with Kinect-SDK if previously installed.

Device entry should look like this.

kinect_driver

Download  zip-file containing c++ wrapper functions for the Microsoft Kinect, OpenNI 1.* from Mathworks website. Extract it and open Matlab and choose current directory as <your path to>\Kinect_Matlab_version2\OpenNI1.

mathcentral_kinect

Tip: Make sure compile_cpp_files.m is in your current folder in Matlab window along with Mex folder.

Next we  need to compile the binaries using Mex compiler and OpenNI Library. For this type the following command in the command window

 compile_cpp_files('C:\Progra~1\OpenNI\')

The Mex compiler will start compiling the binaries for you. After successful compilation open “Example.m

comment the following lines by adding % before it.

% filename='Example/SkelShort.oni';
% KinectHandles=mxNiCreateContext(SAMPLE_XML_PATH,filename);

 

and uncomment the line by removing % before it

KinectHandles=mxNiCreateContext(SAMPLE_XML_PATH);

 

The code displays the RGB and Depth map images on the screen.

matlab_kinect

 

Run the code and enjoy the brilliance of Kinect Sensor!!!!

 

Advertisements

5 thoughts on “Setting Kinect Sensor with Matlab

  1. hello, I’ve done all what you said but when I run the code this error shows:
    One or more of the following nodes could not be enumerated:

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

    what should I do?thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s