FAQ

There's a seperate page for frequently asked questions now: FAQ

Quickstart

First you have to decide whether to use OpenNI oder Microsoft Kinect SDK. Depending on what you've installed you create a OpenNIDataSourceFactory or a SDKDataSourceFactory. They both implement the IDataSourceFactory interface.

OpenNI

To use OpenNI you can use this code snippet:
IDataSourceFactory dataSourceFactory = new OpenNIDataSourceFactory("config.xml");

A sample config xml is checked in and must specify at least one Image and one Depth Node.

Kinect SDK

To use the SDK you can use this code snippet:
IDataSourceFactory dataSourceFactory = new SDKDataSourceFactory();

How to create a hand data source

The minimal code to create a HandDataSource is this:
var handDataSource = new HandDataSource(dataSourceFactory.CreateShapeDataSource());

You can also pass in your own parameter objects:
var handDataSource = new HandDataSource(dataSourceFactory.CreateShapeDataSource(new ClusterDataSourceSettings(), new ShapeDataSourceSettings()), new HandDataSourceSettings());

To get notified when a new frame is available you can subscribe to the NewDataAvailable event. The last thing you'll have to do is to tell the data source to start.
handDataSource.NewDataAvailable += new NewDataHandler<HandCollection>(handDataSource_NewDataAvailable);
handDataSource.Start();

...
void handDataSource_NewDataAvailable(HandCollection data)
{
    for (int index = 0; index < data.Count; index++) 
    {
        var hand = data.Hands[index];
        Console.WriteLine(string.Format("Fingers on hand {0}: {1}", index, hand.FingerPointCount));
    }
}


Last edited Mar 12, 2012 at 8:09 PM by Candescent, version 7

Comments

Niharp Feb 1, 2013 at 3:56 PM 
I am working on this code for last 4 days....but i am not able to collect finger data....Actually i want to collect {x,y,z} cordinate finger movement while program is running...i want to provide that data to the micro controller.How can i do it?plz help me....thank u in advance

zcswin Sep 29, 2012 at 3:48 PM 
CCT.NUI16705 could be build but cannot runi still get an error saying "this does not support the latest version of the hardware." What am I missing here? Thanks for the help!

browniee Jul 18, 2012 at 4:42 PM 
Hey stefan,
you were right I had the kinect for xbox not kinect for windows. So the openNI worked for Kinect for XBOX. Thank you!

Maverickk Jun 6, 2012 at 12:01 PM 
Hi stefan,
Could u plz tell me the threshold calculation code for hand detection using depth data from kinect.

ArvindRaghuvanshi Jun 1, 2012 at 10:58 PM 
Hi Stefen,
I am using Kinect/XBox with OpenNI drivers on Win7-64 bit. After some struggle I was able to make it work. However, I am having troubles using Hand Tracking (NITE) module to track my hand. I have to put it in front of camera for a while. Initially nothings happens, but after a few flicks of hand, I start seeing it tracked. It works beautifully thereafter. Is there some trick to get rid of this initial and unpredictable delay (sometime close to a minute)
thanks,
-Arvind

natemac May 9, 2012 at 9:26 PM 
"Can't create any node of the required type" when I choose openni & openni+nite, using an xbox kinect.

Candescent Apr 18, 2012 at 1:07 PM 
browniee, I'm talking about the device. There's one for the xbox and one for windows (which is more expensive). Because the Kinect for xbox doesn't support the near mode I recommend OpenNI for this device.

browniee Apr 18, 2012 at 1:48 AM 
Hey, I have kinect for windows : http://www.microsoft.com/en-us/kinectforwindows/develop/overview.aspx That is what I have. Do you really recommend OpenNI?

Candescent Apr 17, 2012 at 10:16 AM 
Hi Askani

You could try to calculate the distance between the points BaseLeft and BaseRight on the FingerPoint object. These are not on the interface IFinger, so you have to iterate over handdata.FingerPoints instead of handdata.Fingers. Or you could work with the Contour of the HandData.

There's no built in functionality that will give you the finger thickness directly.

Candescent Apr 17, 2012 at 10:12 AM 
Hi browniee
Do you have a Kinect for Windows or a Kinect for XBOX? If it's the latter I recommend using OpenNI instead of the Kinect SDK.

Askani Apr 16, 2012 at 6:23 PM 
Thanks Stefan, I appreciate all your help :)
I'm able to pick out fingers and figure out which ones they are based on location now so that's great! :)
Thanks again :)
I would recommend adding this stuff to the documentation - your library is great to use and all the functionality would be great to have up there.
Is there any method for measuring width or other info on the fingers? Like, using the dots that are positioned either side of the finger and determining the width between?
Sorry for the avalanche of questions; I'll try to figure more out for myself lol

Thanks again,
Aaron

browniee Apr 16, 2012 at 5:06 PM 
Hi stefan,
I followed all your instructions properly and downloaded the latest version release of kinect sdk for windows (1.0.3) and CCT.NUI 14079 but i still get an error saying "this does not support the latest version of the hardware.' What am I missing here? Thanks for the help!

Candescent Apr 16, 2012 at 5:53 AM 
You can iterate over the fingers collection:
foreach(var finger in hand.Fingers)
{
//do something
}

Askani Apr 15, 2012 at 2:45 PM 
Thank you for the information Stefan :)

Which part of the hand data source gives the individual fingers collection? I can see "hand.Fingers" but cannot determine how to reference an individual instance... (I'm going to use x position to determine which finger is which).

Candescent Apr 15, 2012 at 12:15 PM 
Hi Askani

Unfortunately the library does not identify the fingers or hands. They do get IDs but they're only assigned in the order of appearance and are also reused.

Each finger has 3 coordinates x, y and z where z is the distance.

- Stefan

Askani Apr 12, 2012 at 3:32 PM 
Hi Stefan,
First off, thanks for the library; it is a godsend :)
I was just wondering; I can't see any documentation on reading individual fingers - as in, associating a finger with whether it is an index, thumb etc in order to determine if it is a right or a left hand. Is this possible? Also, how would I go about determining distance of a specific finger?

Sorry if these are a little rudimentary; just coming to grips with what your library can do :)

Thanks for any advice you can offer,
Aaron

Candescent Apr 12, 2012 at 5:39 AM 
Hi browniee

I've upgraded Candescent NUI to the Kinect SDK release version, it's not compatible with the BETA version anymore.

- Stefan

browniee Apr 11, 2012 at 9:46 PM 
I am currently using the Microsoft Kinect for Windows SDK BETA. I don't know if this makes a difference for 14079. Thanks!
browniee

browniee Apr 11, 2012 at 9:43 PM 
Hey Stefan,
Thanks for the previous reply on the comment! One more question. I just downloaded CCT.NUI.14079 but the CCT.NUI.samples does not seem to work on the Kinect SDK. I get an error. Why? I also have your CCT.NUI.9489 and the CCT.NUI.samples seems to work fine on Kinect SDK. Am I missing something? Thank you. I mean the older version works fine with Kinect SDK. I am not using OpenNI since I didnt download everything.

Candescent Apr 3, 2012 at 5:36 PM 
Hi fill32

I think I've fixed this in one of the most recent releases.

- Stefan

Candescent Apr 3, 2012 at 6:35 AM 
Hi fill32

I'll look into it.

- Stefan

fill32 Mar 16, 2012 at 3:29 PM 
Hi Stefan, I have problems when running the app CCT.NUI.TestDataCollector:
- I start the app, click Start Depth Source, I see the depth video frame indicates that everything is okay.
- But when I click Capture Frame or Capture Frame (delayed), a runtime exception is thrown:
+ file: WpdVideoControl.xaml.cs
+ line 67 (in the Show Image Source function).
+ exception: InvalidOperationException - Cannot perform this operation while dispatcher processing is suspended.
Plz check it and help me. Thank you! :)

Candescent Mar 12, 2012 at 3:36 PM 
Hi RomainB

Thanks!

You're right, the WPF sample currently only works with OpenNI. Since the Kinect for XBOX doesn't return values below 800mm the performance isn't that good anyway. I've ordered a Kinect for Windows today and will start to support the Near Mode soon. I'll also make the WPF samples work with it then.

- Stefan

RomainB Mar 9, 2012 at 9:55 AM 
Hi,

It seem that the WPFSample only work with OpenNI (I look in it because I wanted to use the WPF videoControl and it didn't work), I try to change the source with SDKDataSourceFactory but there is an exception with the buffer size in SDKDepthImageDataSource on the line :
this.CurrentValue = System.Windows.Media.Imaging.BitmapSource.Create(image.Width, image.Height, 96, 96, PixelFormats.Bgr32, null, data, image.Width * 4);
I try to change it with the sample gave by Microsoft (with the ConvertDepthFrame function) and it work but with very poor performance (it's not usable).
Did I do something wrong or it is not supported yet (and if so, do you planned on doing it)?

Beside this, i find your project excellent and wanted to say felicitation for this work.

Regards,
Romain

Candescent Mar 7, 2012 at 5:49 AM 
Hi fill32

You mean to find the contour? If I'm only doing it horizontally all horizontal lines would be missing. I'm doing it in parallel so it should be faster on multicore systems.

- Stefan

fill32 Feb 29, 2012 at 2:18 PM 
Plz let me know why do you use 2 scans: horizontal & vertical PARALLEL? Thanks.

Candescent Feb 14, 2012 at 7:09 PM 
Hi JYL
Sorry that I didn't answer earlier, I don't get notified for comments here. I've added the missing dll.
Regards
Stefan

JYL Feb 6, 2012 at 9:13 AM 
... for those who wants to compile the sources and the XnVNITE.net.dll is missing : you can download the latest binaries, and then copy the "XnVNITE.net.dll" file from the unzipped binaries to the following sources folder : Lib/OpenNI .

JYL Feb 6, 2012 at 9:05 AM 
Hi,
Your project seems to be great !
I'm trying to compile your solution, but an assembly is missing (referenced by CCT.NUI.Core) : \Lib\OpenNI\XnVNITE.net.dll (changeset 12689).
I just have the Kinect SDK 1.0 installed (I don't want to install for OpenNI the moment).
Regards,
JYL

Candescent Jan 23, 2012 at 7:04 PM 
Hi Johan

They guys at zigfu have created a bundle that contains everything:
http://zigfu.com/devtools.html

Regards,
Stefan

johanhazendonk Jan 23, 2012 at 3:00 PM 
Hello Stefan,
Can you write or refer to a good page where complete installation of the OPENNI incl drivers is explained. I can not seem to find this, or am I missing something. When I follow some explaining websites regarding this, only parts of the wpf samples work and it crashes regularly.

Thanks in advance, Johan

Candescent Jan 22, 2012 at 11:14 AM 
Hi browniee
You can have a look at the samples projects. I think that's the easiest way to find out how to plug the stuff together.
- Stefan

browniee Jan 19, 2012 at 6:57 PM 
I am a little confused as to where to put the 'how to create a hand data source' I want to get some data but I am new to Microsoft Visual studios.

Candescent Nov 10, 2011 at 11:22 AM 
Hi frankee

Sorry, I didn't see your question before. Please have a look at the new [FAQ] page.

Regards,
Stefan

frankee787 Oct 20, 2011 at 6:50 AM 
Hi there. Seems to work good for me. However, is there any limitation on the distance. It works only at a very specific distance. Something like 1 meter or so. I am using the Kinect SDK though.