Coordinate Mapping Basics-D2D C++ Sample
Kinect for Windows 1.5, 1.6, 1.7, 1.8
Note
Before Kinect for Windows SDK 1.8, this sample was named Green Screen-D2D C++ Sample.
Overview
When you run this sample, you see the following:
- A background image.
- If you move in front of the camera, your body is rendered over the background image. This is done using the depth data to choose the pixel color.
- Click Near Mode to change the range of the depth data.
The Sample Uses the Following APIs | To Do This |
---|---|
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_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX and NUI_INITIALIZE_FLAG_USES_COLOR constants | Initialize the sensor to stream out depth and color data. |
CreateEvent function | Create an event that will be signaled when color data is available by returning an event handle. |
INuiSensor::NuiImageStreamOpen method, NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX constant, NUI_IMAGE_RESOLUTION_320x240 constant, and the event handle | Open a depth stream to receive depth data. |
INuiSensor::NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution method | Get the pixel coordinates in color space that correspond to the specified pixel coordinates in depth space to compensate for the differences between the depth and color cameras. |
INuiSensor::NuiImageStreamGetNextFrame method | Open a stream (with the event just created) for storing color data from the sensor. |
INuiSensor::NuiImageStreamReleaseFrame method | Release each frame of data after saving it. |
INuiSensor::Release method | Release the sensor when you exit the application. |
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.