Pergunta

I'd like to play a previously recordet *.oni-File in C#/WPF. While, with the help of this tutorial I was able to get to RGB- and Depth-Stream to show up on my UI, I don't know how to play an *.oni-file.

The OpenNI page mentions, that I'd just have to "connect" to the file instead of the device, but I can't find the proper piece of code to do so.

The openni::Device class provides an interface to a single physical hardware device (via a driver). It can also provide an interface to a simulated hardware device via a recorded ONI file taken from a physical device.

If connecting to an ONI file instead of a physical device, it is only required that the ONI recording be available on the system running the application, and that the application have read access to this file.

I also found some clues / discussions, but none of it did help much

EDIT: I found a way to at least get the recording played using the SamplesConfig.xml. I just inserted the following code into the <ProductionNodes>:

<Recording file="\test.oni"  playbackSpeed="1.0"/>

Sadly, that recording crashes to program when it's done playing - I'm now looking for a way to loop the recording...

EDIT 2: Just if anybody should be interested, I'm using those lines to set the recording on loop:

ScriptNode scriptNode;
context = Context.CreateFromXmlFile(path + "\\" + configuration, out scriptNode);
Player p = (Player)context.FindExistingNode(NodeType.Player);
if (p!=null) p.SetRepeat(true); //Make sure it's really a recording.
Foi útil?

Solução

If anybody should need the code one day - I managed to load the file and play the recording without the need of a config file:

Context context = new Context();

// Add license
License license = new License();
license.Vendor = "vendor";
license.Key = "key";
context.AddLicense(license);

// Open file
context.OpenFileRecordingEx("record.oni");

// Set to repeat
Player p = (Player)context.FindExistingNode(NodeType.Player);
if (p != null) p.SetRepeat(true);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top