MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / statisticsAddFrame

Function statisticsAddFrame

Samples/NiViewer/Statistics.cpp:106–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void statisticsAddFrame()
107{
108 if (g_StatisticsState == SHOULD_COLLECT)
109 {
110 g_StatisticsState = COLLECTING;
111 }
112
113 if (g_StatisticsState == COLLECTING)
114 {
115 const DepthMetaData* pDepthMD = getDepthMetaData();
116
117 const XnDepthPixel* pDepth = pDepthMD->Data();
118
119 for (XnUInt32 y = pDepthMD->YOffset(); y < pDepthMD->YRes() + pDepthMD->YOffset(); ++y)
120 {
121 XnPixelStatistics* pPixel = &g_PixelStatistics[y*pDepthMD->FullXRes() + pDepthMD->XOffset()];
122 for (XnUInt32 x = pDepthMD->XOffset(); x < pDepthMD->XRes() + pDepthMD->XOffset(); ++x, ++pDepth, ++pPixel)
123 {
124 XnDepthPixel nDepth = *pDepth;
125
126 if (nDepth > pPixel->nMax)
127 pPixel->nMax = nDepth;
128
129 if (nDepth < pPixel->nMin)
130 pPixel->nMin = nDepth;
131
132 pPixel->nSum += nDepth;
133 pPixel->nSumSquare += (nDepth * nDepth);
134 pPixel->nCount++;
135 pPixel->dAverage = pPixel->nSum / pPixel->nCount;
136 pPixel->dStdDev = sqrt( (1.0/pPixel->nCount) * (pPixel->nSumSquare) - (pPixel->dAverage * pPixel->dAverage) );
137 }
138 }
139 }
140}
141
142bool isStatisticsActive()
143{

Callers 1

IdleCallbackFunction · 0.85

Calls 7

getDepthMetaDataFunction · 0.85
YOffsetMethod · 0.80
FullXResMethod · 0.80
XOffsetMethod · 0.80
DataMethod · 0.45
YResMethod · 0.45
XResMethod · 0.45

Tested by

no test coverage detected