Search code examples
c#wpfkinect-sdk

Add a delay to MultiSourceFrameArrived of Kinect


I'm working in a project with Kinect, MS SDK 2, C# and WPF controls.

I setup the event handler MultiSourceFrameArrived method to read all frame types. According MS documentation, this runs when a frame arrives from the Kinect, and it is approximately at 30 FPS.

I want to restrict this running behavior (delay) in order to reduce the capture, for instance at 5 FPS, 10 FPS.

I try to use Task.Delay(ms) and Thread.Sleep(ms) (as in ). Sorry if this question would be stupid, but I couldn't resolve it yet.


Solution

  • Keep a Counter frameCount and maintain reduced fps by ignoring frames.

    static void msfr_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
    {
        frameCount++;
        if (frameCount % 6 != 0) return;
    
        //  Do whatever you want cause you are pirate ... :D
    }