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
xn::DepthGenerator depth;
nRetVal = depth.Create(context);
// TODO: check error code
// Create audio generator
xn::AudioGenerator audio;
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
}
TRUE
#define TRUE
Definition XnPlatform.h:96
xn::AudioGenerator
Definition XnCppWrapper.h:8039
xn::AudioGenerator::Create
XnStatus Create(Context &context, Query *pQuery=NULL, EnumerationErrors *pErrors=NULL)
Creates an AudioGenerator node from available production node alternatives.
Definition XnCppWrapper.h:9925
xn::Context
Definition XnCppWrapper.h:8594
xn::Context::WaitAnyUpdateAll
XnStatus WaitAnyUpdateAll()
Updates all generator nodes in the context to their latest available data, first waiting for any of t...
Definition XnCppWrapper.h:9384
xn::Context::Init
XnStatus Init()
Builds the context's general software environment.
Definition XnCppWrapper.h:8707
xn::Context::StartGeneratingAll
XnStatus StartGeneratingAll()
Ensures all created generator nodes are generating data.
Definition XnCppWrapper.h:9161
xn::DepthGenerator
Definition XnCppWrapper.h:4695
xn::DepthGenerator::Create
XnStatus Create(Context &context, Query *pQuery=NULL, EnumerationErrors *pErrors=NULL)
Creates a DepthGenerator node from available production node alternatives.
Definition XnCppWrapper.h:9801
xn::Recorder
Definition XnCppWrapper.h:3691
xn::Recorder::Create
XnStatus Create(Context &context, const XnChar *strFormatName=NULL)
Creates a Recorder node.
Definition XnCppWrapper.h:9783
xn::Recorder::Record
XnStatus Record()
Records one frame of data from each node that was added to the recorder with AddNodeToRecording().
Definition XnCppWrapper.h:3774
xn::Recorder::AddNodeToRecording
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:3746