Esempio n. 1
0
    /// <summary>
    /// Processes an <see cref="ImageData"/> object and reports it to Ogama.
    /// </summary>
    /// <param name="data">The <see cref="ImageData"/> to process.</param>
    private void ProcessImageData(ImageData data)
    {
      var newGazeData = new GazeData();

      if (data.LeftEye.Found && data.RightEye.Found)
      {
        newGazeData.GazePosX = (float)((data.LeftEye.GazePoint.x + data.RightEye.GazePoint.x) / 2.0);
        newGazeData.GazePosY = (float)((data.LeftEye.GazePoint.y + data.RightEye.GazePoint.y) / 2.0);
        newGazeData.PupilDiaX = (float)data.LeftEye.PupilDiameter;
        newGazeData.PupilDiaY = (float)data.RightEye.PupilDiameter;

        newGazeData.GazePosX = newGazeData.GazePosX / (float)this.resolutionX;
        newGazeData.GazePosY = newGazeData.GazePosY / (float)this.resolutionY;
      }
      else if (data.LeftEye.Found)
      {
        newGazeData.GazePosX = (float)data.LeftEye.GazePoint.x;
        newGazeData.GazePosY = (float)data.LeftEye.GazePoint.y;
        newGazeData.PupilDiaX = (float)data.LeftEye.PupilDiameter;
        newGazeData.PupilDiaY = null;

        newGazeData.GazePosX = newGazeData.GazePosX / (float)this.resolutionX;
        newGazeData.GazePosY = newGazeData.GazePosY / (float)this.resolutionY;
      }
      else if (data.RightEye.Found)
      {
        newGazeData.GazePosX = (float)data.RightEye.GazePoint.x;
        newGazeData.GazePosY = (float)data.RightEye.GazePoint.y;
        newGazeData.PupilDiaX = null;
        newGazeData.PupilDiaY = (float)data.RightEye.PupilDiameter;

        newGazeData.GazePosX = newGazeData.GazePosX / (float)this.resolutionX;
        newGazeData.GazePosY = newGazeData.GazePosY / (float)this.resolutionY;
      }
      else
      {
        newGazeData.GazePosX = null;
        newGazeData.GazePosY = null;
        newGazeData.PupilDiaX = null;
        newGazeData.PupilDiaY = null;
      }

      newGazeData.Time = (long)data.Time;

      this.OnGazeDataChanged(new GazeDataChangedEventArgs(newGazeData));
    }
Esempio n. 2
0
    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    #region EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for UI, Menu, Buttons, Toolbars etc.                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region WINDOWSEVENTHANDLER
    #endregion //WINDOWSEVENTHANDLER

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for Custom Defined Events                                    //
    ///////////////////////////////////////////////////////////////////////////////
    #region CUSTOMEVENTHANDLER
    #endregion //CUSTOMEVENTHANDLER
    #endregion //EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region BACKGROUNDWORKER
    #endregion //BACKGROUNDWORKER

    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region METHODS

    /// <summary>
    /// This method starts the data collection process running an infinite loop
    /// unless isRecording is false
    /// </summary>
    private void StartDataCollecting()
    {
      var tempImgData = new ImageData();
      while (this.isRecording)
      {
        // Keep looping for valid image data.
        while (!NativeMethods.GetImageData(100, ref tempImgData))
        {
        }

        // Check if we have this sample, if so ignore it
        if (tempImgData.Time != this.imageData.Time)
        {
          this.imageData = tempImgData;
          this.ProcessImageData(this.imageData);
        }
      }
    }
Esempio n. 3
0
    /// <summary>
    /// Sets up calibration procedure and the tracking client
    /// and wires the events. Reads settings from file.
    /// </summary>
    protected override sealed void Initialize()
    {
      this.imageData = new ImageData();

      // Load eyetech tracker settings. First tries to get realtime QuickGlance
      // settings. If this fails, fallback to a settingsfile. If that fails, create
      // a default settingsfile. 
      // NOTE: These settings are not always up to date as a user can just change
      // the settings through QuickGlance.
      this.eyetechSettings = new EyeTechSetting();
      if (!this.eyetechSettings.GetQuickGlanceSettings())
      {
        if (File.Exists(this.SettingsFile))
        {
          this.eyetechSettings = this.DeserializeSettings(this.SettingsFile);
        }
        else
        {
          this.SerializeSettings(this.eyetechSettings, this.SettingsFile);
        }
      }

      this.UpdateSettings();
    }
Esempio n. 4
0
 public static extern bool ReadBulkCapture(uint MaxTimeout, ref ImageData Data);
Esempio n. 5
0
 public static extern bool GetImageDataAndLatency(uint MaxTimeout, ref ImageData Data, ref double Latency);
Esempio n. 6
0
 public static extern bool GetImageData(uint MaxTimeout, ref ImageData Data);