Thursday, March 29, 2012

Problem with Kinect SDK and WPF dispatcher

I'm trying to get to run the WPF samples for Candescent NUI with the Kinect SDK. I'm experiencing a strange problem. When processing a depth frame (in the event DepthFrameReady) I experience performance issues and sometimes even a stack overflow exception.

Here's a stacktrace. You'll notice that after calling the WPF dispatcher the DepthFrameReady event is called again, and again ... resulting in a stack overflow exception


My guess is that while I'm processing a depth frame a new frame becomes available. When I give control to the dispatcher it somehow processes the message queue and first continues with the new depth frame instead of the code I pass.

So I see two solutions
1. Make my code faster so it's done when the new frame gets ready. But I can't guarantee this.
2. Create a queue for the depth frames and process them in a separate thread. Maybe dropping some frames when my code is too slow.

Is there information available on how this should be handeled? Might have to ask in the forum...

No comments:

Post a Comment