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

Method Dump

Samples/NiBackRecorder/main.cpp:334–414  ·  view source on GitHub ↗

Save the current state of the buffer to a file

Source from the content-addressed store, hash-verified

332
333 // Save the current state of the buffer to a file
334 XnStatus Dump()
335 {
336 xn::MockDepthGenerator mockDepth;
337 xn::MockImageGenerator mockImage;
338
339 xn::EnumerationErrors errors;
340 XnStatus rc;
341
342 // Create recorder
343 rc = m_context.CreateAnyProductionTree(XN_NODE_TYPE_RECORDER, NULL, m_recorder, &errors);
344 CHECK_RC_ERR(rc, "Create recorder", errors);
345
346 // Create name of new file
347 time_t rawtime;
348 struct tm *timeinfo;
349 time(&rawtime);
350 timeinfo = localtime(&rawtime);
351 XnChar strFileName[XN_FILE_MAX_PATH];
352 sprintf(strFileName, "%s/%04d%02d%02d-%02d%02d%02d.oni", m_strDirName,
353 timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
354
355 m_recorder.SetDestination(XN_RECORD_MEDIUM_FILE, strFileName);
356 printf("Creating file %s\n", strFileName);
357
358 // Create mock nodes based on the depth generator, to save depth
359 if (m_bDepth)
360 {
361 // Create mock nodes based on the depth generator, to save depth
362 rc = m_context.CreateMockNodeBasedOn(m_depthGenerator, NULL, mockDepth);
363 CHECK_RC(rc, "Create depth node");
364 rc = m_recorder.AddNodeToRecording(mockDepth);
365 CHECK_RC(rc, "Add depth node");
366 }
367 if (m_bImage)
368 {
369 // Create mock nodes based on the image generator, to save image
370 rc = m_context.CreateMockNodeBasedOn(m_imageGenerator, NULL, mockImage);
371 CHECK_RC(rc, "Create image node");
372 rc = m_recorder.AddNodeToRecording(mockImage);
373 CHECK_RC(rc, "Add image node");
374 }
375
376 // Write frames from next index (which will be next to be written, and so the first available)
377 // this is only if a full loop was done, and this frame has meaningful data
378 if (m_nNextWrite < m_nBufferCount)
379 {
380 // Not first loop, right till end
381 for (XnUInt32 i = m_nNextWrite; i < m_nBufferSize; ++i)
382 {
383 if (m_bDepth)
384 {
385 mockDepth.SetData(m_pFrames[i].depthFrame);
386 }
387 if (m_bImage)
388 {
389 mockImage.SetData(m_pFrames[i].imageFrame);
390 }
391

Callers 1

mainFunction · 0.80

Calls 6

SetDestinationMethod · 0.45
AddNodeToRecordingMethod · 0.45
SetDataMethod · 0.45
RecordMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected