Updated for Kinect for Windows SDK v1.7!

This project requires the Kinect for Windows SDK.  If you want to learn how to use the Kinect for Windows SDK, head over to the Channel 9 and their quick start series. This toolkit contains both a WinForm and WPF version.

If there is a bug [report], a needed control/feature that could benefit everyone [chat], or you want to help out [email], please reach out to us!

Toolkit Download:

codeplexCurrentRelease 
codeplexSourceCode

NuGet Installs:

nugetKinectWpf 
Install-Package
Coding4Fun.Kinect.Wpf
nugetKinectWinform
Install-Package
Coding4Fun.Kinect.WinForm

Current Coding4Fun Kinect Toolkit:

WPF:

Depth Data Extension Methods:

  • ImageFrame.ToBitmapSource()
    • returns BitmapSource
  • int[].ToBitmapSource()
    • returns BitmapSource
  • int[].ToBitmapSource(int width, int height, int minimumDistance, Color highlightColor)
    • returns BitmapSource
  • ImageFrame.ToDepthArray()
    • returns int[]
  • int[].GetMidpoint(int startX, int startY, int endX, int endY, int minimumDistance)
    • returns Point
  • BitmapSource.Save(string fileName, ImageFormat format)
    • returns nothing

Skeleton Data Extension Methods:

  • Joint.ScaleTo(int width, int height)
    • Scales a Joint's Position to the maximum width and height specified
  • Joint.ScaleTo(int width, int height, float maxSkeletonX, float maxSkeletonY)
    • Scales a Joint's Position to the maximum width and height specified

Controls:

  • Hover Button

WinForm:

Depth Data Extension Methods:

  • ImageFrame.ToBitmap()
    • returns Bitmap
  • int[].ToBitmap()
    • returns Bitmap
  • int[].ToBitmap(int width, int height, int minimumDistance, Color highlightColor)
    • returns Bitmap
  • ImageFrame.ToDepthArray()
    • returns int[]
  • int[].GetMidpoint(int startX, int startY, int endX, int endY, int minimumDistance)
    • returns Point
  • Bitmap.Save(string fileName, ImageFormat format)
    • returns nothing

Skeleton Data Extension Methods:

  • Joint.ScaleTo(int width, int height)
    • Scales a Joint's Position to the maximum width and height specified
  • Joint.ScaleTo(int width, int height, float maxSkeletonX, float maxSkeletonY)
    • Scales a Joint's Position to the maximum width and height specified

Sample usage:

void sensor_ColorFrameReady(AllFramesReadyEventArgs e)
{
	using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
	{
		if (colorFrame == null)
		{
			return; 
		}

		//set image
		ColorImage.Source = colorFrame.ToBitmapSource(); 

		if (_saveColorFrame)
		{
			//save image

			colorFrame.ToBitmapSource().Save(DateTime.Now.ToString("yyyyMMddHHmmss") + "_color.jpg", ImageFormat.Jpeg);
		}
	}            
}

void sensor_DepthFrameReady(AllFramesReadyEventArgs e)
{
	using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
	{
		if (depthFrame == null)
		{
			return; 
		}

		//turn raw data into an array of distances; 
		var depthArray = depthFrame.ToDepthArray();

		MidPointDistanceViaGetDistanceText.Text = depthFrame.GetDistance(depthFrame.Width/2, depthFrame.Height/2).ToString();

		//image
		DepthImageWithMinDistance.Source = depthArray.ToBitmapSource(depthFrame.Width, depthFrame.Height,
																	_minDistance, Colors.Red);

		//image
		DepthImage.Source = depthFrame.ToBitmapSource();

		if (_saveDepthFrame)
		{
			_saveDepthFrame = false;
			depthFrame.ToBitmapSource().Save(DateTime.Now.ToString("yyyyMMddHHmmss") + "_depth.jpg", ImageFormat.Jpeg);
		}
	}
}

Screenshots:

testApp

People, Credit, and Thanks:

Clint Rutkas, Brian Peek, and Dan Fernandez

Coding4FunProject_2

Last edited Sep 5, 2013 at 7:57 PM by crutkas, version 32