Example Code

Using the Kinect with LabVIEW and the Upgraded Microsoft .NET API

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Other

  • Microsoft Kinect

Code and Documents

Attachment

Description

There have been a few versions of Kinect wrappers for LabVIEW circulating since the original release of the Kinect. Many had advantages others did not (I, personally, wrote one of them), but none take advantage of the new upgrades to the Microsoft Kinect API (which actually broke some previous versions of the Kinect API). The library outlined here gives much of the basic functionality users are looking for when using the Kinect.

 

Features Include:

-Get information on any Kinect Devices attached to the computer.

-Connect to any of a number of Kinects attached to the computer.

-Get the Color Images from the Kinect in any of the supported formats.

-Get the Depth Images from the Kinect in any of the supported formats.

-Get the approximate location of a speaking user using the Kinect Audio API.

-Set the angle of elevation of the Kinect.

-Basic error handling.

 

Missing/Incomplete features:

-Get the RAW audio information from the Kinect Microphones

-Get the Skeletal frame from the Kinect (this feature was started, but is incomplete - completing the VI is left as an exercise to the user).

-Perform speech recognition automatically using the API.

 

The VIs are documented internally but are outlined breifly here. The example VI is provided which is also explained here.

 

This software requires NI Vision Acquistion Software (specifically NI IMAQ) which can be downloaded for free from ni.com/drivers.

 

This software was constructed in LabVIEW 2011 SP1 and requires the .NET 4.0 configuration file to have been set for LabVIEW (see this article on how to do that).

 

The example:

 

Kinect Example Front Panel.PNG

 

The front panel consists of a settings panel on the left which demos some basic features including the ability to select a specific Kinect, Color Image Format and Depth Image Format. The approximate location of the user based on the sound the produce is revealed on the bottom as well as the confidence and the beam angle. Unlike with previous iterations involving the .NET API, this package does not crash as a result of hitting the Abort button instead of the Stop button (as is recommended to avoid memory leaking).

 

Kinect Example Block Diagram.PNG

 

As we can see, the block diagram follows a very simple structure familiar to all of us. The first VI gets the information on the Kinects we have connected to the machine (this has only been tested with one Kinect as it's all I have). The second initializes a connection to the selected Kinect (typically Index 0) and selects the resolutions we want. The next three VIs perform some example movements of the Kinect's tilt motor. Notice the min and max range are populated in the Get Device Info.vi function.

 

The loop repeatedly gets the color frame, depth frame and audio information. The Dispose function stops all sensors and the Kinect and clears any internal errors we created (leaving only non-handled errors).

 

Note the delay we left in the loop. This prevents the color and depth frames from repeatedly throwing errors from being called too fast. You can tweak this speed to your preference, but if called too quickly, the Get functions will return non-fatal errors.

 

The disabled area within the block diagram is a short attempt to get the Skeletal Frame. It is not working and not tested, but provided as a starting point for those considering pulling this information.

 

The wrapper provides a session wire which can be called using a property node to get some basic information. These values cannot be written with a property node, but write functionality is included in the form of VIs which can be found in the Kinect Session class.

 

Remember you must install the Microsoft Kinect API in order for this package to work. Additionally, this has not been tested on a 64 bit machine. You may need to remap the DLL reference in order for this to work.

 

Happy Kinecting!

 

 

Install Instructions

___________________________________________________________

-Install LabVIEW 2011 SP1.

-Install Vision Acquistion Software (Specifically NI IMAQ - this is free).

-Install The Microsoft Kinect API (v1.0 - installer attached).

-Install .NET 4.0 and add the config file to the LabVIEW.exe directory.

-Load the Library and try the example.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
philip_c
Member
Member
on

Thank you very much. This was a great starting point.

cmurray71710
Member
Member
on

Hey SaeedMech,

I saw that you had a question on remapping the link to the dll.  I am having the same issue, how did you solve it?

Kevin_H.
NI Employee (retired)
on

You'll need to change the reference in the Constructor node. LabVIEW (if you have a relatively new version) should also prompt you to find the assembly if it can't find it.

aaa2205
Member
Member
on

hi, i want to detect color or object using this librery and get thier coordinate (x,y,z) helpp me

muhammad.kamran.ayub
Member
Member
on

Hi,

Have you implemented SLAM algorithm using LabVIEW and Kinect? If so, can you provide me assistance on this?

Thanks in advance