Pergunta

Im trying to record depth data from the Kinect-sensor to file and then play it using openNi. I have written a simple program based on the examples from openNi. Im using the java wrapper.

The problem is that when I try to read the .oni file that I am recording to, I get this error:

org.OpenNI.StatusException: The file is corrupted!

Here is my code for recording:

Context context = new Context();
// add the NITE License 
License license = new License("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4=");   //     vendor, key
context.addLicense(license); 

DepthGenerator depth = DepthGenerator.create(context);

Recorder recorder = Recorder.create(context, "oni"); 
context.createProductionTree(recorder.getInfo());
recorder.setDestination(RecordMedium.FILE, "KinectLog.oni");

recorder.addNodeToRecording(depth);

context.startGeneratingAll();

int tmp = 0;
while(tmp < 100){
    tmp++;
    context.waitAnyUpdateAll();
    recorder.Record();
    System.out.println("recording");
}

Maybe I have to clean up after recording by calling some .release() method? Recorder does not have such a method.

Here is my code for playing the .oni file:

Context context = new Context();
// add the NITE License 
License license = new License("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4=");   // vendor, key
context.addLicense(license); 

context.openFileRecordingEx("KinectLog.oni");

It's the openFileRecordingEx that casts the StatusException.

Anyone know what I am doing wrong?

Foi útil?

Solução

I figured it out. I rewrote some of the code and added recorder.dispose() at the end of recording to free the recorder object.

    public static void main(String[] args) {

    try {

        Context context = new Context();
        // add the NITE License 
        License license = new License("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4=");   // vendor, key
        context.addLicense(license); 

        DepthGenerator depth = DepthGenerator.create(context);


        Recorder recorder = Recorder.create(context, "oni"); 

        recorder.setDestination(RecordMedium.FILE, "KinectLog.oni");

        recorder.addNodeToRecording(depth);

        context.startGeneratingAll();

        int tmp = 0;
        while(tmp < 100){
            tmp++;
            context.waitAnyUpdateAll();
            recorder.Record();
            System.out.println("recording");
        }
        recorder.dispose();         

        }
        catch (GeneralException e) {
          System.out.println(e);
          System.exit(1);
        }

}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top