/// <summary> /// Constructor: Init the Controller_MyGaze and set the SampleDataCallback. /// </summary> public GazeController() { ET_Device = new EyeTrackingController(); //CallbackDefinition m_samplecallBack = new GetSampleCallBack(GetSampleCallbackFunction); ET_Device.iV_SetSampleCallback(m_samplecallBack); }
/// <summary> /// Constructor: Init the Controller_MyGaze and set the SampleDataCallback. /// </summary> public GazeController() { ET_Device = new EyeTrackingController(); //CallbackDefinition m_samplecallBack = new GetSampleCallBack(GetSampleCallbackFunction); ET_Device.iV_SetSampleCallback(m_samplecallBack); }
/// <summary> /// Write the SystemInfoDataStruct into the gazeModel /// </summary> /// <param name="systemInfoData"></param> private void GetSystemInfoCallbackFuntion(EyeTrackingController.SystemInfoStruct systemInfoData) { gazeModel.systemInfo = systemInfoData; }
/// <summary> /// Write the SampleData into the gazeModel /// </summary> /// <param name="sampleData"></param> private void GetSampleCallbackFunction(EyeTrackingController.SampleStruct sampleData) { //Left Eye gazeModel.posLeftEye = new Vector3((float)sampleData.leftEye.eyePositionX, (float)sampleData.leftEye.eyePositionY, (float)sampleData.leftEye.eyePositionZ); gazeModel.posGazeLeft = new Vector2((float)sampleData.leftEye.gazeX, (float)sampleData.leftEye.gazeY); //Right Eye gazeModel.posRightEye = new Vector3((float)sampleData.rightEye.eyePositionX, (float)sampleData.rightEye.eyePositionY, (float)sampleData.rightEye.eyePositionZ); gazeModel.posGazeRight = new Vector2((float)sampleData.rightEye.gazeX, (float)sampleData.rightEye.gazeY); //PupilData gazeModel.diamLeftEye = (float) sampleData.leftEye.diam; gazeModel.diamRightEye= (float) sampleData.leftEye.diam; #if UNITY_EDITOR Rect gameView = getOffsetFromGameView(); Vector2 posGazeLeft = new Vector3(gazeModel.posGazeLeft.x, gazeModel.posGazeLeft.y - gameView.y); Vector2 posGazeRight = new Vector3(gazeModel.posGazeRight.x, gazeModel.posGazeRight.y - gameView.y); gazeModel.posGazeLeft = posGazeLeft; gazeModel.posGazeRight = posGazeRight; #else Vector2 offSet = Win32HelperClass.GetGameViewPosition(); if (offSet.x >= 0) { gazeModel.posGazeLeft = gazeModel.posGazeLeft - offSet; gazeModel.posGazeRight = gazeModel.posGazeRight - offSet; } else { gazeModel.posGazeLeft = offSet -gazeModel.posGazeLeft; gazeModel.posGazeRight = offSet - gazeModel.posGazeRight; } #endif gazeModel.gameScreenPosition = Win32HelperClass.GetGameViewPosition(); //Head Position gazeModel.posHead = (gazeModel.posLeftEye + gazeModel.posRightEye) * 0.5f; //TimeStamp of the Sample gazeModel.timeStamp = sampleData.timestamp; }
/// <summary> /// Write the SampleData into the gazeModel /// </summary> /// <param name="sampleData"></param> private void GetSampleCallbackFunction(EyeTrackingController.SampleStruct sampleData) { gazeModel.diamLeftEye = (float)sampleData.leftEye.diam; gazeModel.diamRightEye = (float)sampleData.leftEye.diam; gazeModel.posLeftEye = new Vector3((float)sampleData.leftEye.eyePositionX, (float)sampleData.leftEye.eyePositionY, (float)sampleData.leftEye.eyePositionZ); gazeModel.posRightEye = new Vector3((float)sampleData.rightEye.eyePositionX, (float)sampleData.rightEye.eyePositionY, (float)sampleData.rightEye.eyePositionZ); //GazePosition if (isFilterEnable) { if (actualCount < sampleCount) { samplesLeftGaze.Add(new Vector2((float)sampleData.leftEye.gazeX, (float)sampleData.leftEye.gazeY)); samplesRightGaze.Add(new Vector2((float)sampleData.rightEye.gazeX, (float)sampleData.rightEye.gazeY)); actualCount++; } else { Vector2 finalLeftGaze = Vector3.zero; Vector2 finalRightGaze = Vector3.zero; foreach (Vector2 sample in samplesLeftGaze) { finalLeftGaze += sample; } foreach (Vector2 sample in samplesRightGaze) { finalRightGaze += sample; } finalLeftGaze /= 3; finalRightGaze /= 3; gazeModel.posGazeLeft = finalLeftGaze; gazeModel.posGazeRight = finalRightGaze; samplesLeftGaze.Clear(); samplesRightGaze.Clear(); actualCount = 0; #if UNITY_EDITOR Rect gameView = getOffsetFromGameView(); Vector2 posGazeLeft = new Vector3(gazeModel.posGazeLeft.x, gazeModel.posGazeLeft.y - gameView.y); Vector2 posGazeRight = new Vector3(gazeModel.posGazeRight.x, gazeModel.posGazeRight.y - gameView.y); gazeModel.posGazeLeft = posGazeLeft; gazeModel.posGazeRight = posGazeRight; #else Vector2 offSet = Win32HelperClass.GetGameViewPosition(); if (offSet.x >= 0) { gazeModel.posGazeLeft = gazeModel.posGazeLeft - offSet; gazeModel.posGazeRight = gazeModel.posGazeRight - offSet; } else { gazeModel.posGazeLeft = offSet -gazeModel.posGazeLeft; gazeModel.posGazeRight = offSet - gazeModel.posGazeRight; } #endif } } else { Vector2 posGazeLeft = new Vector2((float)sampleData.leftEye.gazeX, (float)sampleData.leftEye.gazeY); Vector2 posGazeRight = new Vector2((float)sampleData.rightEye.gazeX, (float)sampleData.rightEye.gazeY); if(posGazeLeft == Vector2.zero && posGazeRight == Vector2.zero) { gazeModel.isEyeDetected = false; } else { gazeModel.isEyeDetected = true; //Left is Zero if(posGazeLeft == Vector2.zero && posGazeRight!= Vector2.zero) { posGazeLeft = posGazeRight; } //Right is Zero else if (posGazeRight == Vector2.zero && posGazeLeft != Vector2.zero) { posGazeRight = posGazeLeft; } gazeModel.posGazeLeft = posGazeLeft; gazeModel.posGazeRight = posGazeRight; } } gazeModel.gameScreenPosition = Win32HelperClass.GetGameViewPosition(); //Head Position gazeModel.posHead = (gazeModel.posLeftEye + gazeModel.posRightEye) * 0.5f; //TimeStamp of the Sample gazeModel.timeStamp = sampleData.timestamp; }
/// <summary> /// Write the SampleData into the gazeModel /// </summary> /// <param name="sampleData"></param> private void GetSampleCallbackFunction(EyeTrackingController.SampleStruct sampleData) { //Left Eye gazeModel.posLeftEye = new Vector3((float)sampleData.leftEye.eyePositionX, (float)sampleData.leftEye.eyePositionY, (float)sampleData.leftEye.eyePositionZ); gazeModel.posGazeLeft = new Vector2((float)sampleData.leftEye.gazeX, (float)sampleData.leftEye.gazeY); //Right Eye gazeModel.posRightEye = new Vector3((float)sampleData.rightEye.eyePositionX, (float)sampleData.rightEye.eyePositionY, (float)sampleData.rightEye.eyePositionZ); gazeModel.posGazeRight = new Vector2((float)sampleData.rightEye.gazeX, (float)sampleData.rightEye.gazeY); //PupilData gazeModel.diamLeftEye = (float)sampleData.leftEye.diam; gazeModel.diamRightEye = (float)sampleData.leftEye.diam; gazeModel.gameScreenPosition = Win32HelperClass.GetGameViewPosition(); //Head Position gazeModel.posHead = (gazeModel.posLeftEye + gazeModel.posRightEye) * 0.5f; //TimeStamp of the Sample gazeModel.timeStamp = sampleData.timestamp; }