none
Multthread Kinect v2 acquisition+processing+data_transfer RRS feed

  • Question

  • Dear all,

    I am trying to refactor some "realtime" code developed for the good ol' Kinect V2 (sadly RIP), where basically I do almost everything in the Reader_FrameArrived() method. I'd like instead to divide into four separated threads
    a) data acquisition from the sensor
    b) data processing (filtering, etc.)
    c) transfer of the processing results to a biofeedback module (developed in Unreal Engine)
    d) plotting of the incoming and processed signals (if required by the user).

    Now the question is: what kind of data strucutre should I use to pass the information from one thread to the others ? I have been thinking about lists or fifo, but I fear that the Garbage Collector activities could easily make the application less smooth. On the other side, I am not aware of any efficient and thread safe approach using circular arrays...

    Any hints welcome!



    Tuesday, April 3, 2018 1:54 PM

All replies

  • Hello paolo,

    >>what kind of data strucutre should I use to pass the information from one thread to the others ?

    For communicating between threads, I suggest you could use MSMQ (Microsoft Message Queue), you need to start service first and then you could access to a queue by MessageQueue class.

    Installing Message Queuing (MSMQ)

    MessageQueue Class

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 4, 2018 2:34 AM
    Moderator
  • Thanks Neil for your answer. A couple of questions more:

    1) Would it be possible to wake up the threads only when new data are available?

    2) using the MSMQ, how could try to keep the GC activities "low", in order to avoid "freezing" of the two most important thread (acquisition and transfer) ? Should I fire programmatically and cyclically GC ?

    BR

    Paolo

    Wednesday, April 4, 2018 9:09 AM
  • Hello paolo,

    How many data and which type data would you want to pass? If the data is small and type is single, you can use global variables instead, which is easy to debug and good to manage.

    >>Would it be possible to wake up the threads only when new data are available?

    Yes, the message queue just care data usage and if you want to control multi threads you need to use thread synchronization, I'm not clear with your specific situation and you need to choose one option.

    >>using the MSMQ, how could try to keep the GC activities "low", in order to avoid "freezing" of the two most important thread (acquisition and transfer) ? Should I fire programmatically and cyclically GC

    GC start time depend on CLR inner algorithm, the purpose of which is to recycle useless data(no reference data) to keep memory enough. In other words, Garbage Collection just release memory. although the CLR will hang some threads when GC starts to work, you shouldn't care about this because GC optimizing engine determines the best time to perform.

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 5, 2018 6:01 AM
    Moderator