OpenNI 1.3.2

Meta Data Objects

OpenNI meta data objects are a way to hold the entire set of properties of a specific data alongside with the data itself (for example, storing the resolution of a depth map with the depth map). Each generator that produces data has its own kind of meta data object. This object can later be passed to functions processing this data, preventing the need of sending multiple arguments each time.

In addition, the meta data objects are used to freeze the configuration of a node at the time this data arrived. Sometimes an application changes configuration of a node while reading data from it. In such a case, and until new data arrives, the data received from this node was produced using a different configuration. For example, lets say a Depth Generator was configured to produce QVGA depth maps, and the application constantly reads data from it. At some point, the application changed the node output mode to VGA. Until the moment a new frame arrives, calling xn::DepthGenerator::GetDepthMap() would return a QVGA map, but calling xn::DepthGenerator::GetMapOutputMode() would return VGA resolution. This might cause errors (or even access violation) in the application.

To solve this, each node has a meta data object, keeping the properties of the data when it was read. So, in the above case, by calling xn::DepthGenerator::GetMetaData() you would get a xn::DepthMetaData object. This object Data() method would return a pointer to the QVGA depth map, and XRes() and YRes() functions would return QVGA resolution.

Meta Data objects holds const pointers to the data (as this is what's returned from the generators). C++ Meta Data objects (all objects inheriting from xn::OutputMetaData) also provide a way to replace the data buffer with a self-allocated buffer, which can also be written to. Use the AllocateData() function for allocating a clean buffer, or the MakeDataWritable() function for also copying data from the const buffer into the newly allocated writable buffer.

Also, C++ Meta Data objects support several types of copying:

  • All InitFrom functions actually perform the shallow copy made by C functions (xnCopyDepthMetaData() for example).
  • All CopyFrom functions allocates a new buffer and copies data to it (so that destination object now points to a private copy of the data of the source object).

Currently this creates a situation in which the functionality supplied by C and C++ interfaces is not the same. This will be fixed in future versions.