Jump to content

Recommended Posts

Posted

My Unity got crashed when I ran the script below. 

using UnityEngine;
using VIVE.OpenXR;
using VIVE.OpenXR.EyeTracker;

public class EyeTracker : MonoBehaviour
{
    void Update()
    {
        XrSingleEyeGazeDataHTC[] gazeData;
        XR_HTC_eye_tracker.Interop.GetEyeGazeData(out gazeData);

        if (gazeData != null)
        {
            XrSingleEyeGazeDataHTC leftGaze = gazeData[(int)XrEyePositionHTC.XR_EYE_POSITION_LEFT_HTC];
            if (leftGaze.isValid)
            {
                Debug.Log($"Left Eye Gaze Position: {leftGaze.gazePose.position.ToUnityVector()}");
                Debug.Log($"Left Eye Gaze Orientation: {leftGaze.gazePose.orientation.ToUnityQuaternion()}");
            }
            else
            {
                Debug.Log("Left Eye Gaze Data is Invalid.");
            }

            XrSingleEyeGazeDataHTC rightGaze = gazeData[(int)XrEyePositionHTC.XR_EYE_POSITION_RIGHT_HTC];
            if (rightGaze.isValid)
            {
                Debug.Log($"Right Eye Gaze Position: {rightGaze.gazePose.position.ToUnityVector()}");
                Debug.Log($"Right Eye Gaze Orientation: {rightGaze.gazePose.orientation.ToUnityQuaternion()}");
            }
            else
            {
                Debug.Log("Right Eye Gaze Data is Invalid.");
            }
        }

        XrSingleEyeGeometricDataHTC[] geometricData;
        XR_HTC_eye_tracker.Interop.GetEyeGeometricData(out geometricData);

        if (geometricData != null)
        {
            XrSingleEyeGeometricDataHTC leftGeom = geometricData[(int)XrEyePositionHTC.XR_EYE_POSITION_LEFT_HTC];
            if (leftGeom.isValid)
            {
                Debug.Log($"Left Eye Openness: {leftGeom.eyeOpenness}");
                Debug.Log($"Left Eye Squeeze: {leftGeom.eyeSqueeze}");
                Debug.Log($"Left Eye Wide: {leftGeom.eyeWide}");
            }
            else
            {
                Debug.Log("Left Eye Geometric Data is Invalid.");
            }

            XrSingleEyeGeometricDataHTC rightGeom = geometricData[(int)XrEyePositionHTC.XR_EYE_POSITION_RIGHT_HTC];
            if (rightGeom.isValid)
            {
                Debug.Log($"Right Eye Openness: {rightGeom.eyeOpenness}");
                Debug.Log($"Right Eye Squeeze: {rightGeom.eyeSqueeze}");
                Debug.Log($"Right Eye Wide: {rightGeom.eyeWide}");
            }
            else
            {
                Debug.Log("Right Eye Geometric Data is Invalid.");
            }
        }

        XrSingleEyePupilDataHTC[] pupilData;
        XR_HTC_eye_tracker.Interop.GetEyePupilData(out pupilData);

        if (pupilData != null)
        {
            XrSingleEyePupilDataHTC leftPupil = pupilData[(int)XrEyePositionHTC.XR_EYE_POSITION_LEFT_HTC];
            if (leftPupil.isDiameterValid)
            {
                Debug.Log($"Left Eye Pupil Diameter: {leftPupil.pupilDiameter}");
            }
            else
            {
                Debug.Log("Left Eye Pupil Diameter is Invalid.");
            }

            if (leftPupil.isPositionValid)
            {
                Debug.Log($"Left Eye Pupil Position: {leftPupil.pupilPosition}");
            }
            else
            {
                Debug.Log("Left Eye Pupil Position is Invalid.");
            }

            XrSingleEyePupilDataHTC rightPupil = pupilData[(int)XrEyePositionHTC.XR_EYE_POSITION_RIGHT_HTC];
            if (rightPupil.isDiameterValid)
            {
                Debug.Log($"Right Eye Pupil Diameter: {rightPupil.pupilDiameter}");
            }
            else
            {
                Debug.Log("Right Eye Pupil Diameter is Invalid.");
            }

            if (rightPupil.isPositionValid)
            {
                Debug.Log($"Right Eye Pupil Position: {rightPupil.pupilPosition}");
            }
            else
            {
                Debug.Log("Right Eye Pupil Position is Invalid.");
            }
        }
    }
}

Then I tried sample scene, that contain the script like above. However my unity crashed again. 

My environment is this

- Unity 2021.3.9f1

- VIVE OpenXR Plugin Version 2.4.2

- HMD: VIVE Pro eye

Because of  this situation, I googled about old versions of eyes and facial tracker SDK, but it seems HTC removed all sources. 
Like the URL below

https://developer.vive.com/resources/vive-sense/eye-and-facial-tracking-sdk/download/latest/

Is there any way to track eye gaze data?
If anyone has the official URL that provide older versions of SDK ( it means non-OpenXR SDK) or know the method to do eye tracking by using current SDK (VIVE OpenXR Plugin), please teach me how.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...