OpenNI 1.5.7
Recording data

When an application wants to record data, it needs to create a recorder node, add the nodes that it wishes to record to it, and then continuously read data and record it.

The following code creates a depth node and an audio node, and then records their data to a file:

// Initialize context
xn::Context context;
nRetVal = context.Init();
// TODO: check error code
// Create depth generator
nRetVal = depth.Create(context);
// TODO: check error code
// Create audio generator
nRetVal = audio.Create(context);
// TODO: check error code
// Create recorder
xn::Recorder recorder;
nRetVal = recorder.Create(context);
// TODO: check error code
// Add depth node to recording
nRetVal = recorder.AddNodeToRecording(depth);
// TODO: check error code
// Add audio node to recording
nRetVal = recorder.AddNodeToRecording(audio);
// TODO: check error code
// Start generating
nRetVal = context.StartGeneratingAll();
// TODO: check error code
// Now read data and record it
while (TRUE)
{
nRetVal = context.WaitAnyUpdateAll();
// TODO: check error code
nRetVal = recorder.Record();
// TODO: check error code
}
#define TRUE
Definition XnPlatform.h:85
Definition XnCppWrapper.h:8066
XnStatus Create(Context &context, Query *pQuery=NULL, EnumerationErrors *pErrors=NULL)
Creates an AudioGenerator node from available production node alternatives.
Definition XnCppWrapper.h:9952
Definition XnCppWrapper.h:8621
XnStatus WaitAnyUpdateAll()
Updates all generator nodes in the context to their latest available data, first waiting for any of t...
Definition XnCppWrapper.h:9411
XnStatus Init()
Builds the context's general software environment.
Definition XnCppWrapper.h:8734
XnStatus StartGeneratingAll()
Ensures all created generator nodes are generating data.
Definition XnCppWrapper.h:9188
Definition XnCppWrapper.h:4721
XnStatus Create(Context &context, Query *pQuery=NULL, EnumerationErrors *pErrors=NULL)
Creates a DepthGenerator node from available production node alternatives.
Definition XnCppWrapper.h:9828
Definition XnCppWrapper.h:3706
XnStatus Create(Context &context, const XnChar *strFormatName=NULL)
Creates a Recorder node.
Definition XnCppWrapper.h:9810
XnStatus Record()
Records one frame of data from each node that was added to the recorder with AddNodeToRecording().
Definition XnCppWrapper.h:3789
XnStatus AddNodeToRecording(ProductionNode &Node, XnCodecID compression=XN_CODEC_NULL)
Adds a node to the recording setup, and starts recording data what the node generates....
Definition XnCppWrapper.h:3761