c# - 从 .xef 文件离线检测视觉手势

标签 c# kinect gestures

我正在尝试合并 DiscreteGestureBasics提供了kinect sdk工具和RecordAndPlaybackBasics的项目. RecordAndPlaybackBasics 代码有两种主要方法播放 .xef 文件和记录 .xef。我想读取一个 .xef 文件并使用 DiscreteGestureBasics 中的代码评估手势。在 DiscreteGestureBasics 中,我使用来自 RecordAndPlaybackBasics 的代码输入播放 .xef 文件的功能。 .播放文件的代码如下:

 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));
    }

我尝试在 playbackClip 函数中添加 GestureDetector.cs(来自 DiscreteGestureBasics 的脚本)的代码。我添加了一个具有播放功能的按钮,因此当我按下按钮时,一个 .xef 文件开始播放。 xef 正常显示,但检测器的置信度分数始终为零。在 GestureDetector.cs 的以下代码中,scirpt discreteResults 始终为 null。知道这里有什么问题吗?

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.
    {
    }
 } 
}

gestureDetector的初始化可以在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;
    ... 
    }

此外,当我从播放功能运行 VgbView.exe 时 System.Diagnostics.Process.Start("VgbView.exe");观众通常评估手势。为什么在我的情况下我无法访问 ContinuousGestureResults ?在周末我改变了一些东西并且我在我的范围内取得了成功(计算 .xef 的重复)但现在我不记得我改变了什么(并且无意中取消了改变)。为什么 IReadOnlyDictionary<Gesture, ContinuousGestureResult> discreteResults = frame.ContinuousGestureResults; Gesture 和 ContinuousGestureResult 一直为空?对于我收到的每一帧的更多信息,以下方法 IsTrackingIdValid 始终为 false。

最佳答案

“要使用 VGB,您必须拥有至少包含骨架和深度信息的扩展事件文件 (XEF)。有关记录和查看扩展事件文件 (XEF) 的信息,请参阅 Kinect Studio。” Visual Gesture Bilder (MSDN)

所以你已经添加到你的记录骨架和深度信息如下:

   KStudioEventStreamSelectorCollection streamCollection = new KStudioEventStreamSelectorCollection();
   streamCollection.Add(KStudioEventStreamDataTypeIds.Depth);
   streamCollection.Add(KStudioEventStreamDataTypeIds.Body);
   streamCollection.Add(KStudioEventStreamDataTypeIds.BodyIndex);

关于c# - 从 .xef 文件离线检测视觉手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32967863/

相关文章:

ios - 单点触控 : How to add a two finger gesture recognizer to UIPageViewController?

windows-phone-7 - 如何以编程方式切换到不同的 PanoramaItem?

c# - 隐藏 Id 属性时自定义 IdentityRole<TKey, TUserRole> 失败

c# - IComparable 和 Equals()

c# - 编程 "Lean left and Lean right"- Kinect 中的手势

jquery - 允许使用 jQuery.Wipetouch 进​​行捏合缩放

c# - 在有或没有下一代加密技术 (CNG) 的情况下使用 ECDiffieHellman

c# - 从非托管 dll 文件调用托管 dll(注入(inject)正在运行的进程)

machine-learning - 我可以使用 Kinect 的深度图像重新训练 Inception 的最终层吗?

kinect - 将保存的运动与使用Kinect的其他运动进行比较