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


C# Skeleton.Count方法代码示例

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


在下文中一共展示了Skeleton.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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];

                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

示例2: 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

示例3: SkeletonFrameReady_Init_DTW_Process

         //Skeleton FrameEdges ready event - start DTW processing
        void SkeletonFrameReady_Init_DTW_Process(object sender, SkeletonFrameReadyEventArgs e)
        {
            //Get the skeletons from the skeleton frame
            //Some frames come back empty - check for null
            SkeletonFrame skeleton_frame = e.OpenSkeletonFrame();
            if (skeleton_frame == null)
            {
                //Do nothin'
                return;
            }

            //Init a new skeletons array of proper size
            Skeleton[] skeletons = new Skeleton[skeleton_frame.SkeletonArrayLength];
            //Copy data into array
            skeleton_frame.CopySkeletonDataTo(skeletons);

            //For each skeleton, process the data
            //Keep an 'index' of which of the two tracked skeletons is being passed
            int num_tracked = 0;
            for (int i = 0; i < skeletons.Count<Skeleton>(); i++)
            {
                //Only do DTW for skeletons which are fully tracked
                if(skeletons[i].TrackingState == SkeletonTrackingState.Tracked)
                {
                    //Get the event args
                    Skeleton2DdataCoordEventArgs args = Skeleton2DDataExtract.skeletonToSkeleton2DdataCoordEventArgs(skeletons[i],num_tracked);
                    //Launch the events
                    Skeleton2DdataCoordReady(null, args);
                    num_tracked++;
                    //Stop looping if this was the second (max) tracked skeleton 
                    if(num_tracked >= MAX_TRACKED_SKELETONS)
                    {
                        break;
                    }
                }
            }

            //A warning told me to do this - and I am code monkey.
            skeleton_frame.Dispose();
        }
开发者ID:JulianKemmerer,项目名称:Drexel-SeniorDesign,代码行数:41,代码来源:MainWindow.xaml.cs


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