Jump to content

How to get output from the eye-tracker faster than Update in Unity


Recommended Posts

Dear @maple

I suppose that you faced the situation possibly due to the following two reasons.

1: Your computer does not have enough specification to get the data at 120Hz sampling rate. A computer with better specification could enable it to sample at 120Hz.

2. If you look at only the initial samples (i.e. first 30 seconds after you start sampling), you will see lower sampling rate than 120Hz.

The following article may be helpful for you to understand these points.

https://doi.org/10.3389/fpsyt.2020.572938

Best regards,

imarin18

Link to comment
Share on other sites

  • 4 weeks later...
  • 9 months later...
On 1/5/2021 at 10:54 AM, imarin18 said:

Dear @jboss

Thank you very much for your response.

I think your understanding is correct. We need to remember that Unity playing does not always work along with eye tracking. In your script posted previously, you wrote the code below. This stops only the playing of Unity, not eye tracking. Thus, if you want to stop the eye tracking in parallel, one of the workarounds would be to use UnixTime (i.e. SaccadeEndTime) as a trigger to stop the eye tracking, as designed in the GitHub page: https://github.com/MotorControlLearning/SaccadeVR-mobile.

 if (Application.isPlaying)
        {
            Application.Quit();
        }

Best regards,

imarin18

Late to the party, but I've seen this issue come up in several threads here (and had it myself):

The SaccadeVR project actually does a neat workaround that works for most use cases and a freeze because of the ongoing while/for loop in the eye tracking:

You can hand over every end condition you might want to the loop in the separate callback thread through an intermediate function. In my case, it's a simple bool:

    static bool GetEndCondition()
    {
        return isQuitting;
    }


that static bool is set OnApplicationQuit
 

   private void OnApplicationQuit()
    {
        isQuitting = true; 
	}


and the intermediate function called within the loop:

while (FrameCount < MaxFrameCount)
        {
            CppFrameCount++;

            // Break loop when necessary so the Callback does not freeze Unity, e.g. when quitting the application
            bool endCondition;
            endCondition = GetEndCondition();
            
            if (endCondition) // if needed compare the ending condition e.g. with the FrameCount or Unix time here
                break;
                                  
            
		// do stuff
                                  
 	}

 

Voilà. No more freeze on closing the Runtime & Stopping the Editor.

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