当前位置: 首页>>代码示例>>C#>>正文


C# Skeleton.First方法代码示例

本文整理汇总了C#中Microsoft.Kinect.Skeleton.First方法的典型用法代码示例。如果您正苦于以下问题:C# Skeleton.First方法的具体用法?C# Skeleton.First怎么用?C# Skeleton.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Kinect.Skeleton的用法示例。


在下文中一共展示了Skeleton.First方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GestureRecognition

        private void GestureRecognition(Skeleton[] skeletons)
        {
            if (skeletons.Count(t => t.TrackingState == SkeletonTrackingState.Tracked) >= 1)
            {
                Skeleton skel = skeletons.First(s => s.TrackingState == SkeletonTrackingState.Tracked);
                Joint handRight = skel.Joints[JointType.HandRight];
                Joint hipRight = skel.Joints[JointType.HipRight];
                Joint spine = skel.Joints[JointType.Spine];

                innerRect = GetInnerRect(skel);
                outerRect = GetOuterRect(innerRect);
                TransformRectangles();
                TransformHand();
                handRightPoint = SkeletonPointToScreen(handRight.Position);

                isInRect = innerRect.Contains(handRightPoint);

                isInInnerRect = innerRect.Contains(handRightPoint);
                isInOuterRect = outerRect.Contains(handRightPoint);

                // Inneres Rechteck wurde betreten oder verlassen
                if(isInInnerRect != wasInLastFrameInInnerRect)
                {
                    // Inneres Rechteck wurde betreten
                    if (isInInnerRect)
                    {
                        // Fade-out: Save timestamp when enter the inner rect
                        enterInnerRectTimestamp = getTimeStamp();
                        wasInInnerRect = true;
                    }
                    // Inneres Rechteck wurde verlassen
                    else
                    {
                        // Fade-out: Stop animation
                        //if ()
                        if (handRightPoint.X > innerRect.TopRight.X) //leave right
                        {
                            BackColor.Fill = NextColor();
                        }
                        else if (handRightPoint.X < innerRect.TopLeft.X) //leave left
                        {
                            BackColor.Fill = PrevColor();
                        }
                        else if (handRightPoint.Y > innerRect.BottomLeft.Y) //leave bottom
                        {
                            BackColor.Fill = NextColorBlock();
                        }
                        else if (handRightPoint.Y < innerRect.TopLeft.Y) //leave top
                        {
                            BackColor.Fill = PrevColorBlock();
                        }
                    }
                    wasInLastFrameInInnerRect = isInInnerRect;
                }

                // Aeusseres Rechteck wurde betreten oder verlassen
                if (isInOuterRect != wasInLastFrameInOuterRect)
                {
                    // Aeusseres Rechteck wurde betreten
                    if (isInOuterRect)
                    {
                    }
                    // Aeusseres Rechteck wurde verlassen
                    else
                    {
                        if (wasInInnerRect)
                        {
                            if (handRightPoint.X > outerRect.TopRight.X) //leave right
                            {
                                SwipeRight();
                            }
                            else if (handRightPoint.X < outerRect.TopLeft.X) //leave left
                            {
                                SwipeLeft();
                            }
                            else if (handRightPoint.Y > outerRect.BottomLeft.Y) //leave bottom
                            {
                                SwipeDown();
                            }
                            else if (handRightPoint.Y < outerRect.TopLeft.Y) //leave top
                            {
                                SwipeUp();
                            }
                            wasInInnerRect = false;
                            FrontColor.Fill = CurrentColor();
                            TransformFrontColor(0, 0);
                        }
                    }
                }
                wasInLastFrameInOuterRect = isInOuterRect;

                if (isInOuterRect && !isInInnerRect && wasInInnerRect)
                {
                    double swipeLeft = GetPercentageSwipeLeft(handRightPoint);
                    double swipeRight = GetPercentageSwipeRight(handRightPoint);
                    double swipeTop = GetPercentageSwipeTop(handRightPoint);
                    double swipeBottom = GetPercentageSwipeBottom(handRightPoint);
                    if(swipeLeft >= 0)
                    {
                        TransformFrontColor(-swipeLeft, 0);
//.........这里部分代码省略.........
开发者ID:rechc,项目名称:KinectMiniApps,代码行数:101,代码来源:SwipeRectangleMain.xaml.cs

示例2: FindSkeleton

 private Skeleton FindSkeleton()
 {
     var skeletonData = kinectSensor.SkeletonStream.OpenNextFrame(200);
     if (skeletonData != null)
     {
         Skeleton[] skeletons = new Skeleton[skeletonData.SkeletonArrayLength];
         skeletonData.CopySkeletonDataTo(skeletons);
         return skeletons.First();
     }
     return null;
 }
开发者ID:mhope,项目名称:oliviatrellocontrol,代码行数:11,代码来源:MainWindow.xaml.cs

示例3: GestureRecognition

        private void GestureRecognition(Skeleton[] skeletons)
        {
            if (skeletons.Count(t => t.TrackingState == SkeletonTrackingState.Tracked) >= 1)
            {
                Skeleton skel = skeletons.First(s => s.TrackingState == SkeletonTrackingState.Tracked);
                Joint handRight = skel.Joints[JointType.HandRight];
                Joint hipRight = skel.Joints[JointType.HipRight];
                Joint spine = skel.Joints[JointType.Spine];

                startRect = GetGestureRect(skel);
                TransformRectangle();
                handRightPoint = SkeletonPointToScreen(handRight.Position);

                isInRect = startRect.Contains(SkeletonPointToScreen(handRight.Position));
                if (isInRect != isInRectLastFrame)
                {
                    if (isInRect)
                    {
                        Hand.Visibility = Visibility.Hidden;
                        lockElement.Show();
                        entryPoint = handRight.Position;
                        isInGestureRect = true;
                    }
                    else
                    {
                        if(handRightPoint.X > startRect.TopRight.X) //leave right
                        {
                            HandleRectLeave();
                        }
                        else if (handRightPoint.Y > startRect.BottomLeft.Y) //leave bottom
                        {
                            HandleRectLeave();
                        }
                        else if(handRightPoint.Y < startRect.TopLeft.Y) //leave top
                        {
                            HandleRectLeave();
                        }
                    }
                }
                isInRectLastFrame = isInRect;

                if (isInGestureRect)
                {
                    if (handRight.Position.X < entryPoint.X)
                    {
                        lockElement.Position = Math.Abs(entryPoint.X - handRight.Position.X) / Math.Abs(entryPoint.X - spine.Position.X);
                    }
                    else
                    {
                        entryPoint = handRight.Position;
                    }
                    if (handRight.Position.X <= spine.Position.X)
                    {
                        SwipeRight();
                        HandleRectLeave();
                    }
                }
            }
        }
开发者ID:rechc,项目名称:KinectMiniApps,代码行数:59,代码来源:SwipeLockMain.xaml.cs

示例4: get_postion2

        private void get_postion2(AllFramesReadyEventArgs e)
        {
            // スケルトンフレームを取得する
            SkeletonFrame skeletonFrame = e.OpenSkeletonFrame();
            if (skeletonFrame == null) return;

            // スケルトンデータを取得する
            Skeleton[] skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
            skeletonFrame.CopySkeletonDataTo(skeletonData);

            //1プレーヤースケルトン
            var skeleton = skeletonData.First();
            if (skeleton.TrackingState != SkeletonTrackingState.Tracked && skeleton.TrackingState != SkeletonTrackingState.PositionOnly) return;

            //両手のポジション取得
            var left_joint = skeleton.Joints.Where(p => p.JointType == JointType.HandLeft).Single();
            var right_joint = skeleton.Joints.Where(p => p.JointType == JointType.HandRight).Single();
            //var right_joint2 = skeleton.Joints.Where(p => p.JointType == JointType.WristRight).Single();
            var right_Elbow = skeleton.Joints.Where(p => p.JointType == JointType.ElbowRight).Single();

            var left_v = new Microsoft.Xna.Framework.Vector3(left_joint.Position.X, left_joint.Position.Y, left_joint.Position.Z);
            var right_v = new Microsoft.Xna.Framework.Vector3(right_joint.Position.X, right_joint.Position.Y, right_joint.Position.Z);
            var right_Elbow_v = new Microsoft.Xna.Framework.Vector3(right_Elbow.Position.X, right_Elbow.Position.Y, right_Elbow.Position.Z);

            //両手の距離
            Microsoft.Xna.Framework.Vector3 vec1 = left_v - right_v;
            float len = vec1.Length();

            if (len_back == 0) { len_back = len; return; }

            int step;
            #region 拡大・縮小
            step = 10;
            if (len_back > len)
            {
                MouseWinAPI.SendRightButtonDown(SssimWnd, 1, 1);
                MouseWinAPI.SendMouseMove(SssimWnd, 1, step);
                MouseWinAPI.SendRightButtonUp(SssimWnd, 1, step);
            }
            else
            {
                MouseWinAPI.SendRightButtonDown(SssimWnd, 1, step);
                MouseWinAPI.SendMouseMove(SssimWnd, 1, 1);
                MouseWinAPI.SendRightButtonUp(SssimWnd, 1, step);
            }
            len_back = len;
            #endregion

            #region 回転
            step = 2;

            //左手、右手、右ひじの、外積を求める
            Microsoft.Xna.Framework.Vector3 v1 = right_v - left_v; //右手位置-左手位置
            Microsoft.Xna.Framework.Vector3 v2 = right_Elbow_v - left_v; //右ひじ置-左手位置
            Microsoft.Xna.Framework.Vector3 v3 = Vector3.Cross(v1, v2);

            //前回ベクトルと、現在ベクトルの差
            Microsoft.Xna.Framework.Vector3 now_vec = v3_old - v3;

            MouseWinAPI.SendLeftButtonDown(SssimWnd, 100, 100);

            int x = (int)(now_vec.X * 1000) * step;
            int y = (int)(now_vec.Y * 1000) * step;
            MouseWinAPI.SendMouseMove(SssimWnd, 100 + x, 100 + y);
            MouseWinAPI.SendLeftButtonUp(SssimWnd, 100 + x, 100 + y);

            label1.Content = "X=" + x;
            label2.Content = "Y=" + y;

            v3_old = v3;

            #endregion
        }
开发者ID:sugasaki,项目名称:Kinect,代码行数:73,代码来源:MainWindow.xaml.cs


注:本文中的Microsoft.Kinect.Skeleton.First方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。