none
FaceTrackingVisualization SingleFace sample - events fix required RRS feed

  • Question

  • Hi,

    after taking a closer look at the (C++/GDI sample) Face Tracking Visualization I noticed a possible bug in the event handling. This might be interesting for others too when building apps based on this sample.

    The events in the "KinectSensor.cpp" never get reset although set to manual reset! The events (m_hNextDepthFrameEvent, m_hNextVideoFrameEvent & m_hNextSkeletonEvent) are created with the flag bManualReset set TRUE in KinectSensor::Init(). The KinectSensor::ProcessThread() waits for one of the events to happen, but never resets the events. So what happens here is that there is no wait at all! The frames get copied all the time since all events remain in a signaled state.

    So to properly wait for the events, the while loop should look something like this:

        while (true)
        {
            // Wait for an event to be signaled
            WaitForMultipleObjects(sizeof(hEvents)/sizeof(hEvents[0]),hEvents,FALSE,100);
    
            // If the stop event is set, stop looping and exit
            if (WAIT_OBJECT_0 == WaitForSingleObject(pthis->m_hEvNuiProcessStop, 0))
            {
                break;
            }
    
            // Process signal events
            if (WAIT_OBJECT_0 == WaitForSingleObject(pthis->m_hNextDepthFrameEvent, 0))
            {
                pthis->GotDepthAlert();
                pthis->m_FramesTotal++;
                ResetEvent(pthis->m_hNextDepthFrameEvent); //ADD!
            }
            if (WAIT_OBJECT_0 == WaitForSingleObject(pthis->m_hNextVideoFrameEvent, 0))
            {
                pthis->GotVideoAlert();
                ResetEvent(pthis->m_hNextVideoFrameEvent); //ADD!
            }
            if (WAIT_OBJECT_0 == WaitForSingleObject(pthis->m_hNextSkeletonEvent, 0))
            {
                pthis->GotSkeletonAlert();
                pthis->m_SkeletonTotal++;
                ResetEvent(pthis->m_hNextSkeletonEvent); //ADD!
            }
        }


    • Edited by Xcessity Friday, June 28, 2013 9:32 AM
    Friday, June 28, 2013 9:31 AM

All replies