private void RefreshPersonDetectionStates()
 {
     if (Settings.IsDebugViewEnabled)
     {
         for (int i = 0; i < this.bodies.Count; i++)
         {
             Body body = this.bodies[i];
             PersonDetectionState personDetectionState = this.PersonDetectionStates.Where(b => b.BodyIndex == i).FirstOrDefault();
             if (body == null || !body.IsTracked)
             {
                 // Remove previously tracked person
                 if (personDetectionState != null)
                 {
                     this.PersonDetectionStates.Remove(personDetectionState);
                 }
             }
             else
             {
                 bool isPrimary = (i == this.primaryPerson?.BodyIndex);
                 if (personDetectionState == null)
                 {
                     // Add new person
                     this.PersonDetectionStates.Add(new PersonDetectionState(i, isPrimary, body, this.bodyPresenceArea));
                 }
                 else
                 {
                     // Refresh existing person
                     personDetectionState.Refresh(isPrimary, body, this.bodyPresenceArea);
                 }
             }
         }
     }
 }
        public bool Equals(PersonDetectionState other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((this.IsPrimary == other.IsPrimary) &&
                   (this.IsHuman == other.IsHuman) &&
                   (this.IsInFrame == other.IsInFrame) &&
                   (this.DistanceFromSensor == other.DistanceFromSensor) &&
                   (this.TrackedJointCount == other.TrackedJointCount));
        }