Recording streams to file (ONI file)
We learned about playing ONI
files but it was only a part of this topic. You can record ONI
files from the device's outputs yourself too. We will now introduce an
openni::Recorder
class that can be used for this purpose. This recipe is easy, as adding and starting openni::VideoStream
involves nothing special.
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) { if (status == STATUS_OK) return true; printf("ERROR: #%d, %s", status...