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


C# Kinect.Skeleton类代码示例

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


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

示例1: RenderClippedEdges

        private static void RenderClippedEdges(Skeleton skeleton, DrawingContext drawingContext)
        {
            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Bottom))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(0, RenderHeight - ClipBoundsThickness, RenderWidth, ClipBoundsThickness));
            }

            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Top))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(0, 0, RenderWidth, ClipBoundsThickness));
            }

            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Left))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(0, 0, ClipBoundsThickness, RenderHeight));
            }

            if (skeleton.ClippedEdges.HasFlag(FrameEdges.Right))
            {
                drawingContext.DrawRectangle(
                    Brushes.Red,
                    null,
                    new Rect(RenderWidth - ClipBoundsThickness, 0, ClipBoundsThickness, RenderHeight));
            }
        }
开发者ID:nathad02,项目名称:CITS3200--Group-H,代码行数:34,代码来源:MainWindow.xaml.cs

示例2: UpdateAllGestures

 /// <summary>
 /// launch the update on all gestures relying on skeleton datas
 /// </summary>
 /// <param name="skel">the skeleton datas</param>
 /// <param name="gesture_context">the context when the gesture is triggered</param>
 public void UpdateAllGestures(Skeleton skel, ContextGesture gesture_context)
 {
     foreach (BodyGesture bg in this.gestures)
     {
         bg.updateGesture(skel, gesture_context);
     }
 }
开发者ID:HaKDMoDz,项目名称:kinectQlikView,代码行数:12,代码来源:BodyGestureControler.cs

示例3: ResetAll

 public void ResetAll(Skeleton skeleton)
 {
     foreach (var state in _gesturestate)
     {
         state.Reset();
     }
 }
开发者ID:UPS-CS240-F12,项目名称:motion-capture,代码行数:7,代码来源:GestureMapState.cs

示例4: TrackGesture

        private void TrackGesture(Skeleton skeleton, ref GestureTracker tracker, long timeStamp)
        {
            Joint leftHand = skeleton.Joints[JointType.HandLeft];
            Joint rightHand = skeleton.Joints[JointType.HandRight];

            if (leftHand.TrackingState != JointTrackingState.NotTracked && rightHand.TrackingState != JointTrackingState.NotTracked)
            {
                if (tracker.State == GestureState.InProcess && tracker.TimeStamp + _TIMEOUT <= timeStamp)
                    //响应超时
                    tracker.UpdateState(GestureState.Failure, timeStamp);
                else
                {
                    if (tracker.State == GestureState.InProcess)
                    {
                        if (Math.Abs(leftHand.Position.X - rightHand.Position.X) >= UPPER_THRESHOLD || Math.Abs(leftHand.Position.Y - rightHand.Position.Y) >= UPPER_THRESHOLD)
                        {
                            tracker.UpdateState(GestureState.Success, timeStamp);
                            if (GestureDetected != null)
                                GestureDetected(this, new EventArgs());
                        }
                    }
                    else
                    {
                        if (Math.Abs(leftHand.Position.Y - rightHand.Position.Y) < LOWER_THRESHOLD && Math.Abs(leftHand.Position.X - rightHand.Position.X) <= LOWER_THRESHOLD)
                            tracker.UpdatePosition(timeStamp);
                        else
                            tracker.Reset();
                    }
                }
            }
            else
                tracker.Reset();
        }
开发者ID:cnyangyijai,项目名称:Kinect,代码行数:33,代码来源:_TvSwitchGesture.cs

示例5: CheckForGesture

        public virtual bool CheckForGesture(Skeleton skeleton)
        {
            if (this.IsRecognitionStarted == false)
            {
                if (this.ValidateGestureStartCondition(skeleton))
                {
                    this.IsRecognitionStarted = true;
                    this.CurrentFrameCount = 0;
                }
            }

            else
            {
                if (this.CurrentFrameCount == this.MaximumNumberOfFrameToProcess)
                {
                    this.IsRecognitionStarted = false;
                    if (ValidateBaseCondition(skeleton) && ValidateGestureEndCondition(skeleton))
                    {
                        return true;
                    }
                }

                this.CurrentFrameCount++;

                if (!IsGestureValid(skeleton) && !ValidateBaseCondition(skeleton))
                {
                    this.IsRecognitionStarted = false;
                }
            }

            return false;
        }
开发者ID:cs247stanford,项目名称:jarm,代码行数:32,代码来源:GestureBase.cs

示例6: PosicaoValida

        protected override bool PosicaoValida(Skeleton esqueletoUsuario)
        {
            Joint centroOmbros = esqueletoUsuario.Joints[JointType.ShoulderCenter];
            Joint maoDireita = esqueletoUsuario.Joints[JointType.HandRight];
            Joint cotoveloDireito = esqueletoUsuario.Joints[JointType.ElbowRight];
            Joint maoEsquerda = esqueletoUsuario.Joints[JointType.HandLeft];
            Joint cotoveloEsquerdo = esqueletoUsuario.Joints[JointType.ElbowLeft];
            double margemErro = 0.30;

            bool maoDireitaAlturaCorreta = Util.CompararComMargemErro(margemErro, maoDireita.Position.Y, centroOmbros.Position.Y);
            bool maoDireitaDistanciaCorreta = Util.CompararComMargemErro(margemErro, maoDireita.Position.Z, centroOmbros.Position.Z);
            bool maoDireitaAposCotovelo = maoDireita.Position.X > cotoveloDireito.Position.X;

            bool cotoveloDireitoAlturaCorreta = Util.CompararComMargemErro(margemErro, cotoveloDireito.Position.Y, centroOmbros.Position.Y);
            bool cotoveloEsquerdoAlturaCorreta = Util.CompararComMargemErro(margemErro, cotoveloEsquerdo.Position.Y, centroOmbros.Position.Y);

            bool maoEsquerdaAlturaCorreta = Util.CompararComMargemErro(margemErro, maoEsquerda.Position.Y, centroOmbros.Position.Y);
            bool maoEsquerdaDistanciaCorreta = Util.CompararComMargemErro(margemErro, maoEsquerda.Position.Z, centroOmbros.Position.Z);
            bool maoEsquerdaAposCotovelo = maoEsquerda.Position.X < cotoveloEsquerdo.Position.X;
            

            return maoDireitaAlturaCorreta && 
                   maoDireitaDistanciaCorreta && 
                   maoDireitaAposCotovelo &&
                   cotoveloDireitoAlturaCorreta &&
                   maoEsquerdaAlturaCorreta && 
                   maoEsquerdaDistanciaCorreta &&
                   maoEsquerdaAposCotovelo &&
                   cotoveloEsquerdoAlturaCorreta;
        }
开发者ID:gilgaljunior,项目名称:CrieAplicacoesInterativascomoMicrosoftKinect,代码行数:30,代码来源:PoseT.cs

示例7: skelData

 public skelData(Skeleton skel)
 {
     sx = skel.Position.X;
     sy = skel.Position.Y;
     sz = skel.Position.Z;
     spread = 0; //not coded yet!!
 }
开发者ID:tklebanoff,项目名称:kinect2osc,代码行数:7,代码来源:skelData.cs

示例8: AppendSkeleton

        public void AppendSkeleton(Skeleton skeleton)
        {
            SkeletonPoint head = skeleton.Joints[JointType.Head].Position;
            SkeletonPoint shoulderCenter = skeleton.Joints[JointType.ShoulderCenter].Position;
            SkeletonPoint shoulderLeft = skeleton.Joints[JointType.ShoulderLeft].Position;
            SkeletonPoint shoulderRight = skeleton.Joints[JointType.ShoulderRight].Position;

            SkeletonPoint elbowLeft = skeleton.Joints[JointType.ElbowLeft].Position;
            SkeletonPoint wristLeft = skeleton.Joints[JointType.WristLeft].Position;
            SkeletonPoint handLeft = skeleton.Joints[JointType.HandLeft].Position;

            SkeletonPoint elbowRight = skeleton.Joints[JointType.ElbowRight].Position;
            SkeletonPoint wristRight = skeleton.Joints[JointType.WristRight].Position;
            SkeletonPoint handRight = skeleton.Joints[JointType.HandRight].Position;

            StringBuilder sb = new StringBuilder();
            sb.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+", ");
            sb.Append(head.X.ToString() + "," + head.Y.ToString() + "," + head.Z.ToString() + ",");
            sb.Append(shoulderCenter.X + "," + shoulderCenter.Y + "," + shoulderCenter.Z + ",");
            sb.Append(shoulderLeft.X + "," + shoulderLeft.Y + "," + shoulderLeft.Z + ",");
            sb.Append(shoulderRight.X + "," + shoulderRight.Y + "," + shoulderRight.Z + ",");

            sb.Append(elbowLeft.X + "," + elbowLeft.Y + "," + elbowLeft.Z + ",");
            sb.Append(wristLeft.X + "," + wristLeft.Y + "," + wristLeft.Z + ",");
            sb.Append(handLeft.X + "," + handLeft.Y + "," + handLeft.Z + ",");

            sb.Append(elbowRight.X + "," + elbowRight.Y + "," + elbowRight.Z + ",");
            sb.Append(wristRight.X + "," + wristRight.Y + "," + wristRight.Z + ",");
            sb.Append(handRight.X + "," + handRight.Y + "," + handRight.Z);

            AppendSkeletonString(sb.ToString());
        }
开发者ID:Cheat-Bluff,项目名称:Cheat-Bluff,代码行数:32,代码来源:SkeletonLogger.cs

示例9: CheckGesture

        public GesturePartResult CheckGesture(Skeleton skeleton)
        {
            double LeftA = Math.Sqrt((Math.Pow(skeleton.Joints[JointType.KneeLeft].Position.Z - skeleton.Joints[JointType.FootLeft].Position.Z, 2) + Math.Pow(skeleton.Joints[JointType.KneeLeft].Position.Y - skeleton.Joints[JointType.FootLeft].Position.Y, 2)));
            double LeftB = Math.Sqrt((Math.Pow(skeleton.Joints[JointType.HipRight].Position.Z - skeleton.Joints[JointType.KneeLeft].Position.Z, 2) + Math.Pow(skeleton.Joints[JointType.HipLeft].Position.Y - skeleton.Joints[JointType.KneeLeft].Position.Y, 2)));
            double LeftC = skeleton.Joints[JointType.HipLeft].Position.Y - skeleton.Joints[JointType.FootLeft].Position.Y;

            double RightA = Math.Sqrt((Math.Pow(skeleton.Joints[JointType.KneeRight].Position.Z - skeleton.Joints[JointType.FootRight].Position.Z, 2) + Math.Pow(skeleton.Joints[JointType.KneeRight].Position.Y - skeleton.Joints[JointType.FootRight].Position.Y, 2)));
            double RightB = Math.Sqrt((Math.Pow(skeleton.Joints[JointType.HipRight].Position.Z - skeleton.Joints[JointType.KneeRight].Position.Z, 2) + Math.Pow(skeleton.Joints[JointType.HipRight].Position.Y - skeleton.Joints[JointType.KneeRight].Position.Y, 2)));
            double RightC = skeleton.Joints[JointType.HipRight].Position.Y - skeleton.Joints[JointType.FootRight].Position.Y;

            double LeftAngle = Math.Acos((Math.Pow(LeftA, 2) + Math.Pow(LeftB, 2) - Math.Pow(LeftC, 2)) / (2 * LeftA * LeftB));
            double RightAngle = Math.Acos((Math.Pow(RightA, 2) + Math.Pow(RightB, 2) - Math.Pow(RightC, 2)) / (2 * RightA * RightB));

            LeftAngle = (LeftAngle * 180) / Math.PI;
            RightAngle = (RightAngle * 180) / Math.PI;

            if (LeftAngle > 160 && RightAngle > 160)
            {
                NewHipCenterAverage = (skeleton.Joints[JointType.HipLeft].Position.Y + skeleton.Joints[JointType.HipCenter].Position.Y + skeleton.Joints[JointType.HipRight].Position.Y) / 3;
                if(NewHipCenterAverage - BendSegment1.HipCenterAverage < 0.04)
                {   
                return GesturePartResult.Succeed;
                }
                return GesturePartResult.Fail;
            }
            else 
            {
                return GesturePartResult.Pausing;
            }
        }
开发者ID:guozanhua,项目名称:kinect-ripple,代码行数:30,代码来源:BendSegment3.cs

示例10: IsGestureValid

 protected override bool IsGestureValid(Skeleton skeleton)
 {
     SkeletonPoint newLeft = skeleton.Joints[JointType.HandRight].Position;
     SkeletonPoint newRight = skeleton.Joints[JointType.HandRight].Position;
     if ((originLeft != newLeft) && (originRight != newRight)) return false;
     return true;
 }
开发者ID:h3nj3,项目名称:Kinect-Gesture-Recognizer,代码行数:7,代码来源:SickGesture.cs

示例11: Evaluate

        //Checks to see if the two joints are in either of the two states. Unless the beginning relationship has
        //been satisifed, it will not check the ending relationship.
        public bool Evaluate(Skeleton skeleton, int xScale, int yScale)
        {
            var sjoint1 = skeleton.Joints[_component.Joint1].ScaleTo(xScale, yScale);
            var sjoint2 = skeleton.Joints[_component.Joint2].ScaleTo(xScale, yScale);

            if (!BeginningRelationshipSatisfied)
            {
                var goodtogo = CompareJointRelationship(sjoint1, sjoint2, _component.BeginningRelationship);
                if (goodtogo)
                {
                    _beginningRelationshipSatisfied = true;
                }
                else
                {
                    return false;
                }
            }

            if (!EndingRelationshipSatisfied)
            {
                var goodtogo = CompareJointRelationship(sjoint1, sjoint2, _component.EndingRelationship);
                if (goodtogo)
                {
                    return _endingRelationshipSatisfied = true;
                }
                return false;
            }

            return true;
        }
开发者ID:UPS-CS240-F12,项目名称:motion-capture,代码行数:32,代码来源:GestureComponentState.cs

示例12: Add

        /// <summary>
        /// Dequeues from the queue if available and accepting
        /// </summary>
        /// <param name="skeleton">Skeletal array data from the SkeletonFrame</param>
        public void Add(Skeleton[] skeleton, long timeStamp)
        {
            // Is there any space left?
            if (free.Count == 0)
            {
                for (int i = 0; i < maxInstances; ++i)
                {
                    //   enqueue again so long as no one else is using this
                    if (!this.universe[i].InUse)
                    {
                        free.Enqueue(this.universe[i]);
                    }
                }
            }

            if (free.Count > 0)
            {
                SkeletonStamp s = free.Dequeue();
                s.TimeStamp = timeStamp;
                s.SkeletonData = skeleton;
                s.InUse = false;
                s.IsActive = true;
                //Debug.WriteLine("Adding {0}", free.Count);
            }
            else
            {
                Debug.WriteLine("Out of skeletons!  Consider increasing the max instances on initialization.");
            }
        }
开发者ID:slowbump,项目名称:KinectTherapyTest,代码行数:33,代码来源:SkeletonPool.cs

示例13: Pruefe

        /// <summary>
        /// Prueft die history, ob die jeweilige Bewegung ausgelöst wird oder nicht.
        /// </summary>
        /// <param name="history">The history.</param>
        /// <returns></returns>
        public ErkennerStatus Pruefe(Skeleton[] history)
        {
            var headY = history.Select(x => x.Joints[JointType.Head].Position.Y);
            var leftFootY = history.Select(x => x.Joints[JointType.FootLeft].Position.Y);

            bool unten = (headY.Max() - headY.First() > 0.15) && (leftFootY.First() - leftFootY.Min()) < 0.02;
            bool oben = (headY.First() - headY.Min() > 0.1) && (leftFootY.Max()-leftFootY.First()) < 0.02;

            if (Blocked)
            {
                if (BlockStopwatch.ElapsedMilliseconds > 700)
                {
                    Blocked = false;
                    BlockStopwatch = null;
                }
            }

            if (!Blocked)
            {
                if (_geduckt && oben)
                {
                    _geduckt = false;
                    MotionFunctions.SendAction(MotionFunctions.DownUp());
                    return ErkennerStatus.NichtAktiv;
                }
                if (!_geduckt && unten)
                {
                    _geduckt = true;
                    MotionFunctions.SendAction(MotionFunctions.DownDown());
                    return ErkennerStatus.Aktiv;
                }
            }

            return _geduckt ? ErkennerStatus.Aktiv : ErkennerStatus.NichtAktiv;
        }
开发者ID:raphaelschmid,项目名称:finalproject,代码行数:40,代码来源:Ducken.cs

示例14: detectHighFives

        // Detect high fives between pairs of skeletons.
        private void detectHighFives(Skeleton[] skeletons)
        {
            // Loop over every pair of skeletons.
            for (int i = 0; i < skeletons.Length; i++)
            {
                for (int j = i + 1; j < skeletons.Length; j++)
                {
                    var skeleton1 = skeletons[i];
                    var skeleton2 = skeletons[j];
                    var id1 = skeleton1.TrackingId;
                    var id2 = skeleton2.TrackingId;

                    // Generate a key for the pair.
                    Tuple<int, int> key;
                    if (id1 < id2)
                        key = new Tuple<int, int>(id1, id2);
                    else
                        key = new Tuple<int, int>(id2, id1);

                    // Add the pair to the dictionary if it hasn't been seen before.
                    if (!hasHighFived.ContainsKey(key))
                        hasHighFived.Add(key, false);

                    // Check if the skeletons are high fiving at the moment.
                    bool currentHighFiveStatus = isHighFiving(skeleton1, skeleton2, hasHighFived[key]);

                    // Invoke the highFive method when a new high five has been detected.
                    if (!hasHighFived[key] && currentHighFiveStatus)
                        highFive();

                    // Save the current high five status.
                    hasHighFived[key] = currentHighFiveStatus;
                }
            }
        }
开发者ID:decrobin,项目名称:KinectwithDora,代码行数:36,代码来源:Kinect.cs

示例15: kinect_AllFramesReady

        void kinect_AllFramesReady( object sender, AllFramesReadyEventArgs e )
        {
            using ( var colorFrame = e.OpenColorImageFrame() ) {
                if ( colorFrame != null ) {
                    var pixel = new byte[colorFrame.PixelDataLength];
                    colorFrame.CopyPixelDataTo( pixel );

                    ImageRgb.Source = BitmapSource.Create( colorFrame.Width, colorFrame.Height, 96, 96,
                        PixelFormats.Bgr32, null, pixel, colorFrame.Width * 4 );
                }
            }

            using ( var depthFrame = e.OpenDepthImageFrame() ) {
                if ( depthFrame != null ) {
                    // Depth情報を入れる
                    // GetRawPixelData()はインタラクションライブラリ内で実装された拡張メソッド
                    stream.ProcessDepth( depthFrame.GetRawPixelData(), depthFrame.Timestamp );
                }
            }

            using ( var skeletonFrame = e.OpenSkeletonFrame() ) {
                if ( skeletonFrame != null ) {
                    var skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo( skeletons );

                    // スケルトン情報を入れる
                    stream.ProcessSkeleton( skeletons, kinect.AccelerometerGetCurrentReading(), skeletonFrame.Timestamp );
                }
            }
        }
开发者ID:penyatree,项目名称:KinectSDKv17Sample,代码行数:30,代码来源:MainWindow.xaml.cs


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