Kinect v2, read out data from .xef files
Asked Answered
L

3

7

I have collected a bunch of videos using Kinect for windows 2 using the kinect studio with file extension .xef.

Now I want to write a program to load data from them and just playback or save as another format, but I have found little resource to doing so, is there any useful resource to do that?

Lamrouex answered 3/12, 2014 at 20:8 Comment(0)
U
1

what you can do is reading the xef file using the Kinect Studio, then going to Play (or Playback) tab and hit play, your program will start streaming. I think it's the only way to do that, doing like it's coming from the kinect.

Unreadable answered 7/1, 2015 at 14:16 Comment(1)
I am also looking for a way to simulate Kinect input from an .xef recording. How exactly is this done? When I load a file for playback in Kinect Studio and hit play, in my C++ program I can successfully get a Kinect instance with GetDefaultKinectSensor, call Open, get the IBodyFrameSource and IBodyFrameReader, all good, but when I call IBodyFrameReader::AcquireLatestFrame, it gives me "E_PENDING The data necessary to complete this operation is not yet available.". Same with the sample code included in the SDK, btw.Korten
B
15

Actually, you can use the Kinect Studio API to read and play .xef files since the last SDK release (KinectSDK-v2.0_1409). It is just not properly documented yet, but can be integrated into your code. Here is a short description to use it (tried in a VS 2013 C# Solution):

  1. Go to the installation Folder of the KinectStudio (e.g. C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Tools\KinectStudio­).
  2. Reference "Microsoft.Kinect.Tools.dll" in your project.
  3. Copy "KStudioService.dll" to your Debug or Release folder.
  4. Change BuildProperties to x64 (otherwise you get a BadImageFormatException).

The API is described here.

And here is some sample code from Carmine from the Microsoft Kinect team.

Blynn answered 25/2, 2015 at 15:0 Comment(2)
Hi, I have run the sample code from Carmine successfully, but I don't know how to get the color and depth images from KStudioPlayback Object. Do you have any idea about this?Strange
@Blynn did you actually get this sample code to work? I get an exception "Value does not fall within the expected range." when calling client.CreatePlayback (same when opening the file with KSUtil, btw., while KStudio can play the file without any apparent issues).Korten
U
1

what you can do is reading the xef file using the Kinect Studio, then going to Play (or Playback) tab and hit play, your program will start streaming. I think it's the only way to do that, doing like it's coming from the kinect.

Unreadable answered 7/1, 2015 at 14:16 Comment(1)
I am also looking for a way to simulate Kinect input from an .xef recording. How exactly is this done? When I load a file for playback in Kinect Studio and hit play, in my C++ program I can successfully get a Kinect instance with GetDefaultKinectSensor, call Open, get the IBodyFrameSource and IBodyFrameReader, all good, but when I call IBodyFrameReader::AcquireLatestFrame, it gives me "E_PENDING The data necessary to complete this operation is not yet available.". Same with the sample code included in the SDK, btw.Korten
R
1

There seems not having a way to parse XEF file to extract the images directly yet.

If you do not need all frames stored in XEF file, i.e., frame dropping is ok, an indirect way is to make a Kinect application to receive frames from XEF file via Kinect service.

A quick test is:

  1. Launch KinectStudio, connect to Kinect service, open XEF file.
  2. Launch ColorBasics-D2D or DepthBasics-D2D (from Kinect v2 SDK).
  3. Play the XEF file in KinectStudio.
  4. The color/depth frames are displayed in the ColorBasics or DepthBasics app.

You can then modify the source code in ColorBasics or DepthBasics to save the images accordingly. You can modify KinectFusionExplorer-D2D if you care about aligning depth and color images.

This approach can only capture a subset of frames stored in the XEF because the playback and frame receiving via Kinect service is asynchronous. Therefore it will only work if frame dropping is not an issue in your program.

Remediless answered 15/2, 2016 at 10:3 Comment(1)
How did you get this to work? The way I understood this is that when replaying data in Kinect Studio in the Play tab, this is supposed to simulate a real-world Kinect device for other Kinect applications, right?Korten

© 2022 - 2024 — McMap. All rights reserved.