Jump to content

Gaze origin bug in GetGazeRay of Unity package

Recommended Posts

Hi, there seems to be a bug in the `GetGazeRay` function of the SRanipal Unity package (specifically, the function at line 265 in SRanipal_Eye.cs).

origin = eyesData[(int)gazeIndex].gaze_origin_mm * 0.001f;
direction = eyesData[(int)gazeIndex].gaze_direction_normalized;
origin.x *= -1; // Adding this line fixes the bug
direction.x *= -1;

This issue has been mentioned in this post as well.

Here is a demo script to illustrate the bug: GazeRays.cs

This will render a blue ray from the left eye and a red ray from the right eye. Without the fix, the rays will appear swapped like so:


With the fix, the rays will appear in the correct eye like so:


If someone could confirm whether this bug is valid, I would appreciate it. Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

The same bug applies to the combined gazeray. When I move my gaze to the left the ray goes to the right and vice versa. Up/down is fine.

If gaze_orgin_C is the measured combined origin and gaze_direct_C the measured combined direction you need to do the below calculation to use it:

fixed_gaze_origin_C = new Vector3(gaze_origin_C.x*-1f, gaze_origin_C.y, gaze_origin_C.z)/1000f,
fixed_gaze_direction_C = new Vector3(gaze_direct_C.x*-1f, gaze_direct_C.y, gaze_direct_C.z),

Note the division by 1000, as I'm using version 2 of the eyetracking API and there the measured values are in mm and Unity units are meters.

Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...

Hi qxxb, 

First of all- thank you for sharing the fix to the bug and  your code (https://gist.github.com/qxxxb/d1357828c16d27873751280d7222ea25)- It helped me a lot in visualizing the gaze.

I have one question:  in your code you set the endpoint of the LineRender in the following way (line 133 ):

llr.SetPosition(1, gr.leftOrigin + gr.leftDir * 20);

My question is-why do you multiple the resulting eye direction by 20? 

When I convert gaze origin and direction to world coordinates as in your code -I receive world coordinates values which their direction seems a bit off to me. Am I missing a multipcation of the resulting direction? why is this multiplication needed?  What specify the multipcation value (why 20)?

Thank you so much in advance!






Link to comment
Share on other sites

  • 8 months later...

@Hank_Li @Corvus  Hi Hank, you mentioned above that the bug will be fixed in the next sdk version. I downloaded the 1_3_3 sdk and I want to be sure that the bug in the GetGazeray function was fixed. Was it fixed? Is it still necessary to multiple x values in minus 1? 

Waiting for your answer, Thanks! 

Link to comment
Share on other sites

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...