Event-based reading of users' data
You don't need to call nite::UserTracker::readFrame()
and wait for it to return each time you want to read a frame of data from nite::UserTracker
. This is because NiTE developers give us this ability to define a callback (also known as event listener) when a new frame becomes available, just as openni::VideoStream
does. In this recipe, we are going to cover this feature and rewrite the first recipe of this chapter, this time based on events.
Getting ready
Create a project in Visual Studio and prepare it for working with OpenNI and NiTE using the Create a project in Visual Studio 2010 recipe in Chapter 2, OpenNI and C++.
How to do it...
Add the
ReadLastCharOfLine()
function from previous recipes to the top of your source code (just below#include
lines).Then add the
HandleStatus()
function from the previous recipe, right after theReadLastCharOfLine()
function.Add these lines after the definition of the
HandleStatus()
function:struct uTrackerNewFrameListener...