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

Method Display

Samples/NiHandTracker/NiSimpleViewer.cpp:192–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void SimpleViewer::Display()
193{
194 XnStatus rc = XN_STATUS_OK;
195
196 // Read a new frame
197 rc = m_rContext.WaitAnyUpdateAll();
198 if (rc != XN_STATUS_OK)
199 {
200 printf("Read failed: %s\n", xnGetStatusString(rc));
201 return;
202 }
203
204 m_depth.GetMetaData(m_depthMD);
205 m_image.GetMetaData(m_imageMD);
206
207 const XnDepthPixel* pDepth = m_depthMD.Data();
208
209 // Copied from SimpleViewer
210 // Clear the OpenGL buffers
211 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
212
213 // Setup the OpenGL viewpoint
214 glMatrixMode(GL_PROJECTION);
215 glPushMatrix();
216 glLoadIdentity();
217 glOrtho(0, GL_WIN_SIZE_X, GL_WIN_SIZE_Y, 0, -1.0, 1.0);
218
219 // Calculate the accumulative histogram (the yellow display...)
220 xnOSMemSet(m_pDepthHist, 0, m_depthMD.ZRes()*sizeof(float));
221
222 unsigned int nNumberOfPoints = 0;
223 for (XnUInt y = 0; y < m_depthMD.YRes(); ++y)
224 {
225 for (XnUInt x = 0; x < m_depthMD.XRes(); ++x, ++pDepth)
226 {
227 if (*pDepth != 0)
228 {
229 m_pDepthHist[*pDepth]++;
230 nNumberOfPoints++;
231 }
232 }
233 }
234 for (int nIndex=1; nIndex<m_depthMD.ZRes(); nIndex++)
235 {
236 m_pDepthHist[nIndex] += m_pDepthHist[nIndex-1];
237 }
238 if (nNumberOfPoints)
239 {
240 for (int nIndex=1; nIndex<m_depthMD.ZRes(); nIndex++)
241 {
242 m_pDepthHist[nIndex] = (unsigned int)(256 * (1.0f - (m_pDepthHist[nIndex] / nNumberOfPoints)));
243 }
244 }
245
246 xnOSMemSet(m_pTexMap, 0, m_nTexMapX*m_nTexMapY*sizeof(XnRGB24Pixel));
247
248 // check if we need to draw image frame to texture
249 if (m_eViewState == DISPLAY_MODE_OVERLAY ||

Callers 1

glutDisplayMethod · 0.80

Calls 13

xnGetStatusStringFunction · 0.85
WaitAnyUpdateAllMethod · 0.80
ZResMethod · 0.80
RGB24DataMethod · 0.80
YOffsetMethod · 0.80
XOffsetMethod · 0.80
FullXResMethod · 0.80
FullYResMethod · 0.80
xnOSMemSetFunction · 0.50
GetMetaDataMethod · 0.45
DataMethod · 0.45
YResMethod · 0.45

Tested by

no test coverage detected