Event-based reading of data
In OpenNI 2.x, instead of using openni::OpenNI::waitForAnyStream()
, we can use the openni::VideoStream
object's events for reading new frames of data. This is a more standard way than creating an infinite loop around code. In this recipe, we will try to capture this event but we are not actually going to use it in any way. Read the older recipes about how to show and read a frame from sensors.
Getting ready
Create a project in Visual Studio 2010 and prepare it for working with OpenNI using the Creating a project in Visual Studio 2010 recipe of Chapter 2, Open NI and C++.We don't need OpenGL in this recipe.
How to do it...
Add the following lines above your source code (just below the
#include
lines):char ReadLastCharOfLine() { int newChar = 0; int lastChar; fflush(stdout); do { lastChar = newChar; newChar = getchar(); } while ((newChar != '\n') && (newChar != EOF)); return (char)lastChar; } bool HandleStatus(Status status) {...