【问题标题】:Tracking and comparing Skeletons with pre-defined Skeleton跟踪和比较骨架与预定义的骨架
【发布时间】:2013-03-21 15:42:29
【问题描述】:

我目前正在为学校开展一个项目,该项目需要我使用 Kinect 硬件创建某个软件。该软件与有氧运动/锻炼“游戏”密切相关。

但是,由于我从来没有为 Kinect 工作过,所以我不知道从哪里开始。我已经下载了 SDK 和 Toolkit 浏览器,以及一些(非官方?)Toolkit。

我有一些 Java 编程经验,但不知道如何使用 C/C++/C# 或 Visual Studio。

我基本上是在寻找可以帮助我更多地了解 Kinect 及其编程工作原理的教程。我试着找了一些,但它们要么已经过时,要么真的很混乱,以至于我跟不上它们。

我在该项目中的主要目标是弄清楚我如何能看到一个活生生的骷髅何时将双臂举过头顶以及何时靠近他的身体(跳千斤顶练习)。

谁能通过一些链接或示例帮助我朝着正确的方向前进?

【问题讨论】:

    标签: windows kinect xbox360


    【解决方案1】:

    C# 在概念上与 Java 并没有太大的不同。微软甚至有关于这个主题的在线帮助:The C# Programming Language for Java Developers。虽然我建议找一本不将 C# 包装在另一种语言的上下文中的好书——学习 C#,而不是“与 Java 相关的 C#”。

    学习 Kinect 开发应该通过 Toolkit 示例来完成。真的没有更好的办法了。 注意在线教程!许多是为不再兼容的旧版本 SDK 编写的。为 SDK

    可以通过手势识别来检测跳跃杰克。有一些库可以为官方的 Microsoft 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;
            }
        }
    }
    

    您可以按照代码中的 cmets 来查看手是如何在身体上移动的。

    在您的跳跃千斤顶的情况下,您可以定义相对于一系列关节的手,在上升过程中,然后在下降过程中。如果我要快速吐出一系列检查,它们会是:

    1. 左/右手低于臀部中心
    2. 左/右手在臀部中心上方和左/右手在左/右肘之外
    3. 左/右手在脊柱上方和左/右手在左/右肘之外
    4. 左/右手在左/右肩上方和左/右手在左/右肘外侧
    5. 左/右手在头顶

    ...如果所有这些都匹配,您就有了半个跳跃式千斤顶。在同一个Gesture 下反向执行所有检查,您就有了一个完整的上身跳跃式千斤顶。您可以添加腿部位置以获得全身跳跃式千斤顶。

    Kinect 工具箱也可用于定义手势。我只是没有亲自使用它,所以我无法说出所涉及的步骤。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-14
      • 1970-01-01
      • 2011-03-27
      相关资源
      最近更新 更多