internal double Match(SmothendSkeleton skeleton) // distance to other person { SkeletonPoint currentRoot = Position; SkeletonPoint otherRoot = skeleton.Positon; return(SkeletonMath.DistanceBetweenPoints(currentRoot, otherRoot)); }
internal double Match(SmothendSkeleton skeleton) // distance to other person { SkeletonPoint currentRoot = CurrentSkeleton.GetPosition(JointType.HipCenter); SkeletonPoint otherRoot = skeleton.GetPosition(JointType.HipCenter); return(SkeletonMath.DistanceBetweenPoints(currentRoot, otherRoot)); }
private void FindCandidates(List <Person> persons) { var act = GetActivePersons().ToList(); Random r = new Random(); if (_expirationCandidates.Count(x => x.Value.Active == true) + act.Count < PersonsToTrack) // a active person recently disapeared, waiting to come back { //no disappeared active person if (_visiblePersons.Count + persons.Count <= 2 && _visiblePersons.Count > 0) { persons = persons.Union(_visiblePersons).ToList(); } else if (_visiblePersons.Count > 2) { // too many people to track all var tracked = _visiblePersons.Where(x => x.TrackingState == SkeletonTrackingState.Tracked && !x.Active) .ToList(); foreach (var person in tracked) { if ( SkeletonMath.DirectionTo( person.CurrentSkeleton.GetPosition(JointType.HandRight), person.CurrentSkeleton.GetPosition(JointType.ShoulderRight)) .Contains(Direction.Downward) && persons.Count <= 2) { // has the hand over his shoulder persons.Add(person); } } var untracked = _visiblePersons.Where(x => x.TrackingState != SkeletonTrackingState.Tracked) .ToList(); if (untracked.Count + persons.Count <= 2) { // Add the rest persons.AddRange(untracked); } else { // pick random skeletons for (int i = persons.Count; i < 2; i++) { persons.Add(untracked.ElementAt(r.Next(0, untracked.Count - 1))); } } } else { //someting bad happend KinectDevice.SkeletonStream.ChooseSkeletons(); } } switch (persons.Count) { case 1: KinectDevice.SkeletonStream.ChooseSkeletons(persons.First().TrackingId); break; case 2: KinectDevice.SkeletonStream.ChooseSkeletons(persons.First().TrackingId, persons.Last().TrackingId); break; } }