Configuring OpenNI using an XML file

The following code configures OpenNI using an XML file, and then makes sure the nodes it needs exist:

// Initialize OpenNI context using an XML file
xn::Context context;
nRetVal = context.InitFromXmlFile(".\\Config.xml", NULL);
// TODO: check error code
// Look for the depth node
xn::DepthGenerator depth;
nRetVal = context.FindExistingNode(XN_NODE_TYPE_DEPTH, depth);
if (nRetVal != XN_STATUS_OK)
{
printf("Can't run - no depth generator is present!\n");
exit(-1);
}
// TODO: mainloop - process data
XN_STATUS_OK
#define XN_STATUS_OK
Definition XnStatus.h:37
XN_NODE_TYPE_DEPTH
@ XN_NODE_TYPE_DEPTH
Definition XnTypes.h:106
xn::Context
Definition XnCppWrapper.h:8594
xn::Context::FindExistingNode
XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode &node) const
Searches for an existing created node of a specified type and returns a reference to it.
Definition XnCppWrapper.h:9108
xn::Context::InitFromXmlFile
XnStatus InitFromXmlFile(const XnChar *strFileName, ScriptNode &scriptNode, EnumerationErrors *pErrors=NULL)
Shorthand combination of two other initialization methods - Init() and then RunXmlScriptFromFile() - ...
Definition XnCppWrapper.h:8790
xn::DepthGenerator
Definition XnCppWrapper.h:4695