Beispiel #1
0
        public IEnumerable<ColorImagePoint> GetCollisions(Player other)
        {
            if (this != other)
            {
                ColorImagePoint leftHand = GetCameraPoint(JointType.HandLeft);
                ColorImagePoint rightHand = GetCameraPoint(JointType.HandRight);

                ColorImagePoint otherHead = GetCameraPoint(JointType.Head);
                ColorImagePoint otherNeck = GetCameraPoint(JointType.ShoulderCenter);
                if (otherNeck.Y > otherHead.Y)
                {
                    int radius = otherNeck.Y - otherHead.Y;

                    int leftHandDistance = (int)Distance(leftHand, otherHead);
                    if (leftHandDistance <= radius)
                    {
                        yield return leftHand;
                    }

                    int rightHandDistance = (int)Distance(rightHand, otherHead);
                    if (rightHandDistance <= radius)
                    {
                        yield return rightHand;
                    }
                }
            }
        }
Beispiel #2
0
 public IEnumerable<ColorImagePoint> GetCollisions(Player[] others)
 {
     foreach (Player otherPlayer in others)
     {
         foreach (ColorImagePoint point in GetCollisions(otherPlayer))
         {
             yield return point;
         }
     }
 }
        Player[] GetPlayers(DepthImageFrame depth, SkeletonFrame skeletonFrame)
        {
            if (depth == null || skeletonFrame == null)
            {
                return null;
            }

            skeletonFrame.CopySkeletonDataTo(_allSkeletons);
            int trackedCount = _allSkeletons.Count(s =>
            {
                return s.TrackingState == SkeletonTrackingState.Tracked;
            });

            if (trackedCount < 1)
            {
                return new Player[0];
            }

            if (_headImages.Length < trackedCount)
            {
                throw new IndexOutOfRangeException("Not enough head images for number of tracked skeletons");
            }

            Player[] players = new Player[trackedCount];
            int playerIndex = 0;
            for (int i = 0; i < _allSkeletons.Length; i++)
            {
                if (_allSkeletons[i].TrackingState == SkeletonTrackingState.Tracked)
                {
                    players[playerIndex] = new Player(_allSkeletons[i], depth, _headImages[playerIndex]);
                    playerIndex++;
                }
            }

            return players;
        }