Question

valg2017 on Tue, 26 Sep 2017 19:23:57


Hi there--

Does anyone have insight on the TrackingIdLost event?

I've discovered that the TrackingIdLost event for my VGB gesture project is failing to fire when a user leaves the area. (To be clear, all gestures are being recognized correctly & bodyFrames have their tracking ids, the issue is that event does not firing when a user leaves the tracked area.)

I checked out the "Discrete Gesture Basics-WPF" sample from the Kinect SDK Browser and examined its implementation of handling the TrackingIdLost event & discovered that while the event fires in that sampe,  the associated trackingId is always zero

I logged out the event as follows 

(Code snippets below are from Discrete Gesture Basics-WPF project via Kinect SDK Browser):

In GestureDetector.cs:

private void Source_TrackingIdLost(object sender, TrackingIdLostEventArgs e)
{

    String timestamp = DateTime.Now.ToString();

    Console.WriteLine("\n\n####\n\n" + Convert.ToString(e.TrackingId) + "\n\n####\n\n"); // <<=== Always zero
    // update the GestureResultView object to show the 'Not Tracked' image in the UI
    this.GestureResultView.UpdateGestureResult(false, false, 0.0f);
}


In MainWindow.xaml.cs:

private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e)
{
 //...

 if (dataReceived)
{
    // visualize the new body data
    this.kinectBodyView.UpdateBodyFrame(this.bodies);

    // we may have lost/acquired bodies, so update the corresponding gesture detectors
    if (this.bodies != null)
    {
        // loop through all bodies to see if any of the gesture detectors need to be updated
        int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
        for (int i = 0; i < maxBodies; ++i)
        {
            Body body = this.bodies[i];
            ulong trackingId = body.TrackingId;

            // if the current body TrackingId changed, update the corresponding gesture detector with the new value
            if (trackingId != this.gestureDetectorList[i].TrackingId)
            {
                Console.WriteLine("## OLD:" + this.gestureDetectorList[i].TrackingId);
                Console.WriteLine("## NEW (BodyEvent):" + trackingId);
                this.gestureDetectorList[i].TrackingId = trackingId;

                // if the current body is tracked, unpause its detector to get VisualGestureBuilderFrameArrived events
                // if the current body is not tracked, pause its detector so we don't waste resources trying to get invalid gesture results
                this.gestureDetectorList[i].IsPaused = trackingId == 0;
            }
        }
    }
}



I've got two bodies tracked and then one body exits the scene then returns and my debug output is as follows:

// Two bodies get tracking ids, all makes sense

## OLD:0
## NEW (BodyEvent):72057594037935770
## OLD:0
## NEW (BodyEvent):72057594037936562

// One body exits, gets set to 0
## OLD:72057594037936562
## NEW (BodyEvent):0


// TrackingIdLost fires, but associated ID is zero
####

0

####


// User comes back into frame, gets a trackingId
## OLD:0
## NEW (BodyEvent):72057594037936608


-----

Questions/confusion:

1. When does trackingIdLost event to fire? (Is it when it gets set to zero from a previously non-zero value?) The docs state it  "Occurs when the tracking ID of the Visual Gesture Builder frame source is lost." Does "lost" mean it went from a non-zero value to zero?

2. Does the trackingId from TrackingIdLostEventArgs correspond to the previous non-zero trackingId?

3. Has anyone else encountered an issue where trackingId lost won't fire?


Many thanks for any insights