none
Multiple concurrent Frame Readers RRS feed

  • Question

  • Hello,

    I am using the Kinect V2 C++ SDK, and I am just wondering what is the best way to go about this problem. Suppose I have 2 classes C1 and C2. I am passing the same instance of IKinectSensor to them, such as follows:

    IKinectSensor *kSensor;
    GetDefaultKinectSensor(&kSensor);
    C1 instance1(kSensor);
    C2 instance2(kSensor);

    And let's also suppose that these two classes will process IBodyFrame objects from the same sensor, not necessarily at the same rate.

    The thing is that I will be processing frames concurrently, and this involves acquiring frames, and releasing them. Does IKinectSensor supports concurrent frame readers?

    Friday, May 15, 2015 3:41 PM

All replies

  • In my experience working with C# and Unity you can make as many concurrent frame readers as you like running at the same time, so there is no reason you shouldn't be able to in C++.

    However there are some important things to keep in mind. If you are simply reading the same source frame twice then that would be a waste of resources. Generally you should try and find a way to have one class that reads the frame and have the rest of your program read from that same source.

    But there are times when you need to use multiple reader (like with Audio) and the Kinect V2 SDK was developed with that in mind.

    There can be also issues where if the processing of one class "locks up" the processing for an extended period of time the other class may miss the chance to read a frame. But you could use multithreading to avoid that, which is where you have an advantage by using C++.

    Friday, May 15, 2015 7:49 PM
  • Thanks for the reply,

    It took me a little bit more time, but I ended up doing something similar to what you said.

    I have one class processing incoming frames, as they arrive (let's call it class A). I do it in a single thread.

    All the other threads will subscribe to class A, and they will  get the body information from there. I used the Observer pattern for this. It is running really well, and I can have as many subscribers as I want, working at their own frame rate.

    Tuesday, May 19, 2015 9:24 PM