Exemplo n.º 1
0
        private void OnNewCoordinates(TobiiCoordinates coordinates)
        {
            lock (Helpers.locker)
            {
                if (mouse_state == MouseState.Idle &&
                    (DateTime.Now - idle_start_time).TotalSeconds > 60)
                {
                    CoordinateSmoother.Reset();
                    return;
                }

                if (DateTime.Now > freeze_until)
                {
                    if (mouse_state == MouseState.Calibrating &&
                        Helpers.GetDistance(coordinates.gaze_point, calibration_start_gaze_point) > Options.Instance.reset_calibration_zone_size)
                    {
                        mouse_state = MouseState.Controlling;
                    }

                    if (mouse_state == MouseState.Calibrating)
                    {
                        // The only thing to update while calibrating is gaze point.
                        float[] coordinates_copy = new float[smoothened_error_correction.сoordinates.Length];
                        smoothened_error_correction.сoordinates.CopyTo(coordinates_copy, 0);
                        var smoothened_error_correction_clone = new EyeTrackerErrorCorrection(coordinates_copy, smoothened_error_correction.shift);
                        smoothened_error_correction_clone.сoordinates[0] = coordinates.gaze_point.X;
                        smoothened_error_correction_clone.сoordinates[1] = coordinates.gaze_point.Y;
                        smoothened_error_correction = CoordinateSmoother.Smoothen(smoothened_error_correction_clone);
                    }
                    else
                    {
                        // The eye tracker provides shaky data that has to be smoothened before transforming to the mouse cursor position.
                        // |CalibrationManager| amplifies this shaking.
                        // To cancel the amplification we smoothen data BEFORE it goes to |CalibrationManager|.
                        //
                        // Another problem is |CalibrationManager| also may be a source of shaking (even on smoothened input).
                        // So in addition to smoothening its input we have to smoothen its output.
                        // Smoothening data twice leads to bigger latency but otherwise, the cursor shakes.
                        // Big latency is compensated by |instant_jump_distance|.
                        var shift             = smoothened_error_correction == null ? new Point(0, 0) : CalibrationManager.Instance.GetShift(smoothened_error_correction.сoordinates);
                        var shaky_coordinates = coordinates.ToCoordinates(Options.Instance.calibration_mode.additional_dimensions_configuration);
                        smoothened_error_correction = CoordinateSmoother.Smoothen(new EyeTrackerErrorCorrection(shaky_coordinates, shift));
                    }
                }
                else
                {
                    // Adds inertia on exit from freeze state.
                    CoordinateSmoother.Smoothen(smoothened_error_correction);
                }

                if (mouse_state == MouseState.Controlling || mouse_state == MouseState.Calibrating)
                {
                    UpdateCursorPosition();
                }
            }
        }
Exemplo n.º 2
0
 private void StartCalibration()
 {
     if (mouse_state != MouseState.Calibrating)
     {
         calibration_start_gaze_point =
             new Point((int)smoothened_error_correction.сoordinates[0],
                       (int)smoothened_error_correction.сoordinates[1]);
         mouse_state = MouseState.Calibrating;
     }
     freeze_until = DateTime.Now.AddMilliseconds(Options.Instance.calibrate_freeze_time_ms);
     statistics.OnCalibrate();
     CoordinateSmoother.Reset();
 }
Exemplo n.º 3
0
 public void StartCalibration(bool dynamic_calibration)
 {
     this.dynamic_calibration = dynamic_calibration;
     if (mouse_state != MouseState.Calibrating)
     {
         calibration_start_gaze_point =
             new Point((int)smoothened_error_correction.сoordinates[0],
                       (int)smoothened_error_correction.сoordinates[1]);
         mouse_state = MouseState.Calibrating;
     }
     freeze_until = DateTime.Now.AddMilliseconds(Options.Instance.calibrate_freeze_time_ms);
     CoordinateSmoother.Reset();
 }