public static void StartCalibration() { PupilTools.OnCalibrationStarted += OnCalibrationStarted; PupilTools.OnCalibrationEnded += OnCalibrationEnded; PupilTools.OnCalibrationFailed += OnCalibrationFailed; PupilTools.StartCalibration(); }
void Update() { if (updateInitialTranslation) { //might be inconsistent during the first frames -> updating until calibration starts UpdateEyesTranslation(); } if (PupilTools.IsCalibrating) { PupilTools.Calibration.UpdateCalibration(); } PupilTools.Connection.UpdateSubscriptionSockets(); if (PupilTools.IsConnected && Input.GetKeyUp(KeyCode.C)) { if (PupilTools.IsCalibrating) { PupilTools.StopCalibration(); } else { PupilTools.StartCalibration(); updateInitialTranslation = false; } } #if !UNITY_WSA if (Input.GetKeyUp(KeyCode.R)) { if (PupilTools.IsConnected) { if (!Recorder.isRecording) { Recorder.isRecording = true; Recorder.Start(); } else { Recorder.isRecording = false; Recorder.Stop(); } } else { print("Can not start recording without connection to pupil service"); } } #endif if (Instance.OnUpdate != null) { Instance.OnUpdate(); } }
void Update() { if (PupilTools.IsCalibrating) { PupilTools.Calibration.UpdateCalibration(); } PupilTools.Connection.UpdateSubscriptionSockets(); if (PupilTools.IsConnected && Input.GetKeyUp(KeyCode.C)) { if (PupilTools.IsCalibrating) { PupilTools.StopCalibration(); } else { PupilTools.StartCalibration(); } } #if !UNITY_WSA //Start Recording as soon as the scene is loaded after calibration successfully ended if (PupilTools.IsGazing) { if (!Recorder.isRecording) { Recorder.isRecording = true; Recorder.Start(); } } //if (Input.GetKeyUp(KeyCode.R)) //{ // if (PupilTools.IsConnected) // { // if (!Recorder.isRecording) // { // Recorder.isRecording = true; // Recorder.Start(); // } // else // { // Recorder.isRecording = false; // Recorder.Stop(); // } // } // else // print("Can not start recording without connection to pupil service"); //} #endif if (Instance.OnUpdate != null) { Instance.OnUpdate(); } }
void Update() { if (Input.GetKeyUp(KeyCode.D)) { moreGazeDots = !moreGazeDots; } if (PupilTools.IsCalibrating) { PupilTools.Calibration.UpdateCalibration(); } PupilTools.Connection.UpdateSubscriptionSockets(); if (PupilTools.IsConnected && Input.GetKeyUp(KeyCode.C)) { if (PupilTools.IsCalibrating) { PupilTools.StopCalibration(); } else { PupilTools.StartCalibration(); } } #if !UNITY_WSA if (Input.GetKeyUp(KeyCode.R)) { if (PupilTools.IsConnected) { if (!Recorder.isRecording) { Recorder.isRecording = true; Recorder.Start(); } else { Recorder.isRecording = false; Recorder.Stop(); } } else { print("Can not start recording without connection to pupil service"); } } #endif if (Instance.OnUpdate != null) { Instance.OnUpdate(); } }
void Update() { Settings.framePublishing.UpdateEyeTextures(); if (Settings.DataProcessState == PupilSettings.EStatus.Calibration) { if (Settings.calibration.currentStatus == Calibration.Status.Started) { Settings.calibration.UpdateCalibration(); } } Settings.connection.UpdateSubscriptionSockets(); if (Input.GetKeyUp(KeyCode.C)) { if (Settings.DataProcessState == PupilSettings.EStatus.Calibration) { PupilTools.StopCalibration(); } else { PupilTools.StartCalibration(); } } #if !UNITY_WSA if (Input.GetKeyUp(KeyCode.R)) { if (Settings.connection.isConnected) { if (!Recorder.isRecording) { Recorder.isRecording = true; Recorder.Start(); } else { Recorder.isRecording = false; Recorder.Stop(); } } else { print("Can not start recording without connection to pupil service"); } } #endif if (OnUpdate != null) { OnUpdate(); } }
public void OnCalibrationButtonClicked() { if (PupilTools.IsCalibrating) { PupilTools.StopCalibration(); } else { PupilTools.StartCalibration(); ResetCanvasUI(false); calibrationText.text = ""; } }
public void OnCalibrationButtonClicked() { if (PupilTools.DataProcessState == Pupil.EStatus.Calibration) { PupilTools.StopCalibration(); } else { PupilTools.StartCalibration(); ResetCanvasUI(false); calibrationText.text = ""; } }
void Update() { Settings.framePublishing.UpdateEyeTextures(); if (Settings.dataProcess.state == PupilSettings.EStatus.Calibration) { if (Settings.calibration.initialized) { PupilTools.Calibrate(); } } else if (Settings.connection.subscribeSocket != null) { Settings.connection.subscribeSocket.Poll(); } if (Input.GetKeyUp(KeyCode.C)) { if (Settings.dataProcess.state == PupilSettings.EStatus.Calibration) { PupilTools.StopCalibration(); } else { //LoggerBehavior.SceneStatus = "calibrating"; PupilTools.StartCalibration(); } } if (Input.GetKeyUp(KeyCode.R)) { if (!Recorder.isRecording) { Recorder.isRecording = true; Recorder.Start(); } else { Recorder.isRecording = false; Recorder.Stop(); } } if (OnUpdate != null) { OnUpdate(); } }
private void DrawMainMenu() { Event e = Event.current; GUILayout.Space(10); ////////////////////////////CALIBRATE BUTTON//////////////////////////// if (PupilTools.IsConnected) { if (!PupilTools.IsCalibrating) { if (GUILayout.Button("Start Calibration", GUILayout.Height(50))) { if (Application.isPlaying) { PupilTools.StartCalibration(); //EditorApplication.update += CheckCalibration; } else { EditorUtility.DisplayDialog("Pupil service message", "You can only use calibration in playmode", "Understood"); } } } else { if (GUILayout.Button("Stop Calibration", GUILayout.Height(50))) { PupilTools.StopCalibration(); } } } else { GUI.enabled = false; GUILayout.Button("Start Calibration (Requires Connection to Pupil)", GUILayout.Height(50)); } GUI.enabled = true; ////////////////////////////CALIBRATE BUTTON//////////////////////////// GUILayout.Space(5); ////////////////////////////RECORDING BUTTON//////////////////////////// if (PupilTools.IsConnected) { EditorGUI.BeginChangeCheck(); Recorder.isRecording = GUILayout.Toggle(Recorder.isRecording, !Recorder.isRecording ? "Start Recording" : "Stop Recording", "Button", GUILayout.Height(50)); GUI.enabled = true; GUI.backgroundColor = Color.white; if (EditorGUI.EndChangeCheck()) { if (Recorder.isRecording) { Recorder.Start(); EditorApplication.update += CheckRecording; EditorUtility.SetDirty(target); } else { Recorder.Stop(); } } } else { GUI.enabled = false; GUILayout.Button("Start Recording (Requires Connection to Pupil)", GUILayout.Height(50)); } GUI.enabled = true; ////////////////////////////RECORDING BUTTON//////////////////////////// GUILayout.Space(20); GUI.skin = default(GUISkin); GUI.depth = 0; GUI.color = Color.white; GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));//Separator Line GUI.depth = 1; GUI.color = Color.white; if (pupilSettings.customGUIVariables.bools.isAdvanced) { if (GUILayout.Button("IsConnected")) { PupilTools.IsConnected = true; } GUI.backgroundColor = Color.white; GUILayout.Space(10); pupilSettings.debug.printSampling = GUILayout.Toggle(pupilSettings.debug.printSampling, "Print Sampling", "Button"); pupilSettings.debug.printMessage = GUILayout.Toggle(pupilSettings.debug.printMessage, "Print Msg", "Button"); pupilSettings.debug.printMessageType = GUILayout.Toggle(pupilSettings.debug.printMessageType, "Print Msg Types", "Button"); } }
private void DrawMainMenu() { Event e = Event.current; GUILayout.Space(10); ////////////////////////////CALIBRATE BUTTON//////////////////////////// if (PupilTools.Settings.connection.isConnected) { if (PupilTools.Settings.dataProcess.state != PupilSettings.EStatus.Calibration) { if (GUILayout.Button("Calibrate", GUILayout.Height(50))) { if (Application.isPlaying) { PupilTools.StartCalibration(); //EditorApplication.update += CheckCalibration; } else { EditorUtility.DisplayDialog("Pupil service message", "You can only use calibration in playmode", "Understood"); } } } else { if (GUILayout.Button("Stop Calibration", GUILayout.Height(50))) { PupilTools.StopCalibration(); } } } else { GUI.enabled = false; GUILayout.Button("Calibrate (Not Connected !)", GUILayout.Height(50)); } GUI.enabled = true; ////////////////////////////CALIBRATE BUTTON//////////////////////////// GUILayout.Space(5); ////////////////////////////RECORDING BUTTON//////////////////////////// EditorGUI.BeginChangeCheck(); if (Recorder.isProcessing) { GUI.enabled = false; Recorder.isRecording = GUILayout.Toggle(Recorder.isRecording, "Processing ... ", "Button", GUILayout.Height(50)); } else { Recorder.isRecording = GUILayout.Toggle(Recorder.isRecording, "Recording", "Button", GUILayout.Height(50)); } GUI.enabled = true; GUI.backgroundColor = Color.white; if (EditorGUI.EndChangeCheck()) { if (Recorder.isRecording) { Recorder.Start(); EditorApplication.update += CheckRecording; EditorUtility.SetDirty(target); } else { Recorder.Stop(); } } ////////////////////////////RECORDING BUTTON//////////////////////////// /// GUILayout.Space(5); ////////////////////////////OPERATOR MONITOR BUTTON//////////////////////////// EditorGUI.BeginChangeCheck(); pupilTracker.isOperatorMonitor = GUILayout.Toggle(pupilTracker.isOperatorMonitor, "Operator Monitor", "Button", GUILayout.MinWidth(100), GUILayout.Height(50)); if (EditorGUI.EndChangeCheck()) { if (pupilTracker.isOperatorMonitor) { pupilTracker.debugInstance.CloseCalibrationDebugView(); // Debug.Log("instantiate operator monitor"); OperatorMonitor.Instantiate(); } else { if (pupilTracker.OperatorMonitorProperties[0].OperatorCamera != null) { OperatorMonitor.Instance.ExitOperatorMonitor(); } } } ////////////////////////////OPERATOR MONITOR BUTTON//////////////////////////// GUILayout.Space(10); GUI.skin = default(GUISkin); GUILayout.Space(100); GUI.depth = 0; GUI.color = Color.white; GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));//Separator Line GUI.depth = 1; GUI.color = Color.white; if (pupilSettings.customGUIVariables.bools.isAdvanced) { if (GUILayout.Button("IsConnected")) { PupilTools.Settings.connection.isConnected = true; } // pupilTracker.debugInstance.DebugVariables.packetsOnMainThread = GUILayout.Toggle (pupilTracker.debugInstance.DebugVariables.packetsOnMainThread, "Process Packets on Main Thread", "Button", GUILayout.MinWidth (100)); GUI.backgroundColor = Color.white; GUILayout.Space(10); pupilSettings.debug.printSampling = GUILayout.Toggle(pupilSettings.debug.printSampling, "Print Sampling", "Button"); pupilSettings.debug.printMessage = GUILayout.Toggle(pupilSettings.debug.printMessage, "Print Msg", "Button"); pupilSettings.debug.printMessageType = GUILayout.Toggle(pupilSettings.debug.printMessageType, "Print Msg Types", "Button"); // pupilTracker.DebugVariables.subscribeAll = GUILayout.Toggle (pupilTracker.DebugVariables.subscribeAll, "Subscribe to all", "Button"); // // pupilTracker.DebugVariables.subscribeFrame = GUILayout.Toggle (pupilTracker.DebugVariables.subscribeFrame, "Subscribe to frame.", "Button"); // // pupilTracker.DebugVariables.subscribeGaze = GUILayout.Toggle (pupilTracker.DebugVariables.subscribeGaze, "Subscribe to gaze.", "Button"); // // pupilTracker.DebugVariables.subscribeNotify = GUILayout.Toggle (pupilTracker.DebugVariables.subscribeNotify, "Subscribe to notifications.", "Button"); } }
public void InterpreteUDPData(byte[] data) { switch (data[0]) { // Connection established case (byte)'0': switch (data [1]) { case (byte)'I': UnityEngine.Debug.Log("Connection established"); PupilTools.IsConnected = true; break; case (byte)'i': UnityEngine.Debug.Log("Connection closed"); PupilTools.IsConnected = false; break; case (byte)'S': // Start gazing command received break; case (byte)'s': // Stop gazing command received break; default: UnityEngine.Debug.Log("Unknown response: " + (char)data[1]); break; } break; case (byte)'E': switch (data [1]) { case (byte)'C': if (data [2] == (byte)'S') // "notify.calibration.successful" { UnityEngine.Debug.Log("notify.calibration.successful"); PupilTools.CalibrationFinished(); } else if (data [2] == (byte)'F') // "notify.calibration.failed" { UnityEngine.Debug.Log("notify.calibration.failed"); PupilTools.CalibrationFailed(); } else { UnityEngine.Debug.Log("Unknown calibration ended event"); } break; case (byte)'G': if (data [2] == (byte)'2') { if (data [3] == (byte)'1') { //UnityEngine.Debug.Log("Left eye position received"); var leftEyePosition = FloatArrayFromPacket(data, 4); PupilData._2D.LeftEyePosUDP.x = leftEyePosition [0]; PupilData._2D.LeftEyePosUDP.y = leftEyePosition [1]; // UnityEngine.Debug.Log ("Left eye position: " + PupilData._2D.LeftEyePosUDP.ToString()); } else if (data [3] == (byte)'0') { //UnityEngine.Debug.Log("Right eye position received"); var rightEyePosition = FloatArrayFromPacket(data, 4); PupilData._2D.RightEyePosUDP.x = rightEyePosition [0]; PupilData._2D.RightEyePosUDP.y = rightEyePosition [1]; // UnityEngine.Debug.Log ("Right Eye Position: " + PupilData._2D.RightEyePosUDP.ToString()); } else if (data [3] == (byte)'2') { var gaze2DPosition = FloatArrayFromPacket(data, 4); PupilData._2D.Gaze2DPosUDP.x = gaze2DPosition [0]; PupilData._2D.Gaze2DPosUDP.y = gaze2DPosition [1]; // UnityEngine.Debug.Log ("Gazepoint 2D: " + PupilData._2D.Gaze2DPosUDP.ToString()); } else { UnityEngine.Debug.Log("Unknown gaze 2d data"); } } else if (data [2] == (byte)'3') { var gaze3DPosition = FloatArrayFromPacket(data, 4); PupilData._3D.Gaze3DPosUDP.x = gaze3DPosition [0] / PupilSettings.PupilUnitScalingFactor; PupilData._3D.Gaze3DPosUDP.y = gaze3DPosition [1] / PupilSettings.PupilUnitScalingFactor; PupilData._3D.Gaze3DPosUDP.z = gaze3DPosition [2] / PupilSettings.PupilUnitScalingFactor; // UnityEngine.Debug.Log ("Gazepoint 3D: " + PupilData._3D.Gaze3DPosUDP.ToString()); } else { UnityEngine.Debug.Log("Unknown gaze event"); } break; default: UnityEngine.Debug.Log("Unknown event"); break; } break; case 90: UnityEngine.Debug.Log("Start/stop calibration command"); if (data [1] == 1) { PupilTools.StartCalibration(); } else { PupilTools.StopCalibration(); } break; case 91: UnityEngine.Debug.Log("Forcing 2D calibration mode (Pupil version < 1 detected)"); PupilTools.CalibrationMode = Calibration.Mode._2D; break; default: UnityEngine.Debug.Log(StringFromPacket(data)); break; } }
public void InterpreteUDPData(byte[] data) { if (debuging) { Debug.Log("Receive data: " + Encoding.ASCII.GetString(data)); } switch (data[0]) { // Connection established case (byte)'0': switch (data [1]) { case (byte)'I': UnityEngine.Debug.Log("Connection established"); PupilTools.IsConnected = true; break; case (byte)'i': UnityEngine.Debug.Log("Connection closed"); PupilTools.IsConnected = false; break; case (byte)'S': // Start gazing command received break; case (byte)'s': // Stop gazing command received break; default: { UnityEngine.Debug.Log("Unknown response: " + (char)data[1]); debuging = false; } break; } break; case (byte)'E': switch (data [1]) { case (byte)'C': if (data [2] == (byte)'S') // "notify.calibration.successful" { UnityEngine.Debug.Log("notify.calibration.successful"); PupilTools.CalibrationFinished(); } else if (data [2] == (byte)'F') // "notify.calibration.failed" { UnityEngine.Debug.Log("notify.calibration.failed"); PupilTools.CalibrationFailed(); } else { UnityEngine.Debug.Log("Unknown calibration ended event"); } break; case (byte)'G': if (data [2] == (byte)'2') { if (data [3] == (byte)'1') { //UnityEngine.Debug.Log("Left eye position received"); PupilTools.UpdateGazePostion(PupilSettings.gaze2DLeftEyeKey, FloatArrayFromPacket(data, 4)); } else if (data [3] == (byte)'0') { //UnityEngine.Debug.Log("Right eye position received"); PupilTools.UpdateGazePostion(PupilSettings.gaze2DRightEyeKey, FloatArrayFromPacket(data, 4)); } else if (data [3] == (byte)'2') { PupilTools.UpdateGazePostion(PupilSettings.gaze2DKey, FloatArrayFromPacket(data, 4)); } else { UnityEngine.Debug.Log("Unknown gaze 2d data"); } } else if (data [2] == (byte)'3') { PupilTools.UpdateGazePostion(PupilSettings.gaze3DKey, FloatArrayFromPacket(data, 4)); } else { UnityEngine.Debug.Log("Unknown gaze event"); } break; default: UnityEngine.Debug.Log("Unknown event"); break; } break; case 90: UnityEngine.Debug.Log("Start/stop calibration command"); if (data [1] == 1) { PupilTools.StartCalibration(); } else { PupilTools.StopCalibration(); } break; case 91: UnityEngine.Debug.Log("Forcing 2D calibration mode (Pupil version < 1 detected)"); PupilTools.CalibrationMode = Calibration.Mode._2D; break; case (byte)'R': if (PupilSettings.Instance.debug.printSampling) { Debug.Log("Reference points received"); } break; default: UnityEngine.Debug.Log(StringFromPacket(data)); break; } }