コード例 #1
4
ファイル: EyeCalibrator.cs プロジェクト: Faham/emophiz
        private void ComputeCompleted(object sender, AsyncCompletedEventArgs<Empty> e)
        {
            _calibrationForm.Close();

            if(e.Error != null)
            {
                _calibrationResult = null;
            }
            else
            {
                _calibrationResult = _tracker.GetCalibration();
            }
        }
コード例 #2
0
ファイル: CalibrationViewer.cs プロジェクト: Faham/emophiz
        public static Image GetCalibrationImage(TobiiCalibration calibration)
        {
            // Create image to draw to
            Bitmap bitmap = new Bitmap(250, 250, PixelFormat.Format32bppArgb);
            Graphics graphicsDevice = Graphics.FromImage(bitmap);
            graphicsDevice.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;

            foreach(CalibrationPlotItem plotItem in calibration.Plot)
            {
                using(Pen pen = new Pen(Color.DarkGray))
                {

                    // Draw calibration points
                    Rectangle r = GetCalibrationCircleBounds(new PointF(plotItem.TrueX, plotItem.TrueY), circleRadius);
                    graphicsDevice.DrawEllipse(pen,r);

                    // Draw bounds
                    pen.Color = Color.LightGray;
                    Rectangle canvasBounds = GetCanvasBounds();
                    graphicsDevice.DrawRectangle(pen,canvasBounds);

                    // Draw errors
                    if (plotItem.ValidityLeft == 1)
                    {
                        pen.Color = Color.Red;

                        Point p1 = PixelPointFromNormalizedPoint(new PointF(plotItem.TrueX, plotItem.TrueY));
                        Point p2 = PixelPointFromNormalizedPoint(new PointF(plotItem.MapLeftX, plotItem.MapLeftY));

                        graphicsDevice.DrawLine(pen, p1, p2);
                    }

                    if (plotItem.ValidityRight == 1)
                    {
                        pen.Color = Color.Lime;

                        Point p1 = PixelPointFromNormalizedPoint(new PointF(plotItem.TrueX, plotItem.TrueY));
                        Point p2 = PixelPointFromNormalizedPoint(new PointF(plotItem.MapRightX, plotItem.MapRightY));

                        graphicsDevice.DrawLine(pen, p1, p2);
                    }

                }
            }

            return bitmap;
        }
コード例 #3
0
ファイル: EyeCalibrator.cs プロジェクト: Faham/emophiz
 private void AbortCalibration()
 {
     _calibrationResult = null;
     _sleepTimer.Stop();
     _calibrationForm.Close();
 }
コード例 #4
0
ファイル: EyeCalibrator.cs プロジェクト: Faham/emophiz
        private void StartNextOrFinish()
        {
            if (_calibrationForm.InvokeRequired)
            {
                _calibrationForm.Invoke(new Action(StartNextOrFinish));
                return;
            }

            if(_calibrationPoints.Count > 0)
            {
                var point = _calibrationPoints.Dequeue();
                _calibrationForm.DrawCalibrationPoint(point,Color.Yellow);
                _sleepTimer.Start();
            }
            else
            {

                _sleepTimer.Stop();

                // Use the async version of ComputeCalibration since
                // this call takes some time
                _calibrationForm.Close();

                try
                {
                    _tracker.ComputeCalibration();
                    _calibrationResult = _tracker.GetCalibration();
                }
                catch
                {
                    _calibrationResult = null;
                }

                //!!_tracker.ComputeCalibrationAsync(ComputeCompleted);

            }
        }