Threading with the Kinect
Asked Answered
A

2

13

I am writing a C# application that is using the Kinect, i am taking the output currently and writing it to a Shader Resource and rendering it as a texture, my issue is that the Kinect (apparently) only runs at 30fps, so it is throttling my performance badly.

What is the best way to overcome this, is it multithreading? Is there some sort of design pattern that would help with this type of issue? As far as i can tell i may want to have the kinect processing the data on a thread, and then get access to it when the process is finished, but i'm not sure where to start with that in a safe manner.

Thanks for any advice you can offer.

I am currently using OpenNI for the kinect drivers/api, and SlimDX for the directX side of rendering.

Airbrush answered 8/6, 2011 at 9:42 Comment(1)
I have no experience with the Kinect, but if it takes a significant amount of time to process the data, then that data should be processed on a separate, not UI thread. You could try BackgroundWorker Class.Wartburg
L
8

I have not worked with the Kinect before and you didn't specify which drivers/wrapper you are using, but I suspect that it probably won't matter.

What you will probably need to do is the following:

  1. Seperate the "Update" cycle for the Kinect onto it's own thread. That will leave your application logic free to run as fast as it can without being stopped waiting for an update from the kinect hardware.
  2. You will need to "lock" the image/depth data on each pass while the kinect fills in the new data.
  3. If the process of the Kinect filling in the data is taking two long you could try buffering the image and depth data if the drivers don't already do that. This means just keeping two copies in memory and read one while the other is being written.

For excellent tutorials on threading in c#, I always recommend Albahari's Threading in C#. I would also recommend if you want more specific information on what you can do to speed up your application, you should probably edit your question and add details about specifically how you have it structured now and what wrapper/driver's you are using, etc.

Latty answered 13/6, 2011 at 4:10 Comment(1)
Thanks for the response, when i implement this i will throw up some code on what i did in case anyone else runs into this issue.Airbrush
N
1

Any development with Kinect that requires high perfomance you should use the pooling model instead event model. And complementary to this, your best option is open a thread and do the pooling operations. You can use too threads with event model , to make long time operations and not freeze the user interface.

And you can see this : http://msdn.microsoft.com/en-us/library/hh973076

Nepotism answered 23/8, 2012 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.