none
How to decode Kinect Body Event data? RRS feed

  • Question

  • Hello, all! I am working on a project which read xef event data without connecting to Kinect service and extract body information. By the code below, I can save the Kinect body data of each frame as a 6288 length byte array. However, I cannot understand the meaning of the data array. I think it should include the information of floorplane, joints coordinate. How could I decode the array to the body information? Is there any other API in Microsoft.Kinect.Tool could help me to get the body information from the event file (*.xef)?

    Thanks!


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Threading.Tasks;
    using Microsoft.Kinect.Tools;
    
    namespace ksaiptest
    {
        class Program
        {
            static void Main(string[] args)
            {
                string fname = "sample.xef";
                string dir = "C:\\Users\\Eric\\Documents\\MATLAB\\decode\\body\\"; 
                KStudioClient client = KStudio.CreateClient();
    
                KStudioEventStreamSelectorCollection collection = new KStudioEventStreamSelectorCollection();
                collection.Add(KStudioEventStreamDataTypeIds.Body);
                
                KStudioEventReader reader = client.CreateEventReader(dir+fname, collection);
                KStudioEvent ev = reader.GetNextEvent();
    
                int n = 1;
                do
                {
                    ev = reader.GetNextEvent();
                    byte[] bytes = new byte[6288];
                    ev.CopyEventDataToArray(bytes, 0);
    
                    using (FileStream stream = new FileStream(dir + n.ToString() + ".txt", FileMode.Create, FileAccess.Write, FileShare.Read))
                    {
                        stream.Write(bytes, 0, bytes.Length);
                    }
                    ++n;
                }
                while (ev != null);
            }
        }
    }



    • Edited by Eric Huo Monday, July 13, 2015 8:32 PM
    Monday, July 13, 2015 8:29 PM

Answers

All replies

  • Hi Eric,

    The Kinect Studio .xef files are designed to be played back through the Kinect service.  This is to ensure that any changes to the tracking algorithms are reflected in the data you receive.  You can then use the Body classes to retrieve the data.

    Please note that a Kinect sensor is not required to be connected at the time of playback.

    Thanks,

    David

    Monday, July 13, 2015 11:41 PM
    Moderator
  • Thank you for your replying to me!
    The problem is our record starts at the time the human subject stood on a platform which is not suitable for the human tracking algorithm on calibration. And when the tracking algorithm ran in real time, the tracking result became very bad. That is why we really need the original skeleton model data. The original data can be shown in Kinect Studio at "play" tab when we choose "not connected" option, so we think they are stored at somewhere in the event data. I am very appreciate if you can provide a clue to access those data.
    Thanks:)
    Tuesday, July 14, 2015 2:49 AM
  • Hi Eric,

    The process for getting joint data from a .xef file is to play back the file through the service. If you wish to get the specific body data that was recorded, playback as 'not connected'.

    Regarding the issue with playback in connected mode, you are likely encountering an issue related to a recording that was started after tracking had already begun. The referenced post describes best practices with regards to recording body data, specifically Carmine Si's reply.

    https://social.msdn.microsoft.com/Forums/en-US/b0c8c9ea-13ae-4e15-8d8d-84700987f7b7/bodyframe-stream-xef?forum=kinectv2sdk

    Thanks,

    David

    Wednesday, July 15, 2015 5:51 PM
    Moderator
  • Thank you! But how does the KStudio and VGB access to the raw skeleton data and display them on the interface. I need to save the coordinate of joints for each frame to file which calls a need of the API to open xef file and get the skeleton information. Could I find the API in Kinect SDK?

    Thanks.


    Eric Huo

    Wednesday, July 15, 2015 6:28 PM
  • Hi Eric, I've met with the same problem as yours. I also need to decode the body data to get the joints position and orientation. Have you got the solution? Looking forward to your reply. Thanks.
    Tuesday, February 2, 2016 10:02 AM