Question

What I'm basically trying to do is writing kinect skeleton frame data (joint positions) to a file using C# & Kinect SDK (done), then process this data externally (done), then read the data back into my application (done) and draw the data as a light point walker (skeleton joints) frame by frame so I see an animation. (problem)

My Question is: How do I get this 30fps animation drawn using C# (and its DrawingContext class)?

I wanted to use the DrawingContext, because I'm using it for the live output of the SkeletonFrames already while recording. There it is done simply like this, similar to the "Skeleton Basics" SDK Example:

this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;
...

private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
    {
        ...

        using (DrawingContext dc = this.drawingGroup.Open())
        {
        ...
           dc.DrawEllipse(drawBrush, null, 2Dpoint, JointThickness, JointThickness);

        }
    }

So the kinect provides me with the frames at approx. 30fps using events and I just draw the data.

But how do I draw it when there is no kinect but the data is read from file/memory? (Currently using a 2DArray [Frame, Joint])

I thought about having a thread running at 30fps (using sleep to achieve the framerate) which then sends a similar event or draws directly.. However my attempts to get this working failed completely. For instance didn't I get the event sent to the main thread for drawing.

The problem might be my lack of understanding C# (I'm totally new to it)...

Any hints on how I could get this set up and working?

Was it helpful?

Solution

The Kinect Toolbox already provides a way to save and replay stream data (any one of the three). It may fill the hole for what you need.

If you choose to roll your own, you will want to save a zero-based timestamp with each skeleton saved to the file. Then when you wish to replay it you can use a DispatcherTimer or Timer to count from zero to whenever -- when you the timer hits the proper timestamp value for the next skeleton, display it.

As you point out, the Kinect will give you approx. 30 fps. You do not want to assume that it is running at a full 30 fps. Use a timestamp in order to play it back when it should (be it 30 fps, or 15 fps)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top