Пример #1
0
        /// <summary>
        /// Called when new track status data is received
        /// </summary>
        /// <param name="data"> The track status data to be displayed in this control. </param>
        public void OnTrackStatusData(TrackStatusData data)
        {
            // Add data to history
            this.dataHistory.Enqueue(data);

            // Remove history item if necessary
            while (this.dataHistory.Count > Historysize)
            {
                this.dataHistory.Dequeue();
            }

            this.currentTrackStatus = data;

            this.Invalidate();
        }
Пример #2
0
    /// <summary>
    /// Processes the message.
    /// </summary>
    /// <param name="msg">The message from the haytham server.</param>
    private void ProcessMessage(string msg)
    {
      if (msg == "Commands|CalibrationFinished|")
      {
        this.OnCalibrationFinished(EventArgs.Empty);
        return;
      }

      string[] msgArray = this.ConvertMsgToArray(msg);

      if (msg.StartsWith("Eye|"))
      {
        var newData = new GazeData();

        // Get time
        var timeInTicks = long.Parse(msgArray[0]);

        // Convert to milliseconds
        newData.Time = (long)(timeInTicks / 10000.0);

        // Get Position in screen coordinates
        var absoluteX = float.Parse(msgArray[1]);
        var absoluteY = float.Parse(msgArray[2]);

        // Convert to relative coordinates, cause this is expected by Ogama
        newData.GazePosX = absoluteX / this.presentationScreenSize.Width;
        newData.GazePosY = absoluteY / this.presentationScreenSize.Height;

        newData.PupilDiaX = int.Parse(msgArray[3]);

        this.OnGazeDataReceived(new GazeDataChangedEventArgs(newData));

        var newTrackStatusData = new TrackStatusData();
        newTrackStatusData.TrackedEyes = Eye.Left;
        var isPupilFound = bool.Parse(msgArray[4]);
        newTrackStatusData.LeftEyeValidity = isPupilFound ? Validity.Good : Validity.Missing;
        var pupilPosX = float.Parse(msgArray[5]);
        var pupilPosY = float.Parse(msgArray[6]);
        newTrackStatusData.LeftEyePosition = new Vector3D(pupilPosX, pupilPosY, 0);
        this.OnTrackStatusDataChanged(new TrackStatusDataChangedEventArgs(newTrackStatusData));
      }
    }
Пример #3
0
        /// <summary>
        ///   This method computes the status color.
        /// </summary>
        /// <returns>The <see cref="Color" /> indicating the tracking quality.</returns>
        private Color ComputeStatusColor()
        {
            if (!this.Enabled)
            {
                return(Color.Gray);
            }

            int quality = 0;
            int count   = 0;

            var historyClone = new TrackStatusData[Historysize];

            this.dataHistory.CopyTo(historyClone, 0);

            foreach (TrackStatusData item in historyClone)
            {
                switch (item.TrackedEyes)
                {
                case Eye.None:
                    break;

                case Eye.Left:
                    if (item.LeftEyeValidity == Validity.Good)
                    {
                        quality += 2;
                    }
                    else if (item.LeftEyeValidity == Validity.Problematic)
                    {
                        quality++;
                    }

                    break;

                case Eye.Right:
                    if (item.RightEyeValidity == Validity.Good)
                    {
                        quality += 2;
                    }
                    else if (item.RightEyeValidity == Validity.Problematic)
                    {
                        quality++;
                    }

                    break;

                case Eye.Both:
                    if (item.LeftEyeValidity == Validity.Good && item.RightEyeValidity == Validity.Good)
                    {
                        quality += 2;
                    }
                    else if (item.LeftEyeValidity == Validity.Problematic && item.RightEyeValidity == Validity.Problematic)
                    {
                        quality++;
                    }

                    break;
                }

                count++;
            }

            float q = count == 0 ? 0 : quality / (2F * count);

            return(this.statusGradient.GetRelativeColor(q));
        }
Пример #4
0
 /// <summary>
 ///   Clears the track status.
 /// </summary>
 public void Clear()
 {
     this.dataHistory.Clear();
     this.currentTrackStatus = new TrackStatusData();
     this.Invalidate();
 }
Пример #5
0
    /// <summary>
    ///   This method computes the status color.
    /// </summary>
    /// <returns>The <see cref="Color" /> indicating the tracking quality.</returns>
    private Color ComputeStatusColor()
    {
      if (!this.Enabled)
      {
        return Color.Gray;
      }

      int quality = 0;
      int count = 0;

      var historyClone = new TrackStatusData[Historysize];

      this.dataHistory.CopyTo(historyClone, 0);

      foreach (TrackStatusData item in historyClone)
      {
        switch (item.TrackedEyes)
        {
          case Eye.None:
            break;
          case Eye.Left:
            if (item.LeftEyeValidity == Validity.Good)
            {
              quality += 2;
            }
            else if (item.LeftEyeValidity == Validity.Problematic)
            {
              quality++;
            }

            break;
          case Eye.Right:
            if (item.RightEyeValidity == Validity.Good)
            {
              quality += 2;
            }
            else if (item.RightEyeValidity == Validity.Problematic)
            {
              quality++;
            }

            break;
          case Eye.Both:
            if (item.LeftEyeValidity == Validity.Good && item.RightEyeValidity == Validity.Good)
            {
              quality += 2;
            }
            else if (item.LeftEyeValidity == Validity.Problematic && item.RightEyeValidity == Validity.Problematic)
            {
              quality++;
            }

            break;
        }

        count++;
      }

      float q = count == 0 ? 0 : quality / (2F * count);

      return this.statusGradient.GetRelativeColor(q);
    }
Пример #6
0
    /// <summary>
    /// Called when new track status data is received
    /// </summary>
    /// <param name="data"> The track status data to be displayed in this control. </param>
    public void OnTrackStatusData(TrackStatusData data)
    {
      // Add data to history
      this.dataHistory.Enqueue(data);

      // Remove history item if necessary
      while (this.dataHistory.Count > Historysize)
      {
        this.dataHistory.Dequeue();
      }

      this.currentTrackStatus = data;

      this.Invalidate();
    }
Пример #7
0
 /// <summary>
 ///   Clears the track status.
 /// </summary>
 public void Clear()
 {
   this.dataHistory.Clear();
   this.currentTrackStatus = new TrackStatusData();
   this.Invalidate();
 }
 /// <summary>
 /// Initializes a new instance of the TrackStatusDataChangedEventArgs class.
 /// </summary>
 /// <param name="newTrackStatusData">
 /// The track status data as a <see cref="TrackStatusData"/> value.
 /// </param>
 public TrackStatusDataChangedEventArgs(TrackStatusData newTrackStatusData)
 {
   this.TrackStatusData = newTrackStatusData;
 }