Beispiel #1
0
        private void addUser_button_Click(object sender, EventArgs e)
        {
            if (mConfiguration.userNameList.Count == 0)
            {
                DialogResult result = MessageBox.Show("There is allready Profile in system." + "\nDo you want to add a new Profile?",
                                                      "Critical Warning",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);

                if (result == DialogResult.Yes)
                {
                    var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();
                    // EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

                    if (eyeTracker == null)
                    {
                        MessageBox.Show("Cant find the Eye Tracker! \nPlease trye again.",
                                        "Critical Warning",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }


                    if (eyeTracker != null)
                    {
                        //FirstCalibrationWindow firstCalibrationWindow = new FirstCalibrationWindow();
                        // firstCalibrationWindow.Show();

                        CalibrationForm t = new CalibrationForm(eyeTracker);
                    }
                }
            }
        }
Beispiel #2
0
        public CalibrationManager(CameraManager cameraManager)
        {
            this._cameraManager = cameraManager;
            _leftCamera         = cameraManager.LeftCamera.camera;
            _rightCamera        = cameraManager.RightCamera.camera;

            _winForm           = new CalibrationForm(this);
            CalibrationProcess = new Thread(ProcessFrame);
            _winForm.ShowDialog();
        }
Beispiel #3
0
        private void VerifyCalibrationCurve(CalibrationForm calibrationForm, double slope, double intercept, double rSquared)
        {
            var labels = calibrationForm.ZedGraphControl.GraphPane.GraphObjList.FirstOrDefault(o => o is TextObj) as TextObj;

            Assert.IsNotNull(labels);
            var lines = labels.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.IsTrue(lines.Length >= 2);
            Assert.AreEqual(CalibrationCurve.Format(slope, intercept), lines[0]);
            Assert.AreEqual(CalibrationCurve.RSquaredDisplayText(rSquared), lines[1]);
        }
Beispiel #4
0
        private static ZoomState ZoomCalibrationCurve(CalibrationForm calibrationForm, double zoomFraction)
        {
            ZoomState priorZoomState = null;

            RunUI(() =>
            {
                PointF centerPoint =
                    calibrationForm.ZedGraphControl.GraphPane.GeneralTransform(new PointF(0, 0), CoordType.AxisXYScale);
                priorZoomState = new ZoomState(calibrationForm.ZedGraphControl.GraphPane, ZoomState.StateType.Zoom);
                calibrationForm.ZedGraphControl.ZoomPane(calibrationForm.ZedGraphControl.GraphPane, zoomFraction, centerPoint, true);
            });
            return(priorZoomState);
        }
Beispiel #5
0
        private void BtnCalibrateClick(object sender, EventArgs e)
        {
            var dlg = new CalibrationForm();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (dlg.CameraSnapshotDescriptors.Count > 0)
            {
                snapshots = dlg.CameraSnapshotDescriptors;
            }
            if (snapshots.Count > 0)
            {
                btnStartExPoint.Enabled = true;
            }
        }
Beispiel #6
0
        private void Calibration_Button_Click(object sender, EventArgs e)
        {
            var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();

            // EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            if (eyeTracker != null)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}",
                                  eyeTracker.Address,
                                  eyeTracker.DeviceName,
                                  eyeTracker.Model,
                                  eyeTracker.SerialNumber,
                                  eyeTracker.FirmwareVersion,
                                  eyeTracker.RuntimeVersion);

                CalibrationForm t = new CalibrationForm(eyeTracker);
                t.Show();
                //CalibrationWindow cal = new CalibrationWindow(eyeTracker);
                //cal.Show();
            }
        }
        /// <summary>
        /// Calibrates the Screen Based Tobii Eye Tracker using a Windows Form
        /// Based on http://devtobiipro.azurewebsites.net/tobii.research/dotnet/reference/1.7.2.7-alpha-g369155c3/class_tobii_1_1_research_1_1_screen_based_calibration.html
        /// </summary>
        /// <returns></returns>
        public override async Task <ApiResponseData> CalibrateEyeTrackerAsync()
        {
            //EyeTracker == null ? new ApiResponseData { Message = "No connection to an eye tracker has been established. Connect to an eye tracker first." } : null;

            throw new NotImplementedException();
            var calibration = new ScreenBasedCalibration(EyeTracker);
            await calibration.EnterCalibrationModeAsync();

            // Define the points on screen we should calibrate at.
            // The coordinates are normalized, i.e. (0.0f, 0.0f) is the upper left corner and (1.0f, 1.0f) is the lower right corner.
            var pointsToCalibrate = new NormalizedPoint2D[] {
                new NormalizedPoint2D(0.5f, 0.5f),
                new NormalizedPoint2D(0.1f, 0.1f),
                new NormalizedPoint2D(0.1f, 0.9f),
                new NormalizedPoint2D(0.9f, 0.1f),
                new NormalizedPoint2D(0.9f, 0.9f),
            };

            // Display Windows Form for Calibration Drawing
            CalibrationForm calibrationForm = new CalibrationForm();

            calibrationForm.Show();

            System.Threading.Thread.Sleep(3000);

            // Get screen resolution
            Screen myScreen   = Screen.FromControl(calibrationForm);
            float  screenResX = myScreen.WorkingArea.Width;
            float  screenResY = myScreen.WorkingArea.Height;

            // Collect data.
            foreach (var point in pointsToCalibrate)
            {
                // Get screen coodrinates from normalized coordinates
                float x = point.X * screenResX;
                float y = point.Y * screenResY;

                // Show an image on screen where you want to calibrate.
                Console.WriteLine("Show point on screen from UI thread at ({0}, {1})", x, y);

                calibrationForm.Paint += (sender, e) =>
                {
                    e.Graphics.DrawEllipse(Pens.Red, x, y, 100, 100);
                };

                // Wait a little for user to focus.
                System.Threading.Thread.Sleep(700);
                // Collect data.
                CalibrationStatus status = await calibration.CollectDataAsync(point);

                if (status != CalibrationStatus.Success)
                {
                    // Try again if it didn't go well the first time.
                    // Not all eye tracker models will fail at this point, but instead fail on ComputeAndApplyAsync.
                    await calibration.CollectDataAsync(point);
                }
            }
            // Compute and apply the calibration.
            CalibrationResult calibrationResult = await calibration.ComputeAndApplyAsync();

            Console.WriteLine("Compute and apply returned {0} and collected at {1} points.",
                              calibrationResult.Status, calibrationResult.CalibrationPoints.Count);
            // Analyze the data and maybe remove points that weren't good.
            calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
            // Redo collection at the discarded point.
            Console.WriteLine("Show point on screen from UI thread at ({0}, {1})", 0.1f, 0.1f);
            await calibration.CollectDataAsync(new NormalizedPoint2D(0.1f, 0.1f));

            // Compute and apply again.
            calibrationResult = await calibration.ComputeAndApplyAsync();

            Console.WriteLine("Second compute and apply returned {0} and collected at {1} points.",
                              calibrationResult.Status, calibrationResult.CalibrationPoints.Count);
            // See that you're happy with the result.
            // The calibration is done. Leave calibration mode.
            await calibration.LeaveCalibrationModeAsync();
        }
Beispiel #8
0
 private string GetGraphTitle(CalibrationForm calibrationForm)
 {
     return(calibrationForm.ZedGraphControl.GraphPane.Title.Text);
 }
Beispiel #9
0
        private static bool Calibrate(int deviceId, string calibrationFilename, int deviceDistance, QLCalibrationType calibrationType, int targetDuration)
        {
            // Start the device.
            QLError error = QuickLink2API.QLDevice_Start(deviceId);

            if (error != QLError.QL_ERROR_OK)
            {
                Console.WriteLine("QLDevice_Start() returned {0}.", error.ToString());
                return(false);
            }

            bool calibrationSuccessful = false;

            using (CalibrationForm calibrationForm = new CalibrationForm(deviceId, calibrationType, targetDuration))
            {
                if (calibrationForm.Calibrate())
                {
                    // Calculate the total average score.
                    float avg = 0;
                    for (int i = 0; i < calibrationForm.LeftScores.Length; i++)
                    {
                        avg += calibrationForm.LeftScores[i].score;
                        avg += calibrationForm.RightScores[i].score;
                    }
                    avg /= (float)calibrationForm.LeftScores.Length * 2f;

                    Console.WriteLine("Calibration Score: {0}.", avg);

                    while (true)
                    {
                        // Flush the input buffer.
                        while (Console.KeyAvailable)
                        {
                            Console.ReadKey(true);
                        }

                        if (!PromptToApplyCalibration())
                        {
                            Console.WriteLine("Not applying calibration.");
                            calibrationSuccessful = false;
                            break;
                        }
                        else
                        {
                            error = QuickLink2API.QLCalibration_Finalize(calibrationForm.CalibrationId);
                            if (error != QLError.QL_ERROR_OK)
                            {
                                Console.WriteLine("QLCalibration_Finalize() returned {0}.", error.ToString());
                                calibrationSuccessful = false;
                                break;
                            }

                            error = QuickLink2API.QLDevice_ApplyCalibration(deviceId, calibrationForm.CalibrationId);
                            if (error != QLError.QL_ERROR_OK)
                            {
                                Console.WriteLine("QLCalibration_ApplyCalibration() returned {0}", error.ToString());
                                calibrationSuccessful = false;
                                break;
                            }

                            error = QuickLink2API.QLCalibration_Save(calibrationFilename, calibrationForm.CalibrationId);
                            if (error != QLError.QL_ERROR_OK)
                            {
                                Console.WriteLine("QLCalibration_Save() returned {0}", error.ToString());
                                calibrationSuccessful = false;
                                break;
                            }

                            calibrationSuccessful = true;
                            break;
                        }
                    }
                }
            }

            error = QuickLink2API.QLDevice_Stop(deviceId);
            if (error != QLError.QL_ERROR_OK)
            {
                Console.WriteLine("QLDevice_Stop() returned {0}.", error.ToString());
                return(false);
            }

            return(calibrationSuccessful);
        }