Kinect for windows 破解 一,简单的体感超级玛丽

背景知识

1.  游戏模拟器:现在有很多模拟器,让我们可以在PC上玩红白机,PS上的游戏。本破解用的FC 红白机模拟器。网上有很多地方可以下载。注意语言要和你的操作系统一致。

2.  按键模拟器:本破解是通过发送快捷键来模拟游戏操作的。所以需要有一个游戏模拟器。你可以自己写一个,也可以网上找一个。

3.  对比数据:人体动作变化需要有一个基础的对比数据,即正常情况下,人体各关节所处深度和位置。在之后的关节跟踪时,才能知道关节是向什么方向移动了。

4.  基本原理:通过手势启动kinect控制,记录对比数据。然后根据每帧传过来的数据,判断关节移动到了什么位置。比如,如果判断双手位置均高过对比数据中的头顶的高度(即双手举起),则程序判断为开始,并采用按键模拟器向游戏模拟器发出‘开始’的快捷键‘空格’的按下指令。

5.  完整代码下载链接:http://download.csdn.net/detail/u011591115/6012271

6.  注意:本破解只是非常简单的关节静态跟踪。此路绝非正途,仅为一趣。

 

代码演示

各种指令对应的姿势。

1.  启动:双手前臂在胸前摆出X姿态。

 

        // Gesture to start controlling

        privatebool StartControlling()

        {

            bool isHighXToStart =true;

            isHighXToStart =isHighXToStart && JointPostions[JointType.HandLeft].X > JointPostions[JointType.Spine].X;

            isHighXToStart =isHighXToStart && JointPostions[JointType.HandLeft].Y < JointPostions[JointType.Spine].Y;

            isHighXToStart =isHighXToStart && JointPostions[JointType.HandRight].X < JointPostions[JointType.Spine].X;

            isHighXToStart =isHighXToStart && JointPostions[JointType.HandRight].Y < JointPostions[JointType.Spine].Y;

            bool isStarting = IsStandGesture() && isHighXToStart;

            if (isStarting && !isControlling)

            {

               JointBasePostions.Clear();

                foreach(KeyValuePair<JointType,Point> jointin JointPostions)

                {

                   JointBasePostions.Add(joint.Key, joint.Value);

                }

            }

            return isStarting;

    }

 

2.  开始暂停:双手举国头顶

 

        // Gesture to start controlling

        privatebool IsStart()

        {

            bool isHighXToStart =true;

            isHighXToStart =isHighXToStart && JointPostions[JointType.HandLeft].Y < JointBasePostions[JointType.Head].Y;

            isHighXToStart =isHighXToStart && JointPostions[JointType.HandRight].Y < JointBasePostions[JointType.Head].Y;

 

            return IsStandGesture() &&isHighXToStart;

  }

 

3.  向前向后:左右手举起

 

        // Gesture to go forward

        privatebool IsGoForward()

        {

            bool isRightHandUp =true;

            isRightHandUp =isRightHandUp && JointPostions[JointType.HandRight].Y > JointPostions[JointType.Spine].Y;

            isRightHandUp =isRightHandUp && JointPostions[JointType.HandRight].X >

                (JointPostions[JointType.ShoulderRight].X + (JointBasePostions[JointType.HipRight].X - JointBasePostions[JointType.HipLeft].X));

            return IsStandGesture() &&isRightHandUp;

 }

 

4.  跳起:双腿离地一段距离(事实证明,这个挺累的,改成单腿好得多。)

        // Gesture tojump

        privatebool IsJump()

        {

            bool isJump =true;

            double height = JointBasePostions[JointType.Spine].Y - JointBasePostions[JointType.HipCenter].Y;

            isJump = isJump&& JointPostions[JointType.FootLeft].Y< JointBasePostions[JointType.FootLeft].Y +height;

            isJump = isJump&& JointPostions[JointType.FootRight].Y< JointBasePostions[JointType.FootRight].Y +height;

            return isJump;

 }

 

效果演示

 

原文地址:https://www.cnblogs.com/keanuyaoo/p/3283601.html