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

Function calculateHistogram

Samples/NiViewer/Draw.cpp:548–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546}
547
548void calculateHistogram()
549{
550 DepthGenerator* pDepthGen = getDepthGenerator();
551
552 if (pDepthGen == NULL)
553 return;
554
555 XnUInt32 nZRes = pDepthGen->GetDeviceMaxDepth() + 1;
556 if (g_pDepthHist == NULL)
557 {
558 g_pDepthHist = new float[nZRes];
559 }
560
561 xnOSMemSet(g_pDepthHist, 0, nZRes*sizeof(float));
562 int nNumberOfPoints = 0;
563
564 XnDepthPixel nValue;
565
566 const XnDepthPixel* pDepth = pDepthGen->GetDepthMap();
567 const XnDepthPixel* pDepthEnd = pDepth + (pDepthGen->GetDataSize() / sizeof(XnDepthPixel));
568
569 while (pDepth != pDepthEnd)
570 {
571 nValue = *pDepth;
572
573 XN_ASSERT(nValue <= nZRes);
574
575 if (nValue != 0)
576 {
577 g_pDepthHist[nValue]++;
578 nNumberOfPoints++;
579 }
580
581 pDepth++;
582 }
583
584 XnUInt32 nIndex;
585 for (nIndex = 1; nIndex < nZRes; nIndex++)
586 {
587 g_pDepthHist[nIndex] += g_pDepthHist[nIndex-1];
588 }
589 for (nIndex = 1; nIndex < nZRes; nIndex++)
590 {
591 if (g_pDepthHist[nIndex] != 0)
592 {
593 g_pDepthHist[nIndex] = (nNumberOfPoints-g_pDepthHist[nIndex]) / nNumberOfPoints;
594 }
595 }
596}
597
598// --------------------------------
599// Drawing

Callers 1

drawFrameFunction · 0.85

Calls 5

getDepthGeneratorFunction · 0.85
xnOSMemSetFunction · 0.50
GetDeviceMaxDepthMethod · 0.45
GetDepthMapMethod · 0.45
GetDataSizeMethod · 0.45

Tested by

no test coverage detected