【问题标题】:Problems while recording and reading oni file with OpenNI.使用 OpenNI 记录和读取 oni 文件时出现问题。
【发布时间】:2013-02-15 21:57:56
【问题描述】:

我正在尝试将 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() 方法进行清理? Recorder没有这种方法。

这是我播放 .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。

有人知道我做错了什么吗?

【问题讨论】:

    标签: java kinect openni


    【解决方案1】:

    我想通了。我重写了一些代码并在录制结束时添加了 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);
            }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多