Search code examples
kinectrecordingopenni

Problems with recording Kinect depth using OpenNI -- "The file is corrupted!"


This is how I setup the recording in my app:

    xn::NodeInfoList recordersList;
    rc = context.EnumerateProductionTrees(XN_NODE_TYPE_RECORDER, NULL, recordersList);
    CHECK_RC(rc, "enumerate recorders");
    xn::NodeInfo chosen = *recordersList.Begin();

    recorder = new xn::Recorder();
    rc = recorder->Create(context, "oni");
    CHECK_RC(rc, "create recorder");
    rc = context.CreateProductionTree(chosen, *recorder);
    CHECK_RC(rc, "create production tree");
    rc = recorder->SetDestination(XN_RECORD_MEDIUM_FILE, "KinectLog.oni");
    CHECK_RC(rc, "set destination for recording");
    rc = recorder->AddNodeToRecording(depthGenerator, XN_CODEC_16Z_EMB_TABLES);
    CHECK_RC(rc, "add node to recording");

Then I call rc = context.WaitAnyUpdateAll(); about 30 times per second; everything works, I can see the Kinect input on my screen etc.

Everything seems to go fine, but when I try to open the resulting KinectLog.oni in the sample NiViewer, I get:

jan@mbp ~/OpenNI/Samples/Bin/x64-Release $ ./NiViewer ~/devel/k/KinectLog.oni
Open failed: The file is corrupted!
Press any key to continue . . .

What could be the problem?


Solution

  • I found it, I forgot to do:

    recorder->Release();
    delete recorder;
    

    at the end.