2013-03-21 35 views
1

我目前正在爲學校開發一個項目,該項目需要我使用Kinect硬件創建某個軟件。該軟件與有氧運動/運動「遊戲」密切相關。但是,因爲我從來沒有爲Kinect工作過,所以對於從哪裏開始,我有點無知。我已經下載了SDK和Toolkit瀏覽器,以及一些(非官方的)工具包。跟蹤和比較骷髏與預定義骨架

我在Java編程方面有一些經驗,但不知道如何使用C/C++/C#和Visual Studio。

我基本上在尋找可以幫助我更好地瞭解Kinect以及它如何編程的教程。我試着尋找一些,但他們或者過時了,或者真的很混亂,我無法跟上他們。

我在這個項目中的主要目標是弄清楚當一個活骨架的雙臂高於頭部並且他們靠近他的身體時(跳躍式千斤頂鍛鍊),我該如何看到它。

任何人都可以通過幾個鏈接或例子幫助我沿着正確的方向嗎?

回答

2

C#在概念上與Java不太一樣。微軟甚至在這方面有在線幫助:The C# Programming Language for Java Developers。雖然我建議找一本不會在另一種語言環境中打包C#的好書 - 學習C#,而不是「與C#相關的Java」。

學習Kinect的開發應該通過工具包的例子來完成。真的沒有更好的辦法。 請注意在線教程!許多是爲不再兼容的較舊版本的SDK編寫的。任何爲SDK < 1.5編寫的東西都將無法正常工作,無需移植它。

可以通過手勢識別來檢測跳轉千斤頂。在那裏有幾個庫爲官方的微軟Kinect SDK提供了這個功能 - 我通常指的是Kinect ToolboxFizbin Gesture Library。兩者都提供手勢識別,只是使用不同的方法。

對於Fizbin手勢庫,您可以聲明一系列定義手勢構造方式的類。例如,這裏是圖書館如何界定刷卡左手朝身體的右側:

namespace Fizbin.Kinect.Gestures.Segments 
{ 
    /// <summary> 
    /// The first part of the swipe right gesture 
    /// </summary> 
    public class SwipeRightSegment1 : IRelativeGestureSegment 
    { 
     /// <summary> 
     /// Checks the gesture. 
     /// </summary> 
     /// <param name="skeleton">The skeleton.</param> 
     /// <returns>GesturePartResult based on if the gesture part has been completed</returns> 
     public GesturePartResult CheckGesture(Skeleton skeleton) 
     { 
      // left hand in front of left Shoulder 
      if (skeleton.Joints[JointType.HandLeft].Position.Z < skeleton.Joints[JointType.ElbowLeft].Position.Z && skeleton.Joints[JointType.HandRight].Position.Y < skeleton.Joints[JointType.HipCenter].Position.Y) 
      { 
       // left hand below shoulder height but above hip height 
       if (skeleton.Joints[JointType.HandLeft].Position.Y < skeleton.Joints[JointType.Head].Position.Y && skeleton.Joints[JointType.HandLeft].Position.Y > skeleton.Joints[JointType.HipCenter].Position.Y) 
       { 
        // left hand left of left Shoulder 
        if (skeleton.Joints[JointType.HandLeft].Position.X < skeleton.Joints[JointType.ShoulderLeft].Position.X) 
        { 
         return GesturePartResult.Succeed; 
        } 

        return GesturePartResult.Pausing; 
       } 

       return GesturePartResult.Fail; 
      } 

      return GesturePartResult.Fail; 
     } 
    } 

    /// <summary> 
    /// The second part of the swipe right gesture 
    /// </summary> 
    public class SwipeRightSegment2 : IRelativeGestureSegment 
    { 
     /// <summary> 
     /// Checks the gesture. 
     /// </summary> 
     /// <param name="skeleton">The skeleton.</param> 
     /// <returns>GesturePartResult based on if the gesture part has been completed</returns> 
     public GesturePartResult CheckGesture(Skeleton skeleton) 
     { 
      // left hand in front of left Shoulder 
      if (skeleton.Joints[JointType.HandLeft].Position.Z < skeleton.Joints[JointType.ElbowLeft].Position.Z && skeleton.Joints[JointType.HandRight].Position.Y < skeleton.Joints[JointType.HipCenter].Position.Y) 
      { 
       // left hand below shoulder height but above hip height 
       if (skeleton.Joints[JointType.HandLeft].Position.Y < skeleton.Joints[JointType.Head].Position.Y && skeleton.Joints[JointType.HandLeft].Position.Y > skeleton.Joints[JointType.HipCenter].Position.Y) 
       { 
        // left hand left of left Shoulder 
        if (skeleton.Joints[JointType.HandLeft].Position.X < skeleton.Joints[JointType.ShoulderRight].Position.X && skeleton.Joints[JointType.HandLeft].Position.X > skeleton.Joints[JointType.ShoulderLeft].Position.X) 
        { 
         return GesturePartResult.Succeed; 
        } 

        return GesturePartResult.Pausing; 
       } 

       return GesturePartResult.Fail; 
      } 

      return GesturePartResult.Fail; 
     } 
    } 

    /// <summary> 
    /// The third part of the swipe right gesture 
    /// </summary> 
    public class SwipeRightSegment3 : IRelativeGestureSegment 
    { 
     /// <summary> 
     /// Checks the gesture. 
     /// </summary> 
     /// <param name="skeleton">The skeleton.</param> 
     /// <returns>GesturePartResult based on if the gesture part has been completed</returns> 
     public GesturePartResult CheckGesture(Skeleton skeleton) 
     { 
      // //left hand in front of left Shoulder 
      if (skeleton.Joints[JointType.HandLeft].Position.Z < skeleton.Joints[JointType.ElbowLeft].Position.Z && skeleton.Joints[JointType.HandRight].Position.Y < skeleton.Joints[JointType.HipCenter].Position.Y) 
      { 
       // left hand below shoulder height but above hip height 
       if (skeleton.Joints[JointType.HandLeft].Position.Y < skeleton.Joints[JointType.Head].Position.Y && skeleton.Joints[JointType.HandLeft].Position.Y > skeleton.Joints[JointType.HipCenter].Position.Y) 
       { 
        // left hand left of left Shoulder 
        if (skeleton.Joints[JointType.HandLeft].Position.X > skeleton.Joints[JointType.ShoulderRight].Position.X) 
        { 
         return GesturePartResult.Succeed; 
        } 

        return GesturePartResult.Pausing; 
       } 

       return GesturePartResult.Fail; 
      } 

      return GesturePartResult.Fail; 
     } 
    } 
} 

您可以按照代碼中的註釋來看看如何將手穿過身體的移動。

對於跳躍式千斤頂,您可以定義相對於上下一系列關節的手,然後下降。如果我要趕緊吐出了一系列的檢查,他們是:

  1. 左/右手下方髖中心
  2. 左/右手髖部以上的中心&左/右手留在外面/右肘
  3. 左/右手上述脊柱&左/右手外左/右肘關節
  4. 左/右手上述左/右肩&左/右手左/右肘關節
  5. 左/右手以外上述頭

......如果所有這些匹配,你有半跳躍傑克。在相同的Gesture下進行相反的所有檢查,並且您有一個完整的上半身跳轉插孔。您可以添加腿部位置以獲得全身跳躍式插孔。

Kinect工具箱也可以用來定義手勢。我沒有親自使用它,所以我不能說涉及的步驟。