cancel
Showing results for 
Search instead for 
Did you mean: 

How to record and save the eye-tracking (Gaze) data in Quest Pro?

ashu.180035
Honored Guest

I am looking to capture and save eye-tracking metrics like gaze vectors and pupil dilation data from the Quest Pro device. I have already set up eye tracking and enabled cloud backup, but I am having trouble with the actual data saving process. I attempted to follow a tutorial on the Oculus developer site but didn't achieve the desired result. I wrote the script below to record and save eye-tracking data, but this does not work.

Any help would be appreciated. 

 

using UnityEngine;
using System.IO;
using UnityEngine.XR;
using Unity.XR.Oculus;
public class EyeTrackingDataRecorder : MonoBehaviour
{
    private string dataPath;
    void Start()
    {
        // Define the data path where the eye tracking data will be stored.
        dataPath = Application.persistentDataPath + "/EyeTrackingData.csv";
        // Write the CSV header
        WriteData("Timestamp,LeftEyeDirectionX,LeftEyeDirectionY,LeftEyeDirectionZ,RightEyeDirectionX,RightEyeDirectionY,RightEyeDirectionZ\n");
    }
    void Update()
    {
        if (OVRManager.isHmdPresent)
        {
            // Fetch the latest eye tracking data from the OVRPlugin
            var eyeTrackingData = OVRPlugin.GetEyeTrackingData(OVRPlugin.Eye.All);
            if (eyeTrackingData.IsValid)
            {
                // Assuming you're using the combined gaze direction
                Vector3 leftEyeDirection = eyeTrackingData.LeftEyeGazeDirection;
                Vector3 rightEyeDirection = eyeTrackingData.RightEyeGazeDirection;
                // Construct the data string
                string dataString = $"{Time.timeSinceLevelLoad},{leftEyeDirection.x},{leftEyeDirection.y},{leftEyeDirection.z},{rightEyeDirection.x},{rightEyeDirection.y},{rightEyeDirection.z}\n";
                // Write the data string to the file
                WriteData(dataString);
            }
        }
    }
    private void WriteData(string dataString)
    {
        // Append the data string to the file at dataPath
        File.AppendAllText(dataPath, dataString);
    }
    void OnApplicationQuit()
    {
        // Cleanup if needed
    }
}

 

  

1 REPLY 1

harshpalan
Honored Guest

Were you able to get it working?