Beispiel #1
0
        private void GazeInputSourcePreview_GazeMoved(GazeInputSourcePreview sender, GazeMovedPreviewEventArgs args)
        {
            if (!ShowIntermediatePoints)
            {
                UpdateGazeHistory(args.CurrentPoint);
                return;
            }

            var points = args.GetIntermediatePoints();

            foreach (var pt in points)
            {
                UpdateGazeHistory(pt);
            }
        }
 private void OnGazeMoved(
     GazeInputSourcePreview provider,
     GazeMovedPreviewEventArgs args)
 {
     if (!_isShuttingDown)
     {
         var intermediatePoints = args.GetIntermediatePoints();
         foreach (var point in intermediatePoints)
         {
             var position = point.EyeGazePosition;
             if (position != null)
             {
                 _gazeCursor.IsGazeEntered = true;
                 ProcessGazePoint(new TimeSpan((long)point.Timestamp * 10), position.Value);
             }
             else
             {
                 // Debug.WriteLine("Null position eaten at %ld", point.Timestamp);
             }
         }
     }
 }
        private void OnGazeMoved(GazeInputSourcePreview sender, GazeMovedPreviewEventArgs args)
        {
            var points = args.GetIntermediatePoints();

            if (points.Count != 1)
            {
                Log($"Grouped points reported in move, Count={points.Count}");
            }

            foreach (var point in points)
            {
                var position  = point.EyeGazePosition;
                var timestamp = TimeSpan.FromMilliseconds(point.Timestamp / 1000.0);

                if (!_isReporting)
                {
                    _startTimestamp = timestamp;
                    if (!_isEntered)
                    {
                        Log("Gaze report without enter");
                        _isEntered = true;
                    }
                    else if (_isFirstReportExpected && (_lastPosition.HasValue != position.HasValue ||
                                                        (_lastPosition.HasValue &&
                                                         !(_lastPosition.Value.X == position.Value.X &&
                                                           _lastPosition.Value.Y == position.Value.Y))))
                    {
                        Log("First report after enter is inconsistent", point);
                    }
                    _isFirstReportExpected = false;

                    _newPositionCount    = position.HasValue ? 1 : 0;
                    _noPositionCount     = position.HasValue ? 0 : 1;
                    _repeatPositionCount = 0;
                    _blickCount          = 0;

                    _minDelta = TimeSpan.MaxValue;
                    _maxDelta = TimeSpan.MinValue;

                    _isReporting = true;

                    _reportingTimer.Start();
                }
                else
                {
                    var delta = timestamp - _lastTimestamp;
                    if (delta < _minDelta)
                    {
                        _minDelta = delta;
                    }
                    if (_maxDelta < delta)
                    {
                        _maxDelta = delta;
                    }

                    if (2 * _minDelta < delta)
                    {
                        _blickCount++;
                    }

                    if (_lastPosition.HasValue)
                    {
                        if (position.HasValue)
                        {
                            if (_lastPosition == position)
                            {
                                _repeatPositionCount++;
                            }
                            else
                            {
                                _newPositionCount++;
                            }
                        }
                        else
                        {
                            _noPositionCount++;
                        }
                    }
                    else
                    {
                        if (position.HasValue)
                        {
                            _newPositionCount++;
                        }
                        else
                        {
                            _noPositionCount++;
                        }
                    }
                }
                _lastPosition  = position;
                _lastTimestamp = timestamp;
                _lastTickCount = TimeSpan.FromMilliseconds(Environment.TickCount);
            }
        }