Home Forums XR Discussions How to get eye coordinates from HTC Vive Pro Eye

This topic contains 18 replies, has 4 voices, and was last updated by  Grant [Tobii] 2 months, 1 week ago.

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #12061

    stella
    Participant

    Thanks all for your responses. i was having similar questions and your answers were helpful to me.

    #12063

    Grant [Tobii]
    Keymaster

    Hi @dragontattoo, great! glad to hear it 🙂 Please don’t hesitate to get in touch again should you require any further assistance. Best Wishes.

    #12464

    Marco Otte
    Participant

    Here’s what I did and as far as I can see it works.
    I’ve use the Sample Scene of the Tobii SDK (TobiiXR for Unity package) and cut most of the code from the GazeVisualizer there. So take a look there is you want too!

    This is the abbreviated bit of code:


    using UnityEngine;
    using Tobii.XR;
    using System.IO;

    public class EyeTrackOnScreen : MonoBehaviour
    {
    float _defaultDistance = 5f;
    void Update()
    {
    IEyeTrackingProvider provider = TobiiXR.Internal.Provider;
    TobiiXR_EyeTrackingData eyeTrackingData = EyeTrackingDataHelper.Clone(provider.EyeTrackingDataLocal);
    Matrix4x4 localToWorldMatrix = provider.LocalToWorldMatrix;
    Vector3 worldForward = localToWorldMatrix.MultiplyVector(Vector3.forward);
    EyeTrackingDataHelper.TransformGazeData(eyeTrackingData, localToWorldMatrix);
    TobiiXR_GazeRay gazeRay = eyeTrackingData.GazeRay;

    Vector3 screenPosition = gazeRay.Origin + gazeRay.Direction.normalized * _defaultDistance;
    float screenX = transform.localPosition.x + (Screen.width * 0.5);
    float screenY = transform.localPosition.y + (Screen.height * 0.5);
    }
    }

    Note: it is the Game screen that is calculated and so you have to take into account what size the game screen is at run time. If it’s full screen the gaze coordinates will conform to the resolution of your monitor. Is it running in a window, then the inner dimensions of that window will determine the max X and Y.
    The screenPosition vector has its origin at the center of the screen.
    The screenX and screenY are adjusted for the current Screen size.

    Have fun!

    Marco

    #12473

    Grant [Tobii]
    Keymaster

    Hi Marco, that’s great! Thanks so much for sharing your experience, much appreciated. We hope other users will find it useful as well 🙂

Viewing 4 posts - 16 through 19 (of 19 total)

You must be logged in to reply to this topic.