/// <summary> /// Calibrations the callback function. /// </summary> /// <param name="calibrationPoint">The calibration point.</param> void CalibrationCallbackFunction(EyeTrackingController.CalibrationPointStruct calibrationPoint) { string data = ("Data from CalibrationCallback - Number:" + calibrationPoint.number + " PosX:" + calibrationPoint.positionX + " PosY:" + calibrationPoint.positionY); log("CalibrationCallbackFunction: " + data); }
/// <summary> /// Initializes this instance. /// </summary> public void initialize() { ETDevice = new EyeTrackingController(); m_CalibrationCallback = new CalibrationCallback(CalibrationCallbackFunction); m_SampleCallback = new GetSampleCallback(GetSampleCallbackFunction); m_EventCallback = new GetEventCallback(GetEventCallbackFunction); m_EyeImageCallback = new GetEyeImageCallback(GetEyeImageCallbackFunction); m_SceneVideoCallback = new GetSceneVideoCallback(GetSceneVideoCallbackFunction); m_TrackingMonitorCallback = new GetTrackingMonitorCallback(GetTrackingMonitorCallbackFunction); }
/// <summary> /// Gets the sample callback function. /// </summary> /// <param name="sampleData">The sample data.</param> void GetSampleCallbackFunction(EyeTrackingController.SampleStruct sampleData) { string data = ("Data from SampleCallback - timestamp: " + sampleData.timestamp.ToString() + " - GazeRX: " + sampleData.rightEye.gazeX.ToString() + " - GazeRY: " + sampleData.rightEye.gazeY.ToString() + " - GazeLX: " + sampleData.leftEye.gazeX.ToString() + " - GazeLY: " + sampleData.leftEye.gazeY.ToString() + " - DiamRX: " + sampleData.rightEye.diam.ToString() + " - DiamLX: " + sampleData.leftEye.diam.ToString() + " - DistanceR: " + sampleData.rightEye.eyePositionZ.ToString() + " - DistanceL: " + sampleData.leftEye.eyePositionZ.ToString()); //log("GetSampleCallbackFunction: " + data); if (listener != null) { listener.onSampleData(sampleData); } }
/// <summary> /// Gets the event callback function. /// </summary> /// <param name="eventData">The event data.</param> void GetEventCallbackFunction(EyeTrackingController.EventStruct eventData) { string data = ("Data from EventCallback - eye: " + eventData.eye.ToString() + " Event: " + eventData.eventType + " startTime: " + eventData.startTime.ToString() + " End:" + eventData.endTime.ToString() + " duration:" + eventData.duration.ToString() + " PosX:" + eventData.positionX.ToString() + " PosY:" + eventData.positionY.ToString()); //log("GetEventCallbackFunction: " + data); }
/// <summary> /// Gets the scene video callback function. /// </summary> /// <param name="image">The image.</param> void GetSceneVideoCallbackFunction(EyeTrackingController.ImageStruct image) { }
/// <summary> /// Gets the eye image callback function. /// </summary> /// <param name="image">The image.</param> void GetEyeImageCallbackFunction(EyeTrackingController.ImageStruct image) { }
/// <summary> /// Gets the tracking monitor callback function. /// </summary> /// <param name="image">The image.</param> void GetTrackingMonitorCallbackFunction(EyeTrackingController.ImageStruct image) { }
/// <summary> /// Ons the sample data. /// </summary> /// <param name="data">The data.</param> public void onSampleData(EyeTrackingController.SampleStruct data) { lock (LOCK) { if (!IsTracking) { return; } if (this.GazeDataChanged == null) { return; } GazeData gazeData = ExtractTrackerData(data); GazeDataChangedEventArgs eventArgs = new GazeDataChangedEventArgs(gazeData); this.OnGazeDataChanged(eventArgs); } }
/// <summary> /// Extracts the tracker data. /// </summary> /// <param name="data">The data.</param> /// <returns></returns> public GazeData ExtractTrackerData(EyeTrackingController.SampleStruct data) { GazeData result = new GazeData(); float gazePosXLeft = Convert.ToSingle(data.leftEye.gazeX); float gazePosXRight = Convert.ToSingle(data.rightEye.gazeX); float gazePosYLeft = Convert.ToSingle(data.leftEye.gazeY); float gazePosYRight = Convert.ToSingle(data.rightEye.gazeY); result.GazePosX = (gazePosXLeft + gazePosXRight) / 2; result.GazePosY = (gazePosYLeft + gazePosYRight) / 2; if (result.GazePosX > 1000 * 10) { result.GazePosX = result.GazePosX / 1000; } if (result.GazePosY > 1000 * 10) { result.GazePosY = result.GazePosY / 1000; } long MICROSECONDS = 1000; result.Time = (data.timestamp / MICROSECONDS); this.lastTime = result.Time; result.PupilDiaX = Convert.ToSingle(data.leftEye.diam); result.PupilDiaY = Convert.ToSingle(data.rightEye.diam); return result; }