Book Image

Kinect for Windows SDK Programming Guide

By : Abhijit Jana
Book Image

Kinect for Windows SDK Programming Guide

By: Abhijit Jana

Overview of this book

Kinect has been a game-changer in the world of motion games and applications since its first release. It has been touted as a controller for Microsoft Xbox but is much more than that. The developer version of Kinect, Kinect for Windows SDK, provides developers with the tools to develop applications that run on Windows. You can use this to develop applications that make interaction with your computer hands-free. This book focuses on developing applications using the Kinect for Windows SDK. It is a complete end to end solution using different features of Kinect for Windows SDK with step by step guidance. The book will also help you develop motion sensitive and speech recognition enabled applications. You will also learn about building application using multiple Kinects.The book begins with explaining the different components of Kinect and then moves into to the setting up the device and getting thedevelopment environment ready. You will be surprised at how quickly the book takes you through the details of Kinect APIs. You will use NUI to use the Kinect for Natural Inputs like skeleton tracking, sensing, speech recognizing. You will capture different types of stream, and images, handle stream event, and capture frame. Kinect device contains a motorized tilt to control sensor angles, you will learn how to adjust it automatically. The last part of the book teaches you how to build application using multiple Kinects and discuss how Kinect can be used to integrate with other devices such as Windows Phone and microcontroller.
Table of Contents (19 chapters)
Kinect for Windows SDK Programming Guide
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Ever since its inception, Kinect has brought about a revolution in the field of NUI and hands-free gaming. There is no wonder that Kinect went on to shatter all records and become the fastest selling electronic device on earth. Although touted as a controller for Xbox console, Kinect applicability is beyond gaming domain and you can think of building applications for diverse domains such as health care, robotics, imaging, education, security, and so on. Thus we have the Kinect for Windows sensor, that enables applications to interacts with users via gestures and voice, and this opens up avenues that developers couldn't even have imagined before.

This book is mainly focussed on the Kinect for Windows SDK with which you can build applications that can leverage the power of the Kinect sensor. This book doesn't require any prior knowledge about the platform from the reader and its strength is the simplicity in which the concepts have been presented using code snippets, a step-by-step process, and detailed descriptions. This book covers:

  • A practical step-by-step tutorial to make learning easy for a beginner

  • A detailed discussion of all the APIs involved and the explanations of their usage in detail

  • Procedures for developing motion-sensing applications and also methods used to enable speech recognition

What this book covers

Chapter 1, Understanding the Kinect Device, introduces Kinect as a hardware device. You will get an insight into the different components that make up Kinect and the technology behind this device, which makes the components work together. This chapter will also give an overview of the difference between Kinect for Xbox and Kinect for Windows sensor. You will also become familiar with different possibilities of domain specific applications that can be developed using the Kinect sensor.

Chapter 2, Getting Started, introduces the Kinect for Windows SDK, its features, and how to start working with the Kinect sensor. In this chapter, you will get to know about the requirements for preparing your development environment. This will also walk you through a step-by-step guide for downloading and installing the SDK. You will delve into the installed components to verify that everything is set up properly. This chapter will also provide you with a quick lap around the different features of the Kinect for Windows SDK as well as introduce the Kinect for Windows Developer Toolkit.

Chapter 3, Starting to Build Kinect Applications, explains the step-by-step process of building your first Kinect-based application. You will understand how applications interact with the Kinect sensor using the SDK libraries. This chapter will give you an in-depth guide on how to start building Kinect applications using the Kinect for Windows SDK and Visual Studio. You will also learn how to deal with applications when there is any change in the device status.

Chapter 4, Getting the Most Out of Kinect Camera, covers the in-depth discussion of the Kinect color camera and how to use it. In this chapter, you will learn about the different types of image streams and different approaches to retrieve them from the Kinect sensor. You will get an understanding of Color camera stream pipeline and its events. You will also explore the different features of the Kinect for Windows SDK that control the color camera and process the color data. This chapter will give you an understanding of processing color images and applying different effects to the captured images and how to save the image frames. You will also learn how you can use the Kinect camera to capture images in low light.

Chapter 5, The Depth Data – Making Things Happen, explores the fundamentals of the Kinect depth sensors and how they produce depth information. This chapter describes how to work with object distances and player indices from the captured depth data. You will also learn about the capturing of data using the near mode and also get a quick view of generating 3D depth data.

Chapter 6, Human Skeleton Tracking, describes how a Kinect sensor tracks the human skeleton and how you can leverage the features of the Kinect for Windows SDK to play around with tracked skeletons and joints. You will also learn how to change the sensor elevation angle based on the player position. This chapter also explores how skeletons can be tracked in a seated mode. You also learn about details of the skeleton joints and bone hierarchy. The sample application in this chapter will help you to understand the APIs for skeleton tracking in better ways such as using Kinect as an intrusion detector. At the end of this chapter, you will be familiar with a few debugging tips and tricks to boost your development speed.

Chapter 7, Using Kinect's Microphone Array, introduces the microphone array that captures and processes the audio signal. You will learn why Kinect uses an array of microphones rather than a single microphone. In this chapter you will get an insight into the Kinect audio processing pipeline that helps Kinect to capture good-quality audio signals and makes Kinect a highly directional audio device. This chapter provides you with information on how to capture and record audio signals using the Kinect microphone array and process the audio data for better quality. You will also learn about different concepts such as Noise Suppression, Automatic Gain Control, Echo Cancellation, and Beam forming.

Chapter 8, Speech Recognition, introduces the building of speech-enabled applications using Kinect. You will explore how speech recognition works and how Kinect's microphone array helps Kinect to recognize human speech. This chapter also shows how you can use Kinect as the default speech recognition device for your PC. You will also learn about the Microsoft Speech API and how it is integrated with Kinect for Windows SDK, which helps us to build speech-enabled applications.

Chapter 9, Building Gesture-controlled Applications, describes how to build applications that can be controlled by human gestures. You will learn different approaches for recognizing gestures and how to apply these approaches in the form of programs to build motion-sensing applications using the Kinect sensor. This chapter will also help you understand how to build some gestured-enabled controls.

Chapter 10, Developing Applications Using Multiple Kinects, explains how multiple Kinect sensors can be placed together and used to build applications. This chapter describes how to set up environments for developing applications using multiple Kinects and walks you through building applications by reading data from multiple devices. You also learn how multiple Kinects work together and different scenarios where multiple Kinects can be used, along with the challenges while developing applications using multiple devices.

Chapter 11, Putting Things Together, introduces us to more advanced developments using Kinect by integrating it with other devices such as Windows Phone, microcontrollers, and so on. This chapter addresses how we can take things up from Kinect to Windows Azure and control the Kinect sensor using Windows Phone via Windows Azure. You will also learn how Kinect can be integrated with the Netduino microcontroller and how you can use a Kinect device for face tracking.

What you need for this book

The basic requirements for this book are as follows:

  • Microsoft Visual Studio 2010 Express or higher editions of Visual Studio

  • Microsoft .NET Framework 4.0 or higher

  • Kinect for Windows Sensor or Kinect for Xbox Sensor

  • Kinect for Windows SDK

Please refer Chapter 02, Getting Started , for detailed information on installation of SDK and the development environment setup.

Who this book is for

The purpose of this book is to explain how to develop applications using the Kinect for Windows SDK. If you are a beginner and looking to start developing applications using the Kinect for Windows SDK, and if you want to build motion-sensing, speech-recognizing applications with Kinect, this book is for you.

This book uses C# and WPF (Windows Presentation Foundation) in the examples, so you need to know the basics of C# and WPF. You should be familiar with the Visual Studio IDE as well. You don't have to know anything about the Kinect for Windows SDK.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Each Kinect device represents an instance of the Microsoft.Kinect.KinectSensor class."

A block of code is set as follows:

public sealed class KinectSensorCollection : ReadOnlyCollection<KinectSensor>
{
     public KinectSensor this[string instanceId] { get; }
 
     public event EventHandler<StatusChangedEventArgs> StatusChanged;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public partial class MainWindow : Window
{

     KinectSensor sensor;
     // remaining code goes here  
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Move to the Listen tab and select the Listen to this device checkbox and click on Apply".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.