A simple drawing app using Kinect, C#, and XAML.
This short demo project will show you the following:
- How to track a hand using Kinect version 2.
- How to display the camera stream.
- How to draw the trail of the hand on top of a XAML canvas.
- Kinect for Windows v2 sensor or Kinect for XBOX sensor with an adapter
- Kinect for Windows SDK v2
- Visual Studio 2013 or higher
Simply download the project and hit "Start" using Visual Studio. This project is a showcase demo.
<Image Name="camera" />
<Canvas Name="canvas">
<Polyline Name="trail" Stroke="Red" StrokeThickness="15" />
</Canvas>
Joint handRight = body.Joints[JointType.HandRight];
if (handRight.TrackingState != TrackingState.NotTracked)
{
CameraSpacePoint handRightPosition = handRight.Position;
ColorSpacePoint handRightPoint = _sensor.CoordinateMapper.MapCameraPointToColorSpace(handRightPosition);
float x = handRightPoint.X;
float y = handRightPoint.Y;
if (!float.IsInfinity(x) && ! float.IsInfinity(y))
{
// DRAW!
trail.Points.Add(new Point { X = x, Y = y });
}
}
- Vangos Pterneas from LightBuzz - Microsoft Kinect MVP
You are free to use this source code in personal and commercial projects. Licensed under the MIT License.