PacktLib: OpenNI Cookbook

OpenNI Cookbook


About the Author

About the Reviewers


Getting Started


Downloading and installing OpenNI

Downloading and installing NiTE

Downloading and installing the Microsoft Kinect SDK

Connecting Asus Xtion and PrimeSense sensors

Connecting Microsoft Kinect

OpenNI and C++


Creating a project in Visual Studio 2010

OpenNI class and error handling

Enumerating a list of connected devices

Accessing video streams (depth/IR/RGB) and configuring them

Retrieving a list of supported video modes for depth stream

Selecting a specific device for accessing depth stream

Listening to the device connect and disconnect events

Opening an already recorded file (ONI file) instead of a device

Using Low-level Data


Configuring Visual Studio 2010 to use OpenGL

Initializing and preparing OpenGL

Reading and showing a frame from the image sensor (color/IR)

Reading and showing a frame from the depth sensor

Controlling the player when opening a device from file

Recording streams to file (ONI file)

Event-based reading of data

More about Low-level Outputs


Cropping and mirroring frames right from the buffer

Syncing image and depth sensors to read new frames from both streams at the same time

Overlaying the depth frame over the image frame

Converting the depth unit to millimetre

Retrieving the color of the nearest point without depth over color registration

Enabling/disabling auto exposure and auto white balance

NiTE and User Tracking


Getting a list of all the active users

Identifying and coloring users' pixels in depth map

Reading users' bounding boxes and center of mass

Event-based reading of users' data

NiTE and Hand Tracking


Recognizing predefined hand gestures

Tracking hands

Finding the related user ID for each hand ID

Event-based reading of hands' data

Working sample for controlling the mouse by hand

NiTE and Skeleton Tracking


Detecting a user's pose

Getting a user's skeleton joints and displaying their position in the depth map

Designing a simple pong game using skeleton tracking