OpenNI class and error handling
We will show how to create and initialize a context object in C++ and how to use the
openni::Status
datatype to handle errors thrown by OpenNI core. We will use openni::Status
very often in the later recipes and it is a very important part of any successful application.
In this recipe, we try to show the version number of the current OpenNI environment and then initialize the OpenNI framework. This will ask OpenNI to search for any connected device and load their modules and drivers.
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 in this chapter.
How to do it...
Have a look at the following steps:
Open your project and then the project's main source code file. Locate this line:
int _tmain(int argc, _TCHAR* argv[]) {
Write the following code snippet above the preceding line of code:
char ReadLastCharOfLine() { int newChar = 0; int lastChar; fflush(stdout); ...