Command-line interface directly to EyeTribe UI Calibration

Forum for C#/Windows development

Command-line interface directly to EyeTribe UI Calibration

Postby sjobeek » 28 Feb 2014, 10:47

Is it currently possible to directly run the calibration routine from the EyeTribe tracker from the command line?

I imagine this is a very common use case, and something like
Code: Select all
EyeTribeUI.exe --calibrate

in order to run the calibration using the default /previous settings (and close the UI after) would be excellent.


In addition, the ability to "accept" or "re-try" the eye-tribe calibration using either the keyboard or gaze would be appreciated. (is this already possible?)
sjobeek
 
Posts: 7
Joined: 18 Dec 2013, 12:53

Re: Command-line interface directly to EyeTribe UI Calibrati

Postby Martin » 28 Feb 2014, 17:37

Not possible to pass command line arguments to the Eyetribe UI. I'm not sure it makes sense to make it so. For me a better approach is to have a small executable to just do the specific task. Since it's a happy Friday, here is the SimpleCalibrator.

Download the Visual Studio project or go straight to the binary executable.

The application is simple. It uses the TETControls to do a calibration with the CalibrationRunner. It will look for command line arguments to specify the size and number of points.

It would be started like this:

Code: Select all
SimpleCalibrator.exe width=1000 height=800 numpoints=9


The complete code looks like this:

Code: Select all
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
using TETCSharpClient;
using TETControls.Calibration;
using MessageBox = System.Windows.MessageBox;
using Size = System.Drawing.Size;

namespace SimpleCalibrator
{
    public partial class MainWindow : Window
    {
        private Screen screen;
        private Size area;
        private int numPoints = 9;

        public MainWindow()
        {
            GazeManager.Instance.Activate(GazeManager.ApiVersion.VERSION_1_0, GazeManager.ClientMode.Push);

            InitializeComponent();

            if (!GazeManager.Instance.IsConnected)
            {
                MessageBox.Show("EyeTribe Server has not been started");
                Close();
            }

            Calibrate();
            GazeManager.Instance.Deactivate();
            Close();
        }

        private void Calibrate()
        {
            //Run the calibration on 'this' monitor, default to full screen nine points
            screen = Screen.FromHandle(new WindowInteropHelper(this).Handle);
            area = new Size(screen.Bounds.Width, screen.Bounds.Height);

            ParseArguments();

            // Run the calibration
            CalibrationRunner calRunner = new CalibrationRunner(screen, area, numPoints);
            calRunner.Start();
        }

        private void ParseArguments()
        {
            foreach (string s in App.args)
            {
                if (string.IsNullOrEmpty(s))
                    continue;

                string[] keyVal = s.Split('=');

                if (keyVal.Length < 2)
                    continue;

                string keyStr = keyVal[0];
                string valueStr = keyVal[1];

                int value = 0;
                int.TryParse(valueStr, out value);

                if(string.IsNullOrEmpty(keyStr) || value == 0)
                    continue;

                switch (keyStr)
                {
                    case "width":
                        if(value < screen.Bounds.Width)
                           area.Width = value;
                        break;

                    case "height":
                        if(value < screen.Bounds.Height)
                           area.Height = value;
                        break;

                    case "numpoints":
                        if(value == 9 || value == 12 || value == 16)
                        numPoints = value;
                        break;
                }
            }
        }
    }
}



It's of course possible to extend the number of parameters (e.g. point color etc.). These are all properties of the CalibrationRunner class.
Martin
 
Posts: 567
Joined: 29 Oct 2013, 15:20

Re: Command-line interface directly to EyeTribe UI Calibrati

Postby sjobeek » 03 Mar 2014, 13:52

Thanks for the simple example, and the binary, too!

Yay for happy friday!
sjobeek
 
Posts: 7
Joined: 18 Dec 2013, 12:53


Return to C#



cron