1

Kinectセンサーからファイルに深度データを記録し、openNiを使用して再生しようとしています。私はopenNiの例に基づいて簡単なプログラムを書きました。Javaラッパーを使用しています。

問題は、記録している.oniファイルを読み込もうとすると、次のエラーが発生することです。

org.OpenNI.StatusException: The file is corrupted!

録音用のコードは次のとおりです。

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");
}

たぶん、録音後に.release()メソッドを呼び出してクリーンアップする必要がありますか?レコーダーにはそのような方法はありません。

.oniファイルを再生するための私のコードは次のとおりです。

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

context.openFileRecordingEx("KinectLog.oni");

StatusExceptionをキャストするのはopenFileRecordingExです。

誰かが私が間違っていることを知っていますか?

4

1 に答える 1

2

私はそれを考え出した。コードの一部を書き直し、記録の最後にrecorder.dispose()を追加して、レコーダーオブジェクトを解放しました。

    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);
        }

}
于 2013-02-15T13:57:56.230 に答える