Updated for Kinect for Windows SDK v1.0!
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!
NuGet Installs:
Install-Package
Coding4Fun.Kinect.Wpf
Install-Package
Coding4Fun.Kinect.WinForm
Current Coding4Fun Kinect Toolkit:
WPF:
Depth Data Extension Methods:
- ImageFrame.ToBitmapSource()
- int[].ToBitmapSource()
- int[].ToBitmapSource(int width, int height, int minimumDistance, Color highlightColor)
- ImageFrame.ToDepthArray()
- int[].GetMidpoint(int startX, int startY, int endX, int endY, int minimumDistance)
- BitmapSource.Save(string fileName, ImageFormat format)
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:
|
WinForm:
Depth Data Extension Methods:
- ImageFrame.ToBitmap()
- int[].ToBitmap()
- int[].ToBitmap(int width, int height, int minimumDistance, Color highlightColor)
- ImageFrame.ToDepthArray()
- int[].GetMidpoint(int startX, int startY, int endX, int endY, int minimumDistance)
- Bitmap.Save(string fileName, ImageFormat format)
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:

People, Credit, and Thanks:
Clint Rutkas, Brian Peek, and Dan Fernandez
