![]() |
OpenNI 1.5.4
|
Source file: Click the following link to view the source code file:
This file contains the code for calculating the statistics for the frames from the OpenNI generator nodes.
The XnPixelStatistics data structure is defined in Statistics.h of this sample program.
XnPixelStatistics* g_PixelStatistics = NULL;
enum XnCollectionStatus
{
NOT_COLLECTING,
SHOULD_COLLECT,
COLLECTING,
COLLECTION_ENDED,
} g_StatisticsState;
This function initializes the statistics collecting mechanism.
This function gets a saved Frame Objects DepthGenerator node's "frame object", assigning them to pDepthMD
. The frame object is a snapshot of the generated data, saved as a metadata object, at a certain point in time. The xn::OutputMetaData::Data() method gets a pointer to the data frame of the frame object saved in the metadata.
const DepthMetaData* pDepthMD = getDepthMetaData(); if (pDepthMD != NULL) { g_PixelStatistics = new XnPixelStatistics[pDepthMD->FullXRes() * pDepthMD->FullYRes()]; }
The above code uses the FullXRes() method to calculate the scaling factor between the depth map and the GL window. FullXRes() gets the full frame resolution, i.e., the entire field-of-view, ignoring cropping of the FOV in the scene.
In the following, the xn::DepthGenerator::GetDeviceMaxDepth() method gets the maximum depth value that the DepthGenerator node can generate. The maximum depth value is a hardware specification of the sensor.
XnDepthPixel nMaxDepth = getDepthGenerator()->GetDeviceMaxDepth();
This function adds a further data frame to the statistics collection.
This function uses OpenNI operation types that have already been described in this program sample.