Detect visual gestures offline from .xef files
Asked Answered
A

1

7

I am trying to combine DiscreteGestureBasics project which provided with the kinect sdk tool and with RecordAndPlaybackBasics. RecordAndPlaybackBasics code has two main methods playback a .xef file and record a .xef. I want to read a .xef file and evaluate the gestures using the code from DiscreteGestureBasics. In DiscreteGestureBasics I enter functionality for playback .xef files using the code from RecordAndPlaybackBasics. The code for playback file is the following:

 private void PlaybackClip(string filePath)
    {
        using (KStudioClient client = KStudio.CreateClient())
        {
            client.ConnectToService();         
            using (KStudioPlayback playback = client.CreatePlayback(filePath))
            {
                playback.LoopCount = this.loopCount;
                playback.Start();
                while (playback.State == KStudioPlaybackState.Playing)
                {

                    Thread.Sleep(100);
                }
            }
            client.DisconnectFromService();
        }

        // Update the UI after the background playback task has completed
        this.isPlaying = false;
        this.Dispatcher.BeginInvoke(new NoArgDelegate(UpdateState));
    }

I tried to add the code of GestureDetector.cs (script from DiscreteGestureBasics) inside the playbackClip function. I add a button with the playback function thus when I press the button a .xef file is begin to play. The xef is visualised normally, however the confidence score of detector is constantly zero. In the following code from GestureDetector.cs scirpt discreteResults is always null. Any idea what could it be wrong here?

VisualGestureBuilderFrameReference frameReference = e.FrameReference;
using (VisualGestureBuilderFrame frame =frameReference.AcquireFrame())
{// frame return always null
 if (frame != null)
 {
    IReadOnlyDictionary<Gesture, ContinuousGestureResult> discreteResults = frame.ContinuousGestureResults;
    if (discreteResults != null) //discreteResults  is always null.
    {
    }
 } 
}

The initialization of gestureDetector could be found in MainWindow():

     int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount;
     for (int i = 0; i < maxBodies; ++i)
     {
            GestureResultView result = new GestureResultView(i, false, false, 0.0f);
            GestureDetector detector = new GestureDetector(this.kinectSensor, result);
            this.gestureDetectorList.Add(detector);

            ContentControl contentControl = new ContentControl();
            contentControl.Content = this.gestureDetectorList[i].GestureResultView;
    ... 
    }

Moreover when I run VgbView.exe from PlayBack function System.Diagnostics.Process.Start("VgbView.exe"); the viewer evaluate normally the gesture. Why in my case I cant access ContinuousGestureResults? Inside weekend I change something and I succeed in my scope (in counting repetition from .xef) but now I don't remember what I have changed (and unintenionally cancel the change). Why IReadOnlyDictionary<Gesture, ContinuousGestureResult> discreteResults = frame.ContinuousGestureResults; Gesture and ContinuousGestureResult is constantly null? More for every frame I am receiving the following method IsTrackingIdValid is constantly false.

Arbitrate answered 6/10, 2015 at 10:38 Comment(0)
U
-1

"To use VGB, you must have eXtended event file (XEF) files that contain, at the least, skeleton and depth information. For information about recording and viewing an eXtended event file (XEF), see Kinect Studio." Visual Gesture Bilder (MSDN)

So u have added to your record skeleton and depth information like this:

   KStudioEventStreamSelectorCollection streamCollection = new KStudioEventStreamSelectorCollection();
   streamCollection.Add(KStudioEventStreamDataTypeIds.Depth);
   streamCollection.Add(KStudioEventStreamDataTypeIds.Body);
   streamCollection.Add(KStudioEventStreamDataTypeIds.BodyIndex);
Untaught answered 9/10, 2015 at 9:26 Comment(2)
Yes off-course I have .xef stored. Recording function (from RecordAndPlaybackBasics is working like a charm). My problem is that when I play the playback file I cant evaluate it with the gestureDetector. It seems that I got a null gestureFrame. The information from xef file is fine.Arbitrate
I think my problems located in trackingId feature. Maybe I don't compare properly trackingId.Arbitrate

© 2022 - 2024 — McMap. All rights reserved.