gpt4 book ai didi

java - 使用 OpenNI 记录和读取 oni 文件时出现问题。

转载 作者:行者123 更新时间:2023-11-30 04:29:50 25 4
gpt4 key购买 nike

我正在尝试将 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");

是 openFileRecordingEx 抛出 StatusException。

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

最佳答案

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

}

关于java - 使用 OpenNI 记录和读取 oni 文件时出现问题。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14893724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com