示例#1
0
        //private bool isSavingImages = true;
        //private string uniqueFolder = "";

        #endregion

        #region Constructor

        public Calibration()
        {
            id = GetUniqueID();

            if (Settings.Instance.Processing.TrackingGlints)
                calibMethod = new CalibPolynomial();
            else
                calibMethod = new CalibPupil();
        }
示例#2
0
    public void GenerateXML(CalibMethod calibration)
    {
      XDocument doc = new XDocument(
                      new XElement("root",
                      new XAttribute("name", "GTCalibration"), // root doc name
                      GenerateEnvironment(),
                      GenerateHardware(),
                      GenerateResults(id, calibration),
                      GenerateCalibrationData(calibration)));

      // Save as  "\Calibration\20110112224355\20110112224355.xml"
      string saveFilePath = dataFolder + "\\" + id + ".xml";

      try
      {
        doc.Save(saveFilePath);
      }
      catch (Exception ex)
      {
        Console.Out.WriteLine("CalibrationExport.cs, error while saving calibration. Message: " + ex.Message);
      }
    }
示例#3
0
    private static XElement GenerateCalibrationData(CalibMethod calibration)
    {
      var calibrationData = new XElement("CalibrationData");

      foreach (CalibrationTarget ct in calibration.CalibrationTargets)
      {
        for (int j = 0; j < ct.NumImages; j++)
        {
          try
          {
            if (j < ct.pupilCentersLeft.Count && j < ct.glintsLeft.Count &&
                j < ct.estimatedGazeCoordinatesLeft.Count)
            {
              var calData =
                  new XElement("Data",
                               new XElement("T", ct.targetNumber),
                               new XElement("X", ct.targetCoordinates.X),
                               new XElement("Y", ct.targetCoordinates.Y),
                               new XElement("PCLX", Math.Round(ct.pupilCentersLeft[j].X, 4)),
                               new XElement("PCLY", Math.Round(ct.pupilCentersLeft[j].Y, 4)),
                               new XElement("GACLX", Math.Round(ct.glintsLeft[j].AverageCenter.X, 4)),
                               new XElement("GACLY", Math.Round(ct.glintsLeft[j].AverageCenter.Y, 4)),
                               new XElement("EstGLX", Math.Round(ct.estimatedGazeCoordinatesLeft[j].X, 4)),
                               new XElement("EstGLY", Math.Round(ct.estimatedGazeCoordinatesLeft[j].Y, 4))
                      );

              if (Settings.Instance.Processing.TrackingMethod == TrackingMethodEnum.RemoteBinocular)
              {
                if (j < ct.pupilCentersRight.Count && j < ct.glintsRight.Count &&
                    j < ct.estimatedGazeCoordinatesRight.Count)
                {
                  // Add right eye if we're in binocular
                  calData.Add(
                      new XElement("PCRX", Math.Round(ct.pupilCentersRight[j].X, 4)),
                      new XElement("PCRY", Math.Round(ct.pupilCentersRight[j].Y, 4)),
                      new XElement("GACRX", Math.Round(ct.glintsRight[j].AverageCenter.X, 4)),
                      new XElement("GACRY", Math.Round(ct.glintsRight[j].AverageCenter.Y, 4)),
                      new XElement("EstGRX", Math.Round(ct.estimatedGazeCoordinatesRight[j].X, 4)),
                      new XElement("EstGRY", Math.Round(ct.estimatedGazeCoordinatesRight[j].Y, 4))
                      );
                }
              }

              // Add sample to calibrationdata element
              calibrationData.Add(calData);
            }
          }
          catch (Exception ex)
          {
            Console.Out.WriteLine("CalibrationExport.cs, error in GenerateCalibrationData(), message: " + ex.Message);
          }
        } // End per image loop
      } // End foreach

      return calibrationData;
    }
示例#4
0
 private static XElement GenerateResults(long id, CalibMethod calibration)
 {
   return new XElement("CalibrationResults",
                       new XElement("ID", id),
                       new XElement("NumImages", calibration.NumImages),
                       new XElement("Degrees", calibration.Degrees),
                       new XElement("DegreesLeft", calibration.DegreesLeft),
                       new XElement("DegreesRight", calibration.DegreesRight),
                       new XElement("AverageError", calibration.AverageError),
                       new XElement("AverageErrorLeft", calibration.AverageErrorLeft),
                       new XElement("AverageErrorRight", calibration.AverageErrorRight));
 }