Friday, May 13, 2011

Quick Start

I've added a small quick start documentation to the CodePlex page:


First of all you need to create an OpenNIFacade. This object is used to interact with the OpenNI Framework (

var facade = new OpenNIFacade("config.xml");

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

How to create a cluster data source

The next step is to create a cluster data source. But first you need an DepthDataSource (actually an IDepthPointerDataSource, because it returns only the pointer to where the depth data is located in memory).

var depthDataSource = new DepthPointerDataSource(facade.GetDepthGenerator());

With this data source you can create the cluster data source:

var clusterDataSource = new ClusterDataSource(depthDataSource);

This code will use the default setting values. You can also pass in your own settings object:

var clusterDataSource = new ClusterDataSource(depthDataSource,
    new ClusterDataSourceSettings());

To get notified after new data is available, you can register the NewDataAvailable event:

clusterDataSource.NewDataAvailable +=
    new NewDataHandler<ClusterData>(clusterDataSource_NewDataAvailable);


void clusterDataSource_NewDataAvailable(ClusterData data)
    for(int index = 0;index < data.Count;index++) 
        var cluster = data.Clusters[index];
        Console.WriteLine(string.Format("Cluster {0}: {1} / {2}",
            index, cluster.X, cluster.Y));

How to create a hand data source

To create a hand data source you first need an IClusterDataSource (see previous chapter).

var clusterDataSource = ...

var handDataSource = new HandDataSource(clusterDataSource);
handDataSource.NewDataAvailable +=
    new NewDataHandler<HandCollection>(handDataSource_NewDataAvailable);

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));


  1. This is outdated, please read the page directly:

  2. When I tried to create an application using the codes as supplied by you on , Cluster data was empty. I even started the clusterDataSource by using clusterDataSource.Start() but still then Cluster data was empty. Any Suggestions?

  3. Hi Anonymous

    Yes, calling Start() is necessary.

    Have you tried to run the sample projects?

    The Cluster data will be empty if there is nothing in the depth range that is clustered (500mm - 800mm per default).

    Are you using OpenNI oder the Kinect SDK? Kinect SDK does not return any data below 850mm so the default range setting has to be changed to 850mm - 1000mm for example.


  4. Hi Stefan,

    I am using KinectSDK for application. I have tried with varying distances but still was unable to make it work. Yes i had ran your sample projects. Needless to say, the best one in finger point tracking. Thank you.

  5. I could have a look at the code if you send me a zip file with what you have so far to, if that's possible.