Home Forums Software Development Waiting until Calibration/Calibration testing is done.

Tagged: , ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2664
    Albin Stenström
    Participant

    Hi!

    Is there a good way in EyeX SDKto wait until Calibration or calibration testing is done?

    Im right now waiting for a status changed event to Configuring and then Tracking for Calibration.

    This does not work for Calibration Testing as far as i have seen.

    Thank you!
    Albin

    #2681
    Patrik [Tobii]
    Participant

    Hello Albin,

    There is currently no way of knowing when calibration testing is completed. There are currently discussions about adding a callback in the API for this, so hopefully this feature will be available in a future release.

    There is a workaround though, but it is an unsupported hack and not something that should be relied on:

    • You could check for the process Tobii.TestEyeTracking and wait for the process to exit.

    It’s not very robust, and you should be aware that the name of this process can change at any time.
    You might however use it as a temporary hack until there is something proper in the API.

    Below is a simple Console application (C#) that demonstrates the workaround.

    using System;
    using System.Diagnostics;
    using System.Threading;
    
    namespace CalibrationTestingDetection
    {
        public class Program
        {
            static void Main(string[] args)
            {
                var handle = new ManualResetEvent(false);
    
                // Subscribe to CTRL+C
                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    eventArgs.Cancel = true;
                    handle.Set();                
                };
    
                Console.WriteLine("Press CTRL+C to quit.\n");
    
                // Wait for calibration testing to start and finish.
                if (WaitForCalibrationTestingToComplete(handle))
                {
                    Console.WriteLine("Successfully detected start and stop.");
                }
                else
                {
                    Console.WriteLine("Application aborted (CTRL+C pressed).");
                }
    
                // Wait for the user to quit.
                Console.WriteLine("\nPress ANY key to quit");
                Console.ReadKey(true);
            }
    
            public static bool WaitForCalibrationTestingToComplete(WaitHandle handle)
            {
                Console.WriteLine("Waiting for calibration testing to start.");
    
                while (!handle.WaitOne(0))
                {
                    try
                    {
                        var processes = Process.GetProcessesByName("Tobii.TestEyeTracking");
                        if (processes.Length > 0)
                        {
                            Console.WriteLine("Calibration testing was started!");
    
                            var process = processes[0];
                            while (!handle.WaitOne(500))
                            {
                                if (process.HasExited)
                                {
                                    Console.WriteLine("Calibration testing completed!");
                                    return true;
                                }
                            }
                        }
                    }
                    finally
                    {
                        handle.WaitOne(500);
                    }
                }
                return false;
            }
        }
    }

    Best regards
    Patrik

    #2682
    Albin Stenström
    Participant

    Thank you for your help!

    I would NOT have been able to figure that one out on my own!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.