Enumerating a list of connected devices
We learned how to initialize OpenNI and how to retrieve the version number of OpenNI using the openni::OpenNI::getVersion()
method and how to ask OpenNI to read all modules and drivers by calling openni::OpenNI::initialize()
in the last recipe. In this recipe we will get the list of all the connected devices, their hardware Uri (location), and product ID (that can be used to identify the device).
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...
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); do { lastChar = newChar; newChar = getchar(); } while ((newChar != '\n') && (newChar != EOF...