Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Threading with the Kinect

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.

like image 558
Craig Avatar asked Jun 08 '11 09:06

Craig


2 Answers

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.

like image 164
ExCodeCowboy Avatar answered Nov 14 '22 00:11

ExCodeCowboy


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

like image 42
acandaldev Avatar answered Nov 13 '22 22:11

acandaldev