/// <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); }
public void GazeDataThreadProc() { while (!_terminating) { EyeTrackingController.SampleStruct sampleData = new EyeTrackingController.SampleStruct(); if (_eyeTracker.iV_GetSample(ref sampleData) != (int)EyeTrackingController.RetCode.Success) { Thread.Sleep(_sleepTime); continue; } EventHandler <GazeEventArgs> handler = GazeEvent; if (handler != null) { GazeEventArgs gazeEventArgs = new GazeEventArgs(sampleData.leftEye.gazeX, sampleData.leftEye.gazeY, sampleData.timestamp / 1000, Fixation.Unknown, false); handler(this, gazeEventArgs); } Thread.Sleep(_sleepTime); } }
public void testExtractTrackerDataRightEyeZero() { EyeTrackingController.SampleStruct testdata = getTestdata(); testdata.leftEye.gazeX = 10; testdata.leftEye.gazeY = 10; testdata.rightEye.gazeX = 0; testdata.rightEye.gazeY = 0; GazeData gazeData = cut.ExtractTrackerData(testdata); Assert.IsNotNull(gazeData); assertEqualDecimal(5f, gazeData.GazePosX); assertEqualDecimal(5f, gazeData.GazePosY); }
public void testExtractTrackerDataWithZeroValues() { EyeTrackingController.SampleStruct testdata = getTestdata(); testdata.rightEye.gazeX = 0; testdata.rightEye.gazeY = 0; testdata.leftEye.gazeX = 0; testdata.leftEye.gazeY = 0; GazeData gazeData = cut.ExtractTrackerData(testdata); Assert.IsNotNull(gazeData); Assert.AreEqual(0, gazeData.GazePosX); Assert.AreEqual(0, gazeData.GazePosY); }
/// <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> /// 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); } }
protected EyeTrackingController.SampleStruct getTestdata() { EyeTrackingController.SampleStruct testdata = new EyeTrackingController.SampleStruct(); testdata.leftEye.diam = 10; testdata.leftEye.eyePositionX = 2; testdata.leftEye.eyePositionY = 3; testdata.leftEye.eyePositionZ = 4; testdata.rightEye.diam = 10; testdata.rightEye.eyePositionX = 8; testdata.rightEye.eyePositionY = 9; testdata.rightEye.eyePositionZ = 10; testdata.leftEye.gazeX = 10; testdata.leftEye.gazeY = 10; testdata.rightEye.gazeX = 20; testdata.rightEye.gazeY = 10; testdata.planeNumber = 13; testdata.timestamp = 12340000; return(testdata); }