Пример #1
0
		public override void Calibrate(CalibrationResultHandler callback)
		{
			IsCalibrated = false;		
			string message = "Not calibrated";
			Dictionary<string, object> calibrationProperties = new Dictionary<string, object>();
			
			try {
				int ret = 0;
				
				int targetSize = 20;				
				
				EyeTrackingController.EyeTrackingController.CalibrationStruct m_CalibrationData = new EyeTrackingController.EyeTrackingController.CalibrationStruct ();
                m_CalibrationData.displayDevice = (int)DisplayDevice.Primary;
				m_CalibrationData.autoAccept = 1;
                m_CalibrationData.method = (int)CalibrationPoints;
				m_CalibrationData.visualization = 1;
				m_CalibrationData.speed = 0;
				m_CalibrationData.targetShape = 2;
				m_CalibrationData.backgroundColor = 230;
				m_CalibrationData.foregroundColor = 250;
				m_CalibrationData.targetSize = targetSize;
				m_CalibrationData.targetFilename = "";

				DebugLog.Info("SMI Eye Tracker: Setup calibration");
				ret = ETDevice.iV_SetupCalibration (ref m_CalibrationData);
				if (ret != 1) 
                {
					throw new Exception("Calibration setup returned an error: " + GetErrorMessage(ret));
				}

				DebugLog.Info("SMI Eye Tracker: Start calibration");
				ret = ETDevice.iV_Calibrate();
				if (ret != 1) 
                {
                    throw new Exception("Calibration returned an error: " + GetErrorMessage(ret));
				}

				DebugLog.Info("SMI Eye Tracker: Start validation");
				ret = ETDevice.iV_Validate();
				if (ret != 1) 
				{
					throw new Exception("Validation returned an error: " + GetErrorMessage(ret));
				}

				DebugLog.Info("SMI Eye Tracker: Get accuracy data");
				EyeTrackingController.EyeTrackingController.AccuracyStruct accuracyData = new EyeTrackingController.EyeTrackingController.AccuracyStruct();
				ret = ETDevice.iV_GetAccuracy(ref accuracyData, 1);
				if (ret != 1) 
				{
					throw new Exception("GetAccuracy returned an error: " + GetErrorMessage(ret));
				}

				DebugLog.Info("SMI Eye Tracker: Calibration and validation complete");
				IsCalibrated = true;

				message = string.Format("Successfully calibrated SMI eye tracker.\nLeft Eye Deviation = ({0}, {1})\nRight Eye Deviation = ({2}, {3})", 
				                        accuracyData.deviationXLeft, 
				                        accuracyData.deviationYLeft, 
				                        accuracyData.deviationXRight, 
				                        accuracyData.deviationYRight);

				calibrationProperties["deviationXLeft"] = accuracyData.deviationXLeft;
				calibrationProperties["deviationYLeft"] = accuracyData.deviationYLeft;
				calibrationProperties["deviationXRight"] = accuracyData.deviationXRight;
				calibrationProperties["deviationYRight"] = accuracyData.deviationYRight;
			}
            catch (Exception e) 
            {
				message = string.Format("Unable to calibrate SMI server ({0}:{1}). {2}", ServerRecvAddress, ServerRecvPort, e.Message);
			}

			if (callback != null)
			{			
				callback(IsCalibrated, message, calibrationProperties);
			}
		}
Пример #2
0
        public override void Calibrate(CalibrationResultHandler callback)
        {
            IsCalibrated = false;
            string message = "Not calibrated";
            Dictionary <string, object> calibrationProperties = new Dictionary <string, object>();

            try {
                int ret = 0;

                int targetSize = 20;

                EyeTrackingController.EyeTrackingController.CalibrationStruct m_CalibrationData = new EyeTrackingController.EyeTrackingController.CalibrationStruct();
                m_CalibrationData.displayDevice   = (int)DisplayDevice.Primary;
                m_CalibrationData.autoAccept      = 1;
                m_CalibrationData.method          = (int)CalibrationPoints;
                m_CalibrationData.visualization   = 1;
                m_CalibrationData.speed           = 0;
                m_CalibrationData.targetShape     = 2;
                m_CalibrationData.backgroundColor = 230;
                m_CalibrationData.foregroundColor = 250;
                m_CalibrationData.targetSize      = targetSize;
                m_CalibrationData.targetFilename  = "";

                DebugLog.Info("SMI Eye Tracker: Setup calibration");
                ret = ETDevice.iV_SetupCalibration(ref m_CalibrationData);
                if (ret != 1)
                {
                    throw new Exception("Calibration setup returned an error: " + GetErrorMessage(ret));
                }

                DebugLog.Info("SMI Eye Tracker: Start calibration");
                ret = ETDevice.iV_Calibrate();
                if (ret != 1)
                {
                    throw new Exception("Calibration returned an error: " + GetErrorMessage(ret));
                }

                DebugLog.Info("SMI Eye Tracker: Start validation");
                ret = ETDevice.iV_Validate();
                if (ret != 1)
                {
                    throw new Exception("Validation returned an error: " + GetErrorMessage(ret));
                }

                DebugLog.Info("SMI Eye Tracker: Get accuracy data");
                EyeTrackingController.EyeTrackingController.AccuracyStruct accuracyData = new EyeTrackingController.EyeTrackingController.AccuracyStruct();
                ret = ETDevice.iV_GetAccuracy(ref accuracyData, 1);
                if (ret != 1)
                {
                    throw new Exception("GetAccuracy returned an error: " + GetErrorMessage(ret));
                }

                DebugLog.Info("SMI Eye Tracker: Calibration and validation complete");
                IsCalibrated = true;

                message = string.Format("Successfully calibrated SMI eye tracker.\nLeft Eye Deviation = ({0}, {1})\nRight Eye Deviation = ({2}, {3})",
                                        accuracyData.deviationXLeft,
                                        accuracyData.deviationYLeft,
                                        accuracyData.deviationXRight,
                                        accuracyData.deviationYRight);

                calibrationProperties["deviationXLeft"]  = accuracyData.deviationXLeft;
                calibrationProperties["deviationYLeft"]  = accuracyData.deviationYLeft;
                calibrationProperties["deviationXRight"] = accuracyData.deviationXRight;
                calibrationProperties["deviationYRight"] = accuracyData.deviationYRight;
            }
            catch (Exception e)
            {
                message = string.Format("Unable to calibrate SMI server ({0}:{1}). {2}", ServerRecvAddress, ServerRecvPort, e.Message);
            }

            if (callback != null)
            {
                callback(IsCalibrated, message, calibrationProperties);
            }
        }