| 104 | } |
| 105 | |
| 106 | void 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 | |
| 142 | bool isStatisticsActive() |
| 143 | { |
no test coverage detected