KinectBridgeWithOpenCVBasics D2D C++ Sample

Kinect for Windows 1.7, 1.8


  • You must have Visual Studio 2010 or Visual Studio 2012 installed. Express, Professional, Premium, or Ultimate versions can be used.
  • You must install the Kinect for Windows SDK, which is a free download.
To compile and run this sample, you must have OpenCV 2.4.X installed. To find out more about OpenCV see the OpenCV web page and look under Latest Downloads.


This sample demonstrates how to apply a Gaussian filter from the OpenCV library to color and depth data from the sensor.

The Sample Uses the Following APIsTo Do This
NuiImageResolutionToSize functionGet the width and height of the depth frame.
NuiGetSensorCount functionGet the number of sensors that are ready for use.
NuiCreateSensorByIndex function and INuiSensor interfaceCreate an interface that represents a connected sensor.
INuiSensor::NuiStatus methodCheck the sensor status to see if the sensor is connected.
INuiSensor::NuiInitialize method and NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX constantInitialize the sensor to stream out depth data.
INuiSensor::NuiImageStreamSetImageFrameFlags method and NUI_IMAGE_STREAM_FLAG_ENABLE_NEAR_MODE constantSet depth data range to near range.
CreateEvent functionCreate an event that will be signaled when depth data is available by returning an event handle.
INuiSensor::NuiImageStreamOpen method, NUI_IMAGE_TYPE_DEPTH constant, NUI_IMAGE_RESOLUTION_640x480 constant, the event handleOpen a depth stream to receive depth data.
INuiSensor::NuiImageStreamGetNextFrame methodGet the next frame of color data (using the color data event handle).
UpdateBitmap functionSave the color image in a bitmap for drawing.
INuiSensor::NuiImageStreamReleaseFrame methodRelease each frame of depth data after saving it.
INuiSensor::Release methodRelease the sensor when you exit the application.
NuiShutdown functionShut down the sensor.

KinectHelper is an abstract base class that holds functions to communicate with the Kinect runtime to get color and depth data, one frame at a time. OpenCVHelper is a concrete implementation of the KinectHelper class that implements functionality to apply Gaussian transforms to the Kinect data. These classes are only available in this sample and are not part of the Kinect for Windows SDK or Toolkit.

The Sample Uses the Following Additional Classes and MethodsTo Do This
KinectHelper::GetColorHandle method Get a handle to a color event.
KinectHelper::IsInitialized method Update color frame.
KinectHelper::UpdateColorFrame method Update color frame.
KinectHelper::UpdateSkeletonFrame method Update color frame.
KinectHelper::GetColorImage method Get color image.
KinectHelper::GetSkeletonFrame method Get color image.
OpenCVHelper::ApplyColorFilter method Apply filter using OpenCV.
OpenCVHelper::DrawSkeletonsInColorImage method Draw skeleton using OpenCV.
KinectHelper::UpdateDepthFrame method Update the frame of depth data.
KinectHelper::GetDepthImageAsArgb method Get the depth data formatted as ARGB.
OpenCVHelper::ApplyDepthFilter method Apply filter using OpenCV.
OpenCVHelper::DrawSkeletonsInDepthImage method Draw skeleton using OpenCV.

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.

In This Section

Community Additions