示例#1
0
        // ------------------------------------------
        //  SETTER
        // ------------------------------------------

        protected bool UpdateFace(string name)
        {
            if (null == name)
            {
                return(false);
            }
            bool hasChange = true;

            // Search for WSRProfile
            foreach (WSRProfile profile in Profiles)
            {
                if (profile.Name != name)
                {
                    continue;
                }
                hasChange = false;
                Current   = profile; break;
            }

            // Create new WSRProfile
            if (null == Current || (Current.Name != name &&
                                    !Current.Name.StartsWith("Unknow")))
            {
                Current = new WSRProfile();
                Profiles.Add(Current);
            }

            // Reset TimeStamp
            Current.Timestamp = DateTime.Now;
            Current.Name      = name;
            return(hasChange);
        }
示例#2
0
        public void UpdatePitch(double pitch)
        {
            bool hasChange = Profiles.RemoveAll(ProfileTimout) > 0;

            // Search for WSRProfile
            var delta = null != Current?Math.Abs(Current.Pitch - pitch) : pitch;

            foreach (WSRProfile profile in Profiles)
            {
                var d = Math.Abs(profile.Pitch - pitch);
                if (delta < d)
                {
                    continue;
                }
                Current = profile;
                delta   = d;
            }

            // Create new WSRProfile
            if (null == Current || (Current.Pitch > 0 && delta > WSRConfig.GetInstance().PitchDelta))
            {
                Current = new WSRProfile();
                Profiles.Add(Current);
            }

            // Reset TimeStamp
            Current.Timestamp = DateTime.Now;
            Current.Pitch     = pitch;

            // Trigger
            ProfileChange(hasChange);
        }
示例#3
0
        private void DrawProfile()
        {
            var current  = WSRProfileManager.GetInstance().Current;
            var profiles = WSRProfileManager.GetInstance().Profiles;

            for (int i = 0; i < profiles.Count && i < 5; i++)
            {
                WSRProfile profile = profiles[i];
                if (profile == null)
                {
                    continue;
                }
                var label = ((TextBlock)System.Windows.LogicalTreeHelper.FindLogicalNode(this, "label_Profile" + i));
                label.Text       = profile.Name;
                label.Foreground = (profile == current) ?  red : black;
                ((TextBlock)System.Windows.LogicalTreeHelper.FindLogicalNode(this, "label_Pitch" + i)).Text  = "Pitch: " + Math.Round(profile.Pitch);
                ((TextBlock)System.Windows.LogicalTreeHelper.FindLogicalNode(this, "label_Mood" + i)).Text   = "Mood: " + profile.Mood;
                ((TextBlock)System.Windows.LogicalTreeHelper.FindLogicalNode(this, "label_Height" + i)).Text = "Height: " + profile.Height;
                ((TextBlock)System.Windows.LogicalTreeHelper.FindLogicalNode(this, "label_Head" + i)).Text   = "Head: " + Math.Round(profile.x / 10)
                                                                                                               + "," + Math.Round(profile.y / 10)
                                                                                                               + "," + Math.Round(profile.z / 10);
            }

            if (null != current)
            {
                label_Gesture.Text = "Head: Tracked x: " + Math.Round(current.x / 10) + " y: " + Math.Round(current.y / 10) + " z: " + Math.Round(current.z / 10);
                label_Height.Text  = "Height: " + current.Height + "m";
            }
        }
示例#4
0
 private bool ProfileTimout(WSRProfile profile){
   if (profile.Name != null) return false;
   var timeout = (DateTime.Now - profile.Timestamp) > WSRConfig.GetInstance().FaceTH;
   if (timeout && Current == profile) {
     Current = null;
   }
   return timeout;
 }
示例#5
0
        public void UpdateHeight(double height)
        {
            // Create new WSRProfile
            if (null == Current)
            {
                Current = new WSRProfile();
                Profiles.Add(Current);
            }

            // Update Height
            Current.Timestamp = DateTime.Now;
            Current.Height    = height;
        }
示例#6
0
        public void UpdateMood(double mood)
        {
            // Create new WSRProfile
            if (null == Current)
            {
                Current = new WSRProfile();
                Profiles.Add(Current);
            }

            // Update Height
            Current.Timestamp = DateTime.Now;
            Current.Mood      = mood;
        }
示例#7
0
        private bool ProfileTimout(WSRProfile profile)
        {
            if (profile.Name != null)
            {
                return(false);
            }
            var timeout = (DateTime.Now - profile.Timestamp) > WSRConfig.GetInstance().FaceTH;

            if (timeout && Current == profile)
            {
                Current = null;
            }
            return(timeout);
        }
示例#8
0
        public void UpdateHead(float x, float y, float z)
        {
            // Create new WSRProfile
            if (null == Current)
            {
                Current = new WSRProfile();
                Profiles.Add(Current);
            }

            // Update Height
            Current.Timestamp = DateTime.Now;
            Current.x         = x;
            Current.y         = y;
            Current.z         = z;
        }
示例#9
0
    // ------------------------------------------
    //  SETTER
    // ------------------------------------------
    
    protected bool UpdateFace(string name) {
      if (null == name) { return false; }
      bool hasChange = true;

      // Search for WSRProfile
      foreach (WSRProfile profile in Profiles) {
        if (profile.Name != name) { continue; }
        hasChange = false;
        Current = profile; break;
      }

      // Create new WSRProfile
      if (null == Current || (Current.Name != name 
                          && !Current.Name.StartsWith("Unknow"))) { 
        Current = new WSRProfile();
        Profiles.Add(Current);
      }

      // Reset TimeStamp
      Current.Timestamp = DateTime.Now;
      Current.Name = name;
      return hasChange;
    }
示例#10
0
    public void UpdateHead(float x, float y, float z) {

      // Create new WSRProfile
      if (null == Current) {
        Current = new WSRProfile();
        Profiles.Add(Current);
      }

      // Update Height
      Current.Timestamp = DateTime.Now;
      Current.x = x;
      Current.y = y;
      Current.z = z;
    }
示例#11
0
    public void UpdateHeight(double height) {

      // Create new WSRProfile
      if (null == Current) {
        Current = new WSRProfile();
        Profiles.Add(Current);
      }

      // Update Height
      Current.Timestamp = DateTime.Now;
      Current.Height = height;
    }
示例#12
0
    public void UpdateMood(double mood) {

      // Create new WSRProfile
      if (null == Current) {
        Current = new WSRProfile();
        Profiles.Add(Current);
      }

      // Update Height
      Current.Timestamp = DateTime.Now;
      Current.Mood = mood;
    }
示例#13
0
    public void UpdatePitch(double pitch) {
      bool hasChange = Profiles.RemoveAll(ProfileTimout) > 0;
      
      // Search for WSRProfile
      var delta = null != Current ? Math.Abs(Current.Pitch - pitch) : pitch;
      foreach (WSRProfile profile in Profiles) {
        var d = Math.Abs(profile.Pitch - pitch);
        if (delta < d) { continue; }
        Current = profile;
        delta = d;
      }

      // Create new WSRProfile
      if (null == Current || (Current.Pitch > 0 && delta > WSRConfig.GetInstance().PitchDelta)) {
        Current = new WSRProfile();
        Profiles.Add(Current);
      }

      // Reset TimeStamp
      Current.Timestamp = DateTime.Now;
      Current.Pitch = pitch;

      // Trigger
      ProfileChange(hasChange);
    }