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