Share via


Depth with Color-D3D C++ Sample

Kinect for Windows 1.5, 1.6, 1.7, 1.8

Overview

When you run this sample, you see the following:

  • The depth data is captured and displayed; this is a continually streaming grayscale image of the distance between the sensor and whatever the Kinect is pointed at. The camera can see pixels inside of the interaction space, which are colored shades of gray or white; pixels that are outside of the interaction space are colored black.
The Sample Uses the Following APIs To Do This
NuiImageResolutionToSize function Use this two times to get the width and height of the depth frame and to get the width and height of the color frame.
NuiGetSensorCount function Get the number of sensors that are ready for use.
NuiCreateSensorByIndex function and INuiSensor interface Create an interface that represents a connected sensor.
INuiSensor::NuiStatus method Check the sensor status to see if the sensor is connected.
INuiSensor::NuiInitialize method and NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX and NUI_INITIALIZE_FLAG_USES_COLOR constants Initialize the sensor to stream out depth and color data.
INuiSensor::NuiImageStreamSetImageFrameFlags method and NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE constant Set depth data range to near range.
CreateEvent function Create two events, one for depth data and one for color data. Each event will be signaled when new data (depth or color) is available by returning an event handle.
INuiSensor::NuiImageStreamOpen method, NUI_IMAGE_TYPE_DEPTH constant, NUI_IMAGE_RESOLUTION_640x480 constant, and the event handle Open a depth stream to receive depth data.
INuiSensor::NuiImageStreamOpen method, NUI_IMAGE_TYPE_COLOR constant, NUI_IMAGE_RESOLUTION_640x480 constant, and the event handle Open a color stream to receive color data.
INuiSensor::NuiImageStreamGetNextFrame method and the depth data event handle Get the next frame of depth data (using the depth data event handle).
INuiSensor::NuiImageStreamGetNextFrame method and the color data event handle Get the next frame of color data (using the depth data event handle).
INuiFrameTexture::LockRect method and NUI_LOCKED_RECT structure Lock the texture to prepare for saving texture data.
INuiFrameTexture::UnlockRect method Unlock the texture after saving the texture data.
INuiSensor::NuiImageStreamReleaseFrame method Use this twice to release each frame of data (depth and color) after saving it.
INuiSensor::Release method Release the sensor when you exit the application.
NuiShutdown function Shut down the sensor.

To run a sample you must have the Kinect for Windows SDK installed. To compile a sample, you must have the developer toolkit installed. The latest SDK and developer toolkit are available on the developer download page. If you need help installing the toolkit, look on this page: To Install the SDK and Toolkit. The toolkit includes a sample browser, which you can use to launch a sample or download it to your machine. To open the sample browser, click Start > All Programs > Kinect for Windows SDK [version number] > Developer Toolkit Browser.

If you need help loading a sample in Visual Studio or using Visual Studio to compile, run, or debug, see Opening, Building, and Running Samples in Visual Studio.