This service contains libraries for both the server and client.  The distribution includes several samples that demonstrate how to use the server libraries from a console application and a Windows service, and how to use the client libraries from WPF and Windows Phone applications.  This project will continue to be updated as we fix bugs and add new features.


On the server, there are 4 listeners.  These listeners handle managing the underlying socket connection, while also sending color (ColorListener), depth (DepthListener), skeleton (SkeletonListener), and audio data (AudioListener).  You can pick and choose the listeners you need for your application.  For example, if you only wish to stream Color data, you only need to instantiate and use the ColorListener.

To use, simply reference the Coding4Fun.KinectService.Listeners and Coding4Fun.KinectService.Common assemblies in your "server" or "host" project.  Once the assemblies are referenced, you can start that listener to accept client connections on any port you choose.  For this sample code, we use ports 4530-4533.  Note that the ColorListener takes a parameter in its constructor to determine what type of data it sends to the client:  JPEG images (lossy), PNG images (non-lossy), or the raw image data.  Please be aware that raw image frames are over 1 megabyte in size, and at 30 frames per second, you will be transferring more than 30 megabytes per second.  That's a lot of data to keep up with, so ensure your network and client device can handle those speeds.  The ColorListener constructor can also take parameters to resize the resulting image (JPEG and PNG only), and both the ColorListener and DepthListener take a parameter to limit the number of frames delivered per second.

KinectSensor kinect = KinectSensor.KinectSensors[0];


ColorListener colorListener = new ColorListener(kinect, 4530, ImageFormat.Jpeg);

DepthListener depthListener = new DepthListener(kinect, 4531);

SkeletonListener skeletonListener = new SkeletonListener(kinect, 4532);

AudioListener audioListener = new AudioListener(kinect, 4533);

When the application host exists, call the Stop method on any listeners to properly close them.

if(depthListener != null)

if(colorListener != null)

if(skeletonListener != null)

if(audioListener != null)

If you are using the Windows Phone client (see below), you will likely need to resize the color image, and lower the framerate to something the phone can keep up with.  If this isn't done, the phone will not be able to keep up, and the server will start to consume a great deal of memory as frames queue up in the socket.

There are two sample hosts included in the package: a console host, and a Windows Service host.  Please take a look at these examples, and feel free to use them as starting points for your own needs.


On the client side, two libraries are included to connect and receive data from the above listeners: a WPF client, and a Windows Phone client.  These clients will allow you to connect to the listeners and receive data.

To start, reference either the Coding4Fun.KinectService.WpfClient, Coding4Fun.KinectService.PhoneClient or Coding4Fun.KinectService.WinRTClient assembly, and the appropriate Coding4Fun.KinectService.Common assembly for (WPF and Phone only!), depending on your project type.

There are 4 clients which are used to connect to the 4 listeners: ColorClient, DepthClient, SkeletonClient, and AudioClient.  To use these clients, hook the *FrameReady event, and then call the Connect method, specifying the IP address and port on which the listener is listening.  All the data you should need to handle the event is passed through the *EventArgs parameter, depending on the stream type.  Here is an example using the ColorClient object:


private void WindowLoaded(object sender, RoutedEventArgs e)
    ColorClient colorClient = new ColorClient();

    colorClient.ColorFrameReady += clientColorFrameReady;
    colorClient.Connect(ServerAddress, 4530);

void clientColorFrameReady(object sender, ColorFrameReadyEventArgs e)
    // Video is a WPF or Windows Phone Image control
    Video.Source = e.ColorFrame.BitmapImage;

Also note that each client object has a property that contains the same data that is sent through the event handler.  You can use these properties for a polling scenario, such as in an Update loop in an XNA project.


That's it!  Data will stream from your server to your client to be handled by you as your application requires.

Last edited Dec 11, 2012 at 3:49 AM by peekb, version 22


Auxon Aug 5, 2012 at 6:50 PM 
Thanks! I'll probably use this.