【问题标题】:Creating a gesture definition for a simple static gesture using Kinect使用 Kinect 为简单的静态手势创建手势定义
【发布时间】:2012-02-22 01:18:08
【问题描述】:

我在 C# 中使用 Kinect SDK 和 WPF 创建了一个 Kinect 应用程序。

我想创建一个简单的静态手势识别方法,当用户在运行时将他们的“右手”(JointID.HandRight) 关节举过他们的“头”(JointID.Head) 关节时输出一个消息框。

我知道我需要为这个手势创建一个定义,并在每次触发 SkeletonFrameReady 事件时对骨架运行它。有没有人可以帮助我或指出我需要存储/比较哪些骨架数据的正确方向,我将非常感激,谢谢。

【问题讨论】:

    标签: c# wpf kinect gesture-recognition


    【解决方案1】:

    我认为你必须在每轮线程中将右手的初始位置与右手的当前位置进行比较。例如,如果要查看右手是否举起,则必须比较 x 和 y 位置。我希望我已经理解了你的问题。对不起我的英语!

    【讨论】:

      【解决方案2】:

      在 MS SDK V1 中,您必须使用 JointType 而不是 JointID。这是一个非常简单的示例。

      //this event fires when Color/Depth/Skeleton are synchronized
      void newSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
      {
          //Get a skeleton
          Skeleton skeleton = GetFirstSkeleton(e);
      
          if (skeleton == null)
          {
              return;
          }
          else if (skeleton != null)
          {
              checkHand(skeleton.Joints[JointType.Head], skeleton.Joints[JointType.HandRight], skeleton.Joints[JointType.HandLeft]);
          }
      }
      
      Skeleton GetFirstSkeleton(AllFramesReadyEventArgs e)
      {
          using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame())
          {
              if (skeletonFrameData == null)
              {
                  return null;
              }
      
              skeletonFrameData.CopySkeletonDataTo(allSkeletons);
      
              //get the first tracked skeleton
              Skeleton first = (from s in allSkeletons
                                  where s.TrackingState == SkeletonTrackingState.Tracked
                                  select s).FirstOrDefault();
      
              return first;
          }
      }
      
      public void checkHand(Joint head, Joint rhand, Joint lhand)
      {
          if (rhand.Position.Y > head.Position.Y)
          {
              MessageBox.Show("Right hand up!");
          }
          else if (lhand.Position.Y > head.Position.Y)
          {
              MessageBox.Show("Left hand up!");
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多