Exemplo n.º 1
0
        private void _calibrateButton_Click(object sender, EventArgs e)
        {
            var runner = new CalibrationRunner();

            try
            {
                var result = runner.RunCalibration(_connectedTracker);

                // if everything went OK start training
                if (result != null)
                {
                    test t = new test();
                    //get experiment stucture
                    experiment ex = t.create();
                    //loop
                    for (int i = 0; i < ex.Compare.Count; i++)
                    {
                        currentDataItem            = new dataItem(Guid.NewGuid());
                        currentDataItem.RightClass = ex.Compare[i][0];
                        currentDataItem.LeftClass  = ex.Compare[i][1];
                        currentDataItem.ImgPath    = ex.Record[i];
                        trainingForm f = new trainingForm(ex.Compare[i][0], ex.Compare[i][1]);
                        f.ShowDialog();
                        focusCalibrationForm focusCal = new focusCalibrationForm();
                        focusCal.ShowDialog();
                        rc = new recordForm(this, ex.Record[i]);
                        rc.ShowDialog();
                        this.dataItems.Add(currentDataItem);
                    }
                    writeGazeExcel();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Not enough data to create a calibration (or calibration aborted).");
                }
            }
            catch (EyeTrackerException ee)
            {
                MessageBox.Show("Failed to calibrate. Got exception " + ee,
                                "Calibration Failed",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void start()
        {
            var  runner = new CalibrationRunner();
            bool calibratedSuccessfully = false;

            while (!calibratedSuccessfully)
            {
                try
                {
                    var result = runner.RunCalibration(_connectedTracker);

                    // if everything went OK start training
                    if (result != null)
                    {
                        calibratedSuccessfully = true;
                        experimentRunner t = new experimentRunner();
                        //get experiment stucture
                        experiment ex = t.create(this.type);
                        //loop
                        if (ex != null)
                        {
                            this.IsTracking = true;
                            this.ConnectedTracker.StartTracking();
                            int    correctLabelPos = 0;
                            string correctClass    = "";
                            Random rand            = new Random();
                            for (int i = 0; i < ex.Compare.Count; i++)
                            //for (int i = 0; i < 3; i++)
                            {
                                trainingForm f = null;
                                correctLabelPos = rand.Next(2);
                                if (correctLabelPos == 0)
                                {
                                    f               = new trainingForm(ex.Compare[i][0], ex.Compare[i][1], Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                                    correctClass    = "Right";
                                    currentDataItem = new dataItem(ex.Compare[i][0], ex.Compare[i][1], f.LocationRight, f.LocationLeft);
                                }
                                else
                                {
                                    f               = new trainingForm(ex.Compare[i][1], ex.Compare[i][0], Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                                    correctClass    = "Left";
                                    currentDataItem = new dataItem(ex.Compare[i][1], ex.Compare[i][0], f.LocationRight, f.LocationLeft);
                                }
                                f.ShowDialog();
                                focusCalibrationForm focusCal = new focusCalibrationForm();
                                currentDataItem = new dataItem();
                                focusCal.ShowDialog();
                                recordForm rc = new recordForm(this, ex.Record[i], correctClass, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                                currentDataItem = new dataItem(ex.Compare[i][0], ex.Compare[i][1], rc.Location, ex.Record[i]);
                                rc.ShowDialog();
                            }
                            sw.Flush();
                        }
                        this.resultScoresLabel.Text = "Correct guess= " + recordForm.correctScore + ", " + "Wrong guess= " + recordForm.wrongScore;
                        this.close.Visible          = true;
                    }
                    else
                    {
                        MessageBox.Show("Calibration failed! please try again (focus on the dots)");
                    }
                }
                catch (EyeTrackerException ee)
                {
                    MessageBox.Show("Failed to calibrate. Got exception " + ee,
                                    "Calibration Failed",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }