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

Function DrawDepthMap

Samples/NiUserTracker/SceneDrawer.cpp:263–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261
262
263void DrawDepthMap(const xn::DepthMetaData& dmd, const xn::SceneMetaData& smd)
264{
265 static bool bInitialized = false;
266 static GLuint depthTexID;
267 static unsigned char* pDepthTexBuf;
268 static int texWidth, texHeight;
269
270 float topLeftX;
271 float topLeftY;
272 float bottomRightY;
273 float bottomRightX;
274 float texXpos;
275 float texYpos;
276
277 if(!bInitialized)
278 {
279 texWidth = getClosestPowerOfTwo(dmd.XRes());
280 texHeight = getClosestPowerOfTwo(dmd.YRes());
281
282// printf("Initializing depth texture: width = %d, height = %d\n", texWidth, texHeight);
283 depthTexID = initTexture((void**)&pDepthTexBuf,texWidth, texHeight) ;
284
285// printf("Initialized depth texture: width = %d, height = %d\n", texWidth, texHeight);
286 bInitialized = true;
287
288 topLeftX = dmd.XRes();
289 topLeftY = 0;
290 bottomRightY = dmd.YRes();
291 bottomRightX = 0;
292 texXpos =(float)dmd.XRes()/texWidth;
293 texYpos =(float)dmd.YRes()/texHeight;
294
295 memset(texcoords, 0, 8*sizeof(float));
296 texcoords[0] = texXpos, texcoords[1] = texYpos, texcoords[2] = texXpos, texcoords[7] = texYpos;
297 }
298
299 unsigned int nValue = 0;
300 unsigned int nHistValue = 0;
301 unsigned int nIndex = 0;
302 unsigned int nX = 0;
303 unsigned int nY = 0;
304 unsigned int nNumberOfPoints = 0;
305 XnUInt16 g_nXRes = dmd.XRes();
306 XnUInt16 g_nYRes = dmd.YRes();
307
308 unsigned char* pDestImage = pDepthTexBuf;
309
310 const XnDepthPixel* pDepth = dmd.Data();
311 const XnLabel* pLabels = smd.Data();
312
313 static unsigned int nZRes = dmd.ZRes();
314 static float* pDepthHist = (float*)malloc(nZRes* sizeof(float));
315
316 // Calculate the accumulative histogram
317 memset(pDepthHist, 0, nZRes*sizeof(float));
318 for (nY=0; nY<g_nYRes; nY++)
319 {
320 for (nX=0; nX<g_nXRes; nX++)

Callers 1

glutDisplayFunction · 0.85

Calls 15

getClosestPowerOfTwoFunction · 0.85
initTextureFunction · 0.85
DrawTextureFunction · 0.85
xnOSStrFormatFunction · 0.85
GetPoseErrorStringFunction · 0.85
DrawJointFunction · 0.85
DrawLimbFunction · 0.85
ZResMethod · 0.80
IsTrackingMethod · 0.80
GetSkeletonCapMethod · 0.80
IsCalibratingMethod · 0.80

Tested by

no test coverage detected