none
how to store and keep skeleton data (access,read write...)? RRS feed

  • Question

  • hi kinect community guys,

    I have a question and I am sure somebody has faced this before. I will appreciate your suggestions.

    I am working with kinect's skeleton data (joint position information). kinect gives us information of 20 joints in each frame but I need to keep variable number of frames in memory (let's say 2000 frame) and then manipulate it, read and write on it, apply different algorithms on it.

    what is the best method in your idea to keep these frames information (consider simultaneous read/write, threads ..). what I found so far is Concurrency class and I want to add each frame into a concurrent vector or queue like:

    Concurrency::concurrent_vector<NUI_SKELETON_DATA> skeletonFrameQueue;

    skeletonFrameQueue.push_back(frameData);

    that is what I came up with but sometime I have runtime errors and program crashes and it is about heap.

    what do you think and what do you suggest about storing these data? is concurrent vectors ok? does they secure with threads? or what is other options ?

    thanks in advance for your suggestions.


    farhood

    Sunday, May 5, 2013 8:01 PM

All replies

  • Hi farhood,
    use threads ;)

    For new standard concurrency features in Visual C++ 11 read this article:
    http://msdn.microsoft.com/en-us/magazine/hh852594.aspx

    For performance tuning see the Concurrency Visualizer in Visual Studio. 
    Monday, May 6, 2013 8:25 PM
    Moderator
  • Hi Clemente,

    thank you for your useful links, specially the concurrency analyzer is a great tool that I learned to use it.

    but I should say that I already use threads. one I create for OpenGL and the others for Skeleton and depth tracking processes of the kinect.

    but I see lags and screen stutters, after using concurrency analyzer I think there are too many context switches.(I should mention that the only action about threads that I am doing is createThread and I am not doing anything about managing them).

    so I have something like this:

    if(handle)

    {

            if(Do initialization of opengl and kinect and start kinect color,depth and skeleton threads)

              {

                      showWindow(hWnd);

                     updateWindow(hWnd);

                    while (true)
                {
                    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
                    {
                        if (msg.message == WM_QUIT)
                            break;

                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                    }

                    if (msg.message == WM_QUIT)
                        break;

                    if (openglWindow_hasFocus)
                    {
                        UpdateFrame(GetElapsedTimeInSeconds());
                        RenderFrame();
                        SwapBuffers(g_hDC);
                    }
                    else
                    {
                        WaitMessage();
                    }
                }
            }

    }

    there is a point worth to mention that when I set a Sleep(1); at the end of the Got_skeleton() and Got_depth() threads most of the lags go away but I still have some. I thought maybe it helps synchronization. but more values of sleep like 10ms or 20ms doesn't work well. there must be a point here I miss.

    insights ?


    farhood

    Friday, May 10, 2013 12:07 PM