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

Function drawDepth

Samples/NiViewer/Draw.cpp:897–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

895}
896
897void drawDepth(IntRect* pLocation, IntPair* pPointer)
898{
899 if (g_DrawConfig.Streams.Depth.Coloring != DEPTH_OFF)
900 {
901 if (!isDepthOn())
902 {
903 drawClosedStream(pLocation, "Depth");
904 return;
905 }
906
907 const DepthMetaData* pDepthMD = getDepthMetaData();
908 const XnDepthPixel* pDepth = pDepthMD->Data();
909 XN_ASSERT(pDepth);
910
911 if (pDepthMD->FrameID() == 0)
912 {
913 return;
914 }
915
916 if (g_DrawConfig.Streams.Depth.Coloring == STANDARD_DEVIATION)
917 {
918 XnPixelStatistics* pStatistics = g_PixelStatistics;
919
920 for (XnUInt16 nY = pDepthMD->YOffset(); nY < pDepthMD->YRes() + pDepthMD->YOffset(); nY++)
921 {
922 XnUInt8* pTexture = TextureMapGetLine(&g_texDepth, nY) + pDepthMD->XOffset()*4;
923 for (XnUInt16 nX = 0; nX < pDepthMD->XRes(); nX++, pTexture+=4, pStatistics++)
924 {
925 pTexture[0] = pTexture[1] = XN_MIN((int)pStatistics->dStdDev, 255);
926 pTexture[2] = 0;
927 pTexture[3] = g_DrawConfig.Streams.Depth.fTransparency*255;
928 }
929 }
930 }
931 else
932 {
933 // copy depth into texture-map
934 for (XnUInt16 nY = pDepthMD->YOffset(); nY < pDepthMD->YRes() + pDepthMD->YOffset(); nY++)
935 {
936 XnUInt8* pTexture = TextureMapGetLine(&g_texDepth, nY) + pDepthMD->XOffset()*4;
937 for (XnUInt16 nX = 0; nX < pDepthMD->XRes(); nX++, pDepth++, pTexture+=4)
938 {
939 XnUInt8 nRed = 0;
940 XnUInt8 nGreen = 0;
941 XnUInt8 nBlue = 0;
942 XnUInt8 nAlpha = g_DrawConfig.Streams.Depth.fTransparency*255;
943
944 XnUInt16 nColIndex;
945
946 switch (g_DrawConfig.Streams.Depth.Coloring)
947 {
948 case LINEAR_HISTOGRAM:
949 nRed = nGreen = g_pDepthHist[*pDepth]*255;
950 break;
951 case PSYCHEDELIC_SHADES:
952 nAlpha *= (((XnFloat)(*pDepth % 10) / 20) + 0.5);
953 case PSYCHEDELIC:
954

Callers 1

drawFrameFunction · 0.85

Calls 13

isDepthOnFunction · 0.85
drawClosedStreamFunction · 0.85
getDepthMetaDataFunction · 0.85
TextureMapGetLineFunction · 0.85
TextureMapDrawCursorFunction · 0.85
TextureMapUpdateFunction · 0.85
TextureMapDrawFunction · 0.85
FrameIDMethod · 0.80
YOffsetMethod · 0.80
XOffsetMethod · 0.80
DataMethod · 0.45
YResMethod · 0.45

Tested by

no test coverage detected