예제 #1
0
 public MethodResult(CommandType command)
 {
     lock (Lock)
     {
         _command = command;
         _status  = CalibrationStatus.Failure;
     }
 }
예제 #2
0
 public Measurement(decimal[] data, decimal temp = 0, decimal?tf = null, decimal?incl = null, CalibrationStatus status = CalibrationStatus.ToCalibrate)
 {
     this.data   = data;
     this.temp   = temp;
     this.tf     = tf;
     this.incl   = incl;
     this.status = status;
 }
예제 #3
0
        private void InternalCalibrationComplete(IntPtr hNode, UserID id, CalibrationStatus status, IntPtr pCookie)
        {
            EventHandler <CalibrationProgressEventArgs> handlers = this.calibrationCompleteEvent;

            if (handlers != null)
            {
                handlers(this.node, new CalibrationProgressEventArgs(id, status));
            }
        }
예제 #4
0
 /// <summary>
 /// Indicate that the command is ready. The caller needs to hold a reference.
 /// </summary>
 /// <param name="status">The command result.</param>
 /// <param name="elapsed">How long the command took in milliseconds.</param>
 public void Finished(CalibrationStatus status, int elapsed)
 {
     lock (Lock)
     {
         _ready  = true;
         _status = status;
         _elapsedMilliseconds = elapsed;
         _currentResult       = null;
     }
 }
        private static void Calibrate(IEyeTracker eyeTracker)
        {
            // Create a calibration object.
            var calibration = new ScreenBasedCalibration(eyeTracker);


            // 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),
            };

            // Enter calibration mode.
            calibration.EnterCalibrationMode();

            // Collect data.
            foreach (var point in pointsToCalibrate)
            {
                // Show an image on screen where you want to calibrate.
                Console.WriteLine("Show point on screen at ({0}, {1})", point.X, point.Y);
                // Wait a little for user to focus.
                //System.Threading.Thread.Sleep(700);
                // Collect data.,,
                CalibrationStatus status = calibration.CollectData(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 ComputeAndApply.
                    calibration.CollectData(point);
                }
            }
            // Compute and apply the calibration.
            CalibrationResult calibrationResult = calibration.ComputeAndApply();

            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 at ({0}, {1})", 0.1f, 0.1f);
            calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
            // Compute and apply again.
            calibrationResult = calibration.ComputeAndApply();
            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.
            calibration.LeaveCalibrationMode();
        }
        public WiimoteCalibrationHandler(Wiimotes p_Wiimotes, Form1 p_Form)
        {
            m_Status            = CalibrationStatus.CalibrationNotStarted;
            m_Wiimotes          = p_Wiimotes;
            m_parent            = p_Form;
            m_CalibrationRecord = m_Wiimotes.getCalibrationRecord();

            m_Wiimotes.RecordingCompletedEvent   += new Wiimotes.OnRecordingCompletedEvent(OnRecordingCompletedEvent);
            m_Wiimotes.RecordingInterruptedEvent += new Wiimotes.OnRecordingInterruptedEvent(OnRecordingInterruptedEvent);

            calibrationRecordingSync = new object();
        }
예제 #7
0
        public CalibrationStatus GetCalibrationStatus()
        {
            CalibrationStatus status = new CalibrationStatus();
            byte cal = ReadRegister(BNO055_CALIB_STAT_ADDR);

            status.System = (byte)((cal >> 6) & 0x03);
            status.Gyro   = (byte)((cal >> 4) & 0x03);
            status.Accel  = (byte)((cal >> 2) & 0x03);
            status.Mag    = (byte)(cal & 0x03);

            return(status);
        }
예제 #8
0
        ///-----------------------------------------------------------------------------------------
        ///   Class:          <BNO055>
        ///   Method:         <GetCalibrationStatus>
        ///   Description:    'This method gets the calibration status of the sensor.'
        ///
        ///   Inputs:         void
        ///   Output:         CalibrationStatus
        ///
        ///   Author:         <Steven_Pugia>
        ///   Notes:          <None>
        ///-----------------------------------------------------------------------------------------
        public CalibrationStatus GetCalibrationStatus()
        {
            //byte calStatus = ReadBytes(BNO055_CALIB_STAT_ADDR, 1)[0];

            CalibrationStatus cal = new CalibrationStatus();

            cal.System = 3;                          //(byte)((calStatus >> 6) & 0x03);
            cal.IMU    = 3;                          //(byte)((calStatus >> 4) & 0x03);
            cal.Accel  = 3;                          //(byte)((calStatus >> 2) & 0x03);
            cal.Mag    = 3;                          //(byte)(calStatus & 0x03);

            return(cal);
        }
예제 #9
0
        private void SendUpdates()
        {
            var status = new CalibrationStatus
            {
                topLeftCalibrated     = DisplayCalibration.IsCornerCalibrated[(int)Corner.TopLeft],
                bottomLeftCalibrated  = DisplayCalibration.IsCornerCalibrated[(int)Corner.BottomLeft],
                topRightCalibrated    = DisplayCalibration.IsCornerCalibrated[(int)Corner.TopRight],
                bottomRightCalibrated = DisplayCalibration.IsCornerCalibrated[(int)Corner.BottomRight],
                calibrationStatus     = DisplayCalibration.CalibrationProgress,
                isCalibrating         = DisplayCalibration.IsCalibrating
            };

            RemoteSurfaceConnection.SendCommand(Globals.DefaultSurfaceName, "admin-cmd-calibration-status", JsonUtility.ToJson(status));
        }
    public IEnumerator Calibrate(IEyeTracker eyeTracker)
    {
        // Create a calibration object.
        HMDBasedCalibration calibration = new HMDBasedCalibration(eyeTracker);

        // Enter calibration mode.
        calibration.EnterCalibrationMode();
        // Define the points in the HMD space we should calibrate at.
        Point3D[] pointsToCalibrate = new Point3D[] {
            new Point3D(9f, 9f, 20f),
            new Point3D(-9f, 9f, 20f),
            new Point3D(-9f, -9f, 20f),
            new Point3D(9f, -9f, 20f),
            new Point3D(0f, 0f, 20f),
        };
        // Collect data.
        foreach (Point3D point in pointsToCalibrate)
        {
            // Show an image on screen where you want to calibrate.
            Debug.Log("Show point in HMD space at ( " + point.X + " , " + point.Y + " , " + point.Z + " )");
            VRHeadsetDebugDisplay.Instance.SetText("Show point in HMD space at ( " + point.X + " , " + point.Y + " , " + point.Z + " )");
            DisplayImgAtPoint(new Vector3(point.X, point.Y, point.Z));
            // Wait a little for user to focus.
            yield return(new WaitForSeconds(5));

            // Collect data.
            CalibrationStatus status = calibration.CollectData(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 ComputeAndApply.
                calibration.CollectData(point);
                Debug.Log("Calibration point status : " + status);
            }
            VRHeadsetDebugDisplay.Instance.SetText("Ok, next!");
        }
        // Compute and apply the calibration.
        HMDCalibrationResult calibrationResult = calibration.ComputeAndApply();

        Debug.Log("Compute and apply returned : " + calibrationResult.Status);
        // See that you're happy with the result.
        // The calibration is done. Leave calibration mode.


        calibration.LeaveCalibrationMode();
        VRHeadsetDebugDisplay.Instance.SetText("All finished!");
    }
        private void CalibrationMode()
        {
            calibration.EnterCalibrationMode();
            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),
            };

            foreach (var point in pointsToCalibrate)
            {
                //this.Dispatcher.Invoke(() =>
                //{
                //    Connect.Text = $"Please look at {point.X},{point.Y}.";
                //});
                //CoPoint.Text = $"Please look at {point.X},{point.Y}.";

                //ThreadPool.QueueUserWorkItem((o) =>
                //{

                //});
                Dispatcher.Invoke((Action)(() => Connect.Text = $"Please look at {point.X},{point.Y}."));
                System.Threading.Thread.Sleep(1000);

                CalibrationStatus status = calibration.CollectData(point);
                if (status != CalibrationStatus.Success)
                {
                    calibration.CollectData(point);
                }
            }
            CalibrationResult calibrationResult = calibration.ComputeAndApply();

            CoPoint.Text = $"Compute and apply returned {calibrationResult.Status} and collected at {calibrationResult.CalibrationPoints.Count} points.";
            Thread.Sleep(1000);
            //calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
            //calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
            //calibrationResult = calibration.ComputeAndApply();

            calibration.LeaveCalibrationMode();
        }
예제 #12
0
        public override void ProcessFrame(CameraStateManager stateManager, Helpers.VideoFrameWrapper frame)
        {
            base.ProcessFrame(stateManager, frame);

            if (status == CalibrationStatus.CollectingData)
            {
                if (frame.PerformedAction.HasValue && frame.PerformedAction.Value == 1)
                {
                    if (frame.PerformedActionProgress.HasValue && (Math.Abs(frame.PerformedActionProgress.Value - 1) < 0.001))
                    {
                        // Calibration data collection has finished. Need to get the data and complete the calibration
                        Dictionary<float, List<float>> calibrationData = NativeHelpers.GetIntegrationCalibrationData();
                        status = CalibrationStatus.CalculatingBestSettings;
                        ThreadPool.QueueUserWorkItem(FindBestIntegrationDetectionSettings, calibrationData);
                    }
                }
            }
            else if (status == CalibrationStatus.Finished)
            {
                stateManager.CancelIntegrationCalibration(calibrationSuccessful);
            }
        }
    void Update()
    {
        switch (currentState)
        {
        case State.CALIBRATING:
            currentCalibrationStatus = Calibrate(calibratingSurfaceObject);

            Debug.Log(currentCalibrationStatus);

            break;

        case State.PROCESSING_POSITION_ROTATION:

            ProcessPositions();

            /*   Debug.Log(objects[0].firstPointDistance);
             * Debug.Log(objects[0].secondPointDistance);
             * Debug.Log(objects[0].thirdPointDistance); */

            break;
        }
    }
예제 #14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            int w = Screen.PrimaryScreen.Bounds.Width;
            int h = Screen.PrimaryScreen.Bounds.Height;


            //label1.ResetText = "Look at each dot until its color changes!";
            //label1.ForeColor = Color.White;

            //  label1.Text = "Look at each dot until its color changes!";
            RectangleF recBegin = new RectangleF(0.5f * w, 0.5f * h, 30, 30);

            e.Graphics.FillEllipse(Brushes.White, recBegin);

            /*RectangleF rec2 = new RectangleF(0.1f * w, 0.1f * h, 20, 20);
             * e.Graphics.FillEllipse(Brushes.Black, rec2);
             *
             * RectangleF rec3 = new RectangleF(0.1f * w, 0.9f * h, 20, 20);
             * e.Graphics.FillEllipse(Brushes.Black, rec3);
             *
             * RectangleF rec4 = new RectangleF(0.9f * w, 0.1f * h, 20, 20);
             * e.Graphics.FillEllipse(Brushes.Black, rec4);
             *
             * RectangleF rec5 = new RectangleF(0.9f * w, 0.9f * h, 20, 20);
             * e.Graphics.FillEllipse(Brushes.Black, rec5);*/

            if (calibrationBegin2 == 1)
            {
                //   label1.Text = "";
                e.Graphics.FillEllipse(Brushes.Yellow, recBegin);

                var calibration = new ScreenBasedCalibration(mEyeTracker);

                // 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 pta = new PointF[5];

                var pointsToCalibrate = new NormalizedPoint2D[5] {
                    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),
                };

                // Enter calibration mode.
                calibration.EnterCalibrationMode();

                foreach (var point in pointsToCalibrate)
                {
                    // Show an image on screen where you want to calibrate.
                    Console.WriteLine("Show point on screen at ({0}, {1})", point.X, point.Y);


                    RectangleF rec = new RectangleF(point.X * w, point.Y * h, 30, 30);
                    e.Graphics.FillEllipse(Brushes.White, rec);

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

                    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 ComputeAndApply.
                        //vaghti cheshmo nabine ghermez mishe
                        calibration.CollectData(point);
                        e.Graphics.FillEllipse(Brushes.Red, rec);
                    }

                    if (status == CalibrationStatus.Success)
                    {
                        e.Graphics.FillEllipse(Brushes.Black, rec);
                    }
                }
                // Compute and apply the calibration.
                CalibrationResult calibrationResult = calibration.ComputeAndApply();
                Console.WriteLine("Compute and apply returned {0} and collected at {1} points.", calibrationResult.Status, calibrationResult.CalibrationPoints.Count);

                //textBox1.Text += "Compute and apply returned" + calibrationResult.Status+" and collected at " + calibrationResult.CalibrationPoints.Count+" points." +"\n";

                // 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 at ({0}, {1})", 0.1f, 0.1f);
                calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));

                RectangleF rec2 = new RectangleF(0.1f * w, 0.1f * h, 30, 30);
                e.Graphics.FillEllipse(Brushes.Yellow, rec2);

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

                Console.WriteLine("Second compute and apply returned {0} and collected at {1} points.",
                                  calibrationResult.Status, calibrationResult.CalibrationPoints.Count);
                // textBox1.Text += "Compute and apply returned" + calibrationResult.Status + " and collected at " + calibrationResult.CalibrationPoints.Count + " points." + "\n";
                // See that you're happy with the result.
                // The calibration is done. Leave calibration mode.
                calibration.LeaveCalibrationMode();

                calibrationBegin2 = 0;
                this.Close();
            }

            // calibrationBegin = false;
        }
예제 #15
0
        /// <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();
        }
예제 #16
0
 public override void InitialiseState(CameraStateManager stateManager)
 {
     status = CalibrationStatus.CollectingData;
     calibrationSuccessful = false;
 }
예제 #17
0
        private void FindBestIntegrationDetectionSettings(object input)
        {
            var calibrationData = input as Dictionary<float, List<float>>;
            if (calibrationData != null)
            {
                Trace.WriteLine("Running integration detection calibration ... ");
                foreach (float gamma in calibrationData.Keys)
                {
                    Trace.WriteLine(string.Format("{0}: {1}", gamma, string.Join(",", calibrationData[gamma].Select(x => x.ToString(CultureInfo.InvariantCulture)))));
                }

                var calibrator = new IntegrationDetectionCalibrator(calibrationData);
                calibrationSuccessful = calibrator.Calibrate();
            }

            status = CalibrationStatus.Finished;
        }
예제 #18
0
        private void Calibrate(Form CalibrationForm, IEyeTracker eyeTracker)
        {
            // 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),
            };

            var calibration = new ScreenBasedCalibration(eyeTracker);

            // Enter calibration mode.
            calibration.EnterCalibrationMode();

            // Collect data.

            Panel AnimatedPointPanel = new Panel();

            AnimatedPointPanel.Width  = CalibrationForm.Width;
            AnimatedPointPanel.Height = CalibrationForm.Height;
            Graphics AnimatedPointGraphics = AnimatedPointPanel.CreateGraphics();

            CalibrationForm.Controls.Add(AnimatedPointPanel);

            int w = CalibrationForm.Width;
            int h = CalibrationForm.Height;

            MovingPoint(AnimatedPointGraphics, w, h, new NormalizedPoint2D(0.5f, 0.1f), new NormalizedPoint2D(0.5f, 0.5f));
            for (int i = 0; i < pointsToCalibrate.Length; i++)
            {
                var point = pointsToCalibrate[i];
                // Show an image on screen where you want to calibrate.
                DrawPointOnForm(AnimatedPointGraphics, w, h, point);
                Console.WriteLine("Show point on screen at ({0}, {1})", point.X, point.Y);
                // Wait a little for user to focus.
                System.Threading.Thread.Sleep(700);
                // Collect data.
                CalibrationStatus status = calibration.CollectData(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 ComputeAndApply.
                    calibration.CollectData(point);
                }
                if (i + 1 < pointsToCalibrate.Length)
                {
                    MovingPoint(AnimatedPointGraphics, w, h, point, pointsToCalibrate[i + 1]);
                }
            }
            // Compute and apply the calibration.
            CalibrationResult calibrationResult = calibration.ComputeAndApply();

            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 at ({0}, {1})", 0.1f, 0.1f);
            calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
            // Compute and apply again.
            calibrationResult = calibration.ComputeAndApply();
            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.
            calibration.LeaveCalibrationMode();
            CalibrationForm.Close();
        }
        private void CalibrationTobii_Paint(object sender, PaintEventArgs e)
        {
            if (!justOneTime)
            {
                justOneTime   = true;
                gazePointList = new List <Point>();
                SolidBrush newBrush; // to have a new color that we choose

                int w = Screen.PrimaryScreen.Bounds.Width;
                int h = Screen.PrimaryScreen.Bounds.Height;


                var calibration = new ScreenBasedCalibration(mEyeTracker);

                // 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 pta = new PointF[5];

                var pointsToCalibrate = new NormalizedPoint2D[5] {
                    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),
                };

                // Enter calibration mode.
                calibration.EnterCalibrationMode();

                foreach (var point in pointsToCalibrate)
                {
                    // Show an image on screen where you want to calibrate.
                    Console.WriteLine("Show point on screen at ({0}, {1})", point.X, point.Y);
                    RectangleF rec = new RectangleF(point.X * w - mConfiguration.calibrationPointSize / 2, point.Y * h - mConfiguration.calibrationPointSize / 2, mConfiguration.calibrationPointSize, mConfiguration.calibrationPointSize);
                    //  RectangleF rec = new RectangleF(point.X * w - 70, point.Y * h - 70, 150, 150);

                    newBrush = new SolidBrush(mConfiguration.CalibrationColor);
                    e.Graphics.FillEllipse(newBrush, rec);

                    // Wait a little for user to focus.


                    // Collect data.,,

                    // Wait a little for user to focus.
                    // System.Threading.Thread.Sleep(700);

                    // getGazeData((int)point.X * w, (int)point.Y * h);

                    int X = (int)(point.X * w); // circle with r=70 ,
                    int Y = (int)(point.Y * h);

                    //compareGazeWithShape(X, Y);



                    CalibrationStatus status = CalibrationStatus.Failure;



                    while (status != CalibrationStatus.Success && gazeIsRight == false)
                    {
                        gazePointList = new List <Point>();
                        gazePointList.Add(getGazePoint());
                        //compareGazeWithShape(X, Y);
                        //e.Graphics.FillEllipse(Brushes.Red, rec);
                        // 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 ComputeAndApply.
                        //vaghti cheshmo nabine ghermez mishe

                        for (int i = 0; i < gazePointList.Count; i++)
                        {
                            //Console.WriteLine(new Point(X, Y));
                            //Console.WriteLine(gazePointList[i]);
                            //Console.WriteLine("+++");

                            int gazeX = gazePointList[i].X;
                            int gazeY = gazePointList[i].Y;
                            if (Math.Pow(gazeX - X, 2) + Math.Pow(gazeY - Y, 2) <= Math.Pow(80, 2))//150 circel
                            {
                                e.Graphics.FillEllipse(Brushes.Green, gazeX, gazeY, 10, 10);
                                gazeIsRight = true;
                                System.Threading.Thread.Sleep(1700);
                                status = calibration.CollectData(point);
                                break;
                            }

                            else
                            {
                                e.Graphics.FillEllipse(Brushes.Red, gazeX, gazeY, 10, 10);
                                gazeIsRight = false;
                            }
                        }
                    }

                    if (status == CalibrationStatus.Success && gazeIsRight == true)
                    {
                        e.Graphics.Clear(Color.Black);
                        e.Graphics.FillEllipse(Brushes.Black, rec);
                    }
                    gazeIsRight = false;
                    Invalidate();
                }
                // Compute and apply the calibration.
                CalibrationResult calibrationResult = calibration.ComputeAndApply();
                Console.WriteLine("Compute and apply returned {0} and collected at {1} points.", calibrationResult.Status, calibrationResult.CalibrationPoints.Count);

                //textBox1.Text += "Compute and apply returned" + calibrationResult.Status+" and collected at " + calibrationResult.CalibrationPoints.Count+" points." +"\n";

                // 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 at ({0}, {1})", 0.1f, 0.1f);
                calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));

                RectangleF rec2 = new RectangleF(0.1f * w, 0.1f * h, 30, 30);
                e.Graphics.FillEllipse(Brushes.Yellow, rec2);

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

                Console.WriteLine("Second compute and apply returned {0} and collected at {1} points.",
                                  calibrationResult.Status, calibrationResult.CalibrationPoints.Count);
                // textBox1.Text += "Compute and apply returned" + calibrationResult.Status + " and collected at " + calibrationResult.CalibrationPoints.Count + " points." + "\n";
                // See that you're happy with the result.
                // The calibration is done. Leave calibration mode.
                calibration.LeaveCalibrationMode();


                this.Close();
            }
            this.Close();
            //  }

            // calibrationBegin = false;
        }
        public WiimoteCalibrationHandler(Wiimotes p_Wiimotes,Form1 p_Form)
        {
            m_Status = CalibrationStatus.CalibrationNotStarted;
            m_Wiimotes = p_Wiimotes;
            m_parent = p_Form;
            m_CalibrationRecord = m_Wiimotes.getCalibrationRecord();

            m_Wiimotes.RecordingCompletedEvent += new Wiimotes.OnRecordingCompletedEvent(OnRecordingCompletedEvent);
            m_Wiimotes.RecordingInterruptedEvent += new Wiimotes.OnRecordingInterruptedEvent(OnRecordingInterruptedEvent);

            calibrationRecordingSync = new object();
        }
예제 #21
0
        /// <summary>
        /// GetCalibrationCalls calibration layer
        /// </summary>
        /// <param name="scorecardId"></param>
        /// <returns></returns>
        public CalibrationCallsInfo GetCalibrationCalls(int scorecardId)
        {
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                string userName = "";
                if (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268)
                {
                    userName = "******";
                }
                else
                {
                    userName = HttpContext.Current.User.Identity.Name;
                }
                SqlCommand sqlComm = new SqlCommand();
                sqlComm.CommandType = CommandType.StoredProcedure;
                sqlComm.CommandText = "getClientCalibrationsSM";
                sqlComm.Parameters.AddWithValue("@username", userName);
                sqlComm.Parameters.AddWithValue("@show_completed", 1);

                sqlComm.Parameters.AddWithValue("@scorecardId", scorecardId);


                sqlComm.Connection = sqlCon;

                var calibrationsCalibratedInfoList = new List <CalibrationCalls>();
                var completedUserList           = new List <CompletedUserList>();
                var calibrationsPendingInfoList = new List <CalibrationCalls>();

                try
                {
                    sqlCon.Open();
                    SqlDataReader reader        = sqlComm.ExecuteReader();
                    var           clientSidelst = new List <AssignedUserList>();
                    var           ccSidelst     = new List <AssignedUserList>();
                    while (reader.Read())
                    {
                        var a = new AssignedUserList
                        {
                            formId    = int.Parse(reader.GetValue(reader.GetOrdinal("form_id")).ToString()),
                            processed = (reader.GetValue(reader.GetOrdinal("processed")).ToString()),
                            assigned  = (reader.GetValue(reader.GetOrdinal("assigned")).ToString()),
                        };
                        clientSidelst.Add(a);
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            var a = new AssignedUserList
                            {
                                formId    = int.Parse(reader.GetValue(reader.GetOrdinal("form_id")).ToString()),
                                processed = (reader.GetValue(reader.GetOrdinal("processed")).ToString()),
                                assigned  = (reader.GetValue(reader.GetOrdinal("assigned")).ToString()),
                            };
                            ccSidelst.Add(a);
                        }
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            try
                            {
                                CalibrationStatus ccSide = new CalibrationStatus()
                                {
                                    completed = int.Parse(reader.GetValue(reader.GetOrdinal("cc_completed")).ToString()),
                                    reviewed  = int.Parse(reader.GetValue(reader.GetOrdinal("cc_available")).ToString()),
                                };

                                CalibrationStatus clientSide = new CalibrationStatus()
                                {
                                    completed = int.Parse(reader.GetValue(reader.GetOrdinal("Client_Completed")).ToString()),
                                    reviewed  = int.Parse(reader.GetValue(reader.GetOrdinal("client_available")).ToString()),
                                };
                                CalibrationStatus status = new CalibrationStatus()
                                {
                                    completed = int.Parse(reader.GetValue(reader.GetOrdinal("Real_Num_Completed")).ToString()),
                                    reviewed  = int.Parse(reader.GetValue(reader.GetOrdinal("Real_Num_Reviews")).ToString()),
                                };
                                Scorecard scorecard = new Scorecard()
                                {
                                    scorecardId   = int.Parse(reader.GetValue(reader.GetOrdinal("scorecardId")).ToString()),
                                    scorecardName = reader.GetValue(reader.GetOrdinal("Short_Name")).ToString(),
                                };
                                calibrationsPendingInfoList.Add(new CalibrationCalls
                                {
                                    ccSide        = ccSide,
                                    clientSide    = clientSide,
                                    status        = status,
                                    scorecard     = scorecard,
                                    calibrationId = int.Parse(reader.GetValue(reader.GetOrdinal("Form_ID")).ToString()),
                                    dateAdded     = DateTime.Parse(reader.GetValue(reader.GetOrdinal("DateAdded")).ToString()),
                                    weekEndDate   = DateTime.Parse(reader.GetValue(reader.GetOrdinal("week_ending_date")).ToString()),
                                    phone         = reader.GetValue(reader.GetOrdinal("Phone")).ToString(),
                                    callDate      = DateTime.Parse(reader.GetValue(reader.GetOrdinal("call_date")).ToString()),
                                    callLength    = float.Parse(reader.GetValue(reader.GetOrdinal("call_length")).ToString()),
                                    callType      = reader.GetValue(reader.GetOrdinal("callType")).ToString(),
                                    ownedCall     = bool.Parse(reader.GetValue(reader.GetOrdinal("owned_call")).ToString()),
                                    callId        = int.Parse(reader.GetValue(reader.GetOrdinal("callId")).ToString())
                                });
                            }

                            catch (Exception ex) { }
                        }
                    }
                    ;
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            try
                            {
                                CalibrationStatus ccSide = new CalibrationStatus()
                                {
                                    completed = int.Parse(reader.GetValue(reader.GetOrdinal("cc_completed")).ToString()),
                                    reviewed  = int.Parse(reader.GetValue(reader.GetOrdinal("cc_available")).ToString()),
                                };

                                CalibrationStatus clientSide = new CalibrationStatus()
                                {
                                    completed = int.Parse(reader.GetValue(reader.GetOrdinal("Client_Completed")).ToString()),
                                    reviewed  = int.Parse(reader.GetValue(reader.GetOrdinal("client_available")).ToString()),
                                };
                                CalibrationStatus status = new CalibrationStatus()
                                {
                                    completed = int.Parse(reader.GetValue(reader.GetOrdinal("Real_Num_Completed")).ToString()),
                                    reviewed  = int.Parse(reader.GetValue(reader.GetOrdinal("Real_Num_Reviews")).ToString()),
                                };
                                Scorecard scorecard = new Scorecard()
                                {
                                    scorecardId   = 1,
                                    scorecardName = reader.GetValue(reader.GetOrdinal("Short_Name")).ToString(),
                                };
                                completedUserList.Add(new CompletedUserList()
                                {
                                    formId      = int.Parse(reader.GetValue(reader.GetOrdinal("Form_ID")).ToString()),
                                    completedBy = reader.GetValue(reader.GetOrdinal("who_processed")).ToString(),
                                    reviewTime  = int.Parse(reader.GetValue(reader.GetOrdinal("review_time")).ToString()),
                                });
                                calibrationsCalibratedInfoList.Add(new CalibrationCalls
                                {
                                    dateAdded     = DateTime.Parse(reader.GetValue(reader.GetOrdinal("DateAdded")).ToString()),
                                    ccSide        = ccSide,
                                    clientSide    = clientSide,
                                    status        = status,
                                    scorecard     = scorecard,
                                    calibrationId = int.Parse(reader.GetValue(reader.GetOrdinal("Form_ID")).ToString()),
                                    phone         = reader.GetValue(reader.GetOrdinal("Phone")).ToString(),
                                    callDate      = DateTime.Parse(reader.GetValue(reader.GetOrdinal("call_date")).ToString()),
                                    weekEndDate   = DateTime.Parse(reader.GetValue(reader.GetOrdinal("week_ending_date")).ToString()),
                                    callLength    = float.Parse(reader.GetValue(reader.GetOrdinal("call_length")).ToString()),
                                    callType      = reader.GetValue(reader.GetOrdinal("callType")).ToString(),
                                    callId        = int.Parse(reader.GetValue(reader.GetOrdinal("callId")).ToString())
                                });
                            }
                            catch (Exception ex) { }
                        }
                    }

                    var calibrationsPendingInfoListGrouped = new List <CalibrationCalls>();
                    foreach (var cal in calibrationsPendingInfoList)
                    {
                        var caltmp = cal;
                        caltmp.ccSide.whoProcessed     = (from c in ccSidelst where c.formId == caltmp.callId select c.processed).ToList();
                        caltmp.ccSide.assignedTo       = (from c in ccSidelst where c.formId == caltmp.callId select c.assigned).ToList();
                        caltmp.clientSide.whoProcessed = (from c in clientSidelst where c.formId == caltmp.callId select c.processed).ToList();
                        caltmp.clientSide.assignedTo   = (from c in clientSidelst where c.formId == caltmp.callId select c.assigned).ToList();

                        calibrationsPendingInfoListGrouped.Add(caltmp);
                        //continue;
                    }
                    var calibrationsCalibratedInfoListGrouped = new List <CalibrationCalls>();
                    foreach (var c in calibrationsCalibratedInfoList.Distinct())
                    {
                        var tmp = c;
                        tmp.completedUserList = (from a in completedUserList where a.formId == tmp.callId select a).ToList();
                        calibrationsCalibratedInfoListGrouped.Add(tmp);
                    }

                    return(new CalibrationCallsInfo()
                    {
                        pending = calibrationsPendingInfoListGrouped, completed = calibrationsCalibratedInfoListGrouped
                    });
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
예제 #22
0
 public CalibrationCompletedArgs(CalibrationStatus result)
 {
     Result = result;
 }
예제 #23
0
        // <BeginExample>
        private IEnumerator Calibrate(Point3D[] calibrationPoints, GameObject target)
        {
            if (_eyeTracker == null)
            {
                yield break;
            }

            _eyeTracker.CalibrationModeEntered += EyeTracker_CalibrationModeEntered;
            _eyeTracker.CalibrationModeLeft    += EyeTracker_CalibrationModeLeft;

            // Create a calibration object.
            var calibration = new HMDBasedCalibration(_eyeTracker);

            // Enter calibration mode.
            calibration.EnterCalibrationMode();

            // Get and set the lens cup separation
            float hmdIpdInMeter;

            if (TobiiPro_Util.TryGetHmdLensCupSeparationInMeter(out hmdIpdInMeter) == false)
            {
                Debug.LogWarning("TobiiPro: Failed to get lens cup separation from HMD. Setting default lens cup separation.");
                hmdIpdInMeter = 0.0635f;
            }

            TobiiPro_Util.SetLensCupSeparation(hmdIpdInMeter);
            // Collect data.
            var index           = 0;
            var remainingPoints = true;

            while (remainingPoints)
            {
                // Play intro animation for the point
                _hasAnimated = false;
                WaitingOnIntroAnimation.Invoke(this, new IntroAnimationArgs(index));

                yield return(StartCoroutine(WaitingForAnimation()));

                var point = calibrationPoints[index];

                point = new Point3D(-point.X, point.Y, point.Z);

                // Show an image on screen where you want to calibrate.
                // target.transform.localPosition = new Vector3(-point.X, point.Y, point.Z) / 1000f;

                // Wait a little for user to focus.
                yield return(new WaitForSeconds(1.5f));


                // Collect data.
                CalibrationStatus status = calibration.CollectData(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 ComputeAndApply.
                    Debug.Log("TobiiPro: Calibration for this point wasn't success, try again.");
                    calibration.CollectData(point);
                }

                index++;

                // Outro animation for the point
                _hasAnimated = false;
                WaitingOnOutroAnimation.Invoke(this, null);
                yield return(StartCoroutine(WaitingForAnimation()));

                // Check if there are more points remaining
                if (index > calibrationPoints.Length - 1)
                {
                    remainingPoints = false;
                }
            }
            // Compute and apply the calibration.
            HMDCalibrationResult calibrationResult = calibration.ComputeAndApply();

            Debug.Log(string.Format("Compute and apply returned {0}.", calibrationResult.Status));
            // See that you're happy with the result.
            // The calibration is done. Leave calibration mode.

            OnCalibrationCompleted.Invoke(this, new CalibrationCompletedArgs(calibrationResult.Status));

            if (target != null)
            {
                Destroy(target);
            }

            _eyeTracker.CalibrationModeEntered -= EyeTracker_CalibrationModeEntered;
            calibration.LeaveCalibrationMode();

            _eyeTracker.CalibrationModeLeft -= EyeTracker_CalibrationModeLeft;
        }
예제 #24
0
        public void Successful_Scenario_Test(byte calibrationState, byte calibrationError, CalibrationStatus status, string errorMessage)
        {
            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x29 });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { 0x00, calibrationState, calibrationError });

            var sut    = new QueryCalibrationCommand();
            var result = sut.Execute(ftdiMock.Object);

            result.Success.Should().BeTrue();
            result.CalibrationStatus.Should().Be(status);
            result.Error.Should().Be(errorMessage);
        }
예제 #25
0
        /// <summary>
        /// The thread function that calls the blocking calibration methods.
        /// </summary>
        private void ThreadFunction()
        {
            var eyeTracker = EyeTrackerIF;

            if (eyeTracker == null)
            {
                return;
            }

            Running = true;

            // Create the calibration object.
            ScreenBasedCalibration screenBasedCalibration = null;
            HMDBasedCalibration    hmdBasedCalibration    = null;

            if (ScreenBased)
            {
                screenBasedCalibration = new ScreenBasedCalibration(eyeTracker);
            }
            else
            {
                hmdBasedCalibration = new HMDBasedCalibration(eyeTracker);
            }

            // Find out how long the calls took using a stopwatch.
            var stopWatch = new System.Diagnostics.Stopwatch();

            // Handle the calibration commands.
            while (Running)
            {
                var currentResult = MethodResult.CurrentResult;
                stopWatch.Reset();
                stopWatch.Start();

                if (currentResult == null)
                {
                    Thread.Sleep(25);
                }
                else
                {
                    switch (currentResult.Command)
                    {
                    case MethodResult.CommandType.Invalid:
                        Thread.Sleep(25);
                        break;

                    case MethodResult.CommandType.Enter:
                        if (screenBasedCalibration != null)
                        {
                            screenBasedCalibration.EnterCalibrationMode();
                        }
                        else
                        {
                            hmdBasedCalibration.EnterCalibrationMode();
                        }

                        stopWatch.Stop();
                        currentResult.Finished(CalibrationStatus.Success, (int)stopWatch.ElapsedMilliseconds);
                        break;

                    case MethodResult.CommandType.Collect:
                        var collectResult = screenBasedCalibration != null?
                                            screenBasedCalibration.CollectData(MethodResult.CurrentPoint) :
                                                hmdBasedCalibration.CollectData(MethodResult.CurrentPoint);

                        stopWatch.Stop();
                        currentResult.Finished(collectResult, (int)stopWatch.ElapsedMilliseconds);
                        break;

                    case MethodResult.CommandType.Compute:
                        CalibrationStatus status = screenBasedCalibration != null?
                                                   screenBasedCalibration.ComputeAndApply().Status:
                                                   hmdBasedCalibration.ComputeAndApply().Status;

                        stopWatch.Stop();
                        currentResult.Finished(status, (int)stopWatch.ElapsedMilliseconds);
                        break;

                    case MethodResult.CommandType.Leave:
                        if (screenBasedCalibration != null)
                        {
                            screenBasedCalibration.LeaveCalibrationMode();
                        }
                        else
                        {
                            hmdBasedCalibration.LeaveCalibrationMode();
                        }

                        stopWatch.Stop();
                        currentResult.Finished(CalibrationStatus.Success, (int)stopWatch.ElapsedMilliseconds);
                        break;

                    default:
                        Thread.Sleep(25);
                        break;
                    }
                }
            }

            if (hmdBasedCalibration != null)
            {
                hmdBasedCalibration.Dispose();
            }

            if (screenBasedCalibration != null)
            {
                screenBasedCalibration.Dispose();
            }
        }
예제 #26
0
 public CalibrationStatusResult(CalibrationStatus status) : base(true)
 {
     CalibrationStatus = status;
 }
예제 #27
0
 public CalibrationStatusResult(CalibrationStatus status, string error) : base(true)
 {
     CalibrationStatus = status;
     Error             = error;
 }
예제 #28
0
 private void InternalCalibrationInProgress(IntPtr hNode, UserID id, CalibrationStatus status, IntPtr pCookie)
 {
     EventHandler<CalibrationProgressEventArgs> handlers = this.calibrationInProgressEvent;
     if (handlers != null)
         handlers(this.node, new CalibrationProgressEventArgs(id, status));
 }
예제 #29
0
 public CalibrationProgressEventArgs(UserID id, CalibrationStatus status)
     : base(id)
 {
     this.status = status;
 }
예제 #30
0
 public CalibrationProgressEventArgs(UserID id, CalibrationStatus status)
     : base(id)
 {
     this.status = status;
 }
예제 #31
0
 public CalibrationResult(IEnumerable <CalibrationPointResult> points, CalibrationStatus status)
     : this(points)
 {
     Status = status;
 }