/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the Client class. /// </summary> public Client() { // Will attempt to load "GazeTrackerSettings.xml" from execution dir. or set default this.settings = new Settings(); this.socketUdpReceive = new Socket( AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.commands = new Commands(); this.stream = new Stream(this); this.streamformat = new StreamFormat { TimeStampMilliseconds = true, GazePosition = true, EyetrackingType = StreamFormat.EyeTrackingType.Left }; this.stream.StreamFormat = this.streamformat; this.tracker = new Tracker(); this.camera = new Camera(this); this.calibration = new Calibration(this); this.uiControl = new UIControl(this); this.log = new Log(this); // Not fully implemented yet.. this.MouseControl = new MouseControl(); // On new gaze data this.gazeData = new GazeData(); this.gazeData.OnSmoothedGazeData += this.MouseControl.Move; }
/// <summary> /// This function moves the cursor to a specific point at the screen. /// </summary> /// <param name="x">X coordinate of the posotion as pixel</param> /// <param name="y">Y coordinate of the posotion as pixel</param> /// <returns>Returns 0 if there was an error otherwise 1.</returns> /// public void Move(GazeData gData) { if (isEnabled) { double ScreenWidth = Screen.PrimaryScreen.Bounds.Width; double ScreenHeight = Screen.PrimaryScreen.Bounds.Height; var input_move = new INPUT(); input_move.mi.dx = (int)Math.Round(gData.GazePositionX * (65535 / ScreenWidth), 0); input_move.mi.dy = (int)Math.Round(gData.GazePositionY * (65535 / ScreenHeight), 0); input_move.mi.mouseData = 0; input_move.mi.dwFlags = (int)(MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE); INPUT[] input = { input_move }; } //return SendInput(1, input, Marshal.SizeOf(input_move)); }
/// <summary> /// Initializes a new instance of the Client class. /// </summary> public Client() { // Will attempt to load "GazeTrackerSettings.xml" from execution dir. or set default this.settings = new Settings(); this.socketUdpReceive = new Socket( AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.commands = new Commands(); this.stream = new Stream(this); this.streamformat = new StreamFormat { TimeStampMilliseconds = true, GazePosition = true, EyetrackingType = StreamFormat.EyeTrackingType.Left }; this.stream.StreamFormat = this.streamformat; this.tracker = new Tracker(); this.camera = new Camera(this); this.calibration = new Calibration(this); this.uiControl = new UIControl(this); this.log = new Log(this); // Not fully implemented yet.. this.MouseControl = new MouseControl(); // On new gaze data this.gazeData = new GazeData(); this.gazeData.OnSmoothedGazeData += this.MouseControl.Move; }
private void OnGazeData(GazeData data) { if(onStream) SendMessage("GAZE_DATA", data.GazePositionX + " " + data.GazePositionY); }
private void GazeData_OnGazeData(GazeData gData) { Dispatcher.Invoke( (Action) delegate { if (gData.TimeStamp == prevTime) // if its the same timestamp, don't bother.. return; string s = gData.TimeStamp + "\t" + gData.GazePositionX + "\t" + gData.GazePositionY + "\t" + gData.PupilDiameterLeft; // Only keep 15 log lines... if (receivedData.Count <= receivedDataMaxLines) receivedData.Add(s); else { for (int i = 0; i < receivedDataMaxLines; i++) { receivedData[i] = receivedData[i + 1]; } receivedData[receivedDataMaxLines] = s; } // Clear textbox TextBlockData.Text = ""; // List received data foreach (string dataStr in receivedData) { TextBlockData.Text = TextBlockData.Text + dataStr + "\n"; } prevTime = gData.TimeStamp; }, DispatcherPriority.Background, null); }
/// <summary> /// This function moves the cursor to a specific point at the screen. /// </summary> /// <param name="x">X coordinate of the posotion as pixel</param> /// <param name="y">Y coordinate of the posotion as pixel</param> /// <returns>Returns 0 if there was an error otherwise 1.</returns> /// public void Move(GazeData gData) { if (isEnabled) { double ScreenWidth = Screen.PrimaryScreen.Bounds.Width; double ScreenHeight = Screen.PrimaryScreen.Bounds.Height; var input_move = new INPUT(); input_move.mi.dx = (int) Math.Round(gData.GazePositionX*(65535/ScreenWidth), 0); input_move.mi.dy = (int) Math.Round(gData.GazePositionY*(65535/ScreenHeight), 0); input_move.mi.mouseData = 0; input_move.mi.dwFlags = (int) (MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE); INPUT[] input = {input_move}; } //return SendInput(1, input, Marshal.SizeOf(input_move)); }
private void OnGazeData(GazeData data) { if (onStream) { //GazeTime = new TimeSpan(); //GazeTime = DateTime.UtcNow - StartTime; TimeSpan GazeTimeLong = DateTime.UtcNow - StartTime; gazeX = Math.Round(data.GazePositionX, 0); gazeY = Math.Round(data.GazePositionY, 0); SendMessageData("GAZE_DATA", (long)GazeTimeLong.TotalMilliseconds, gazeX + " " + gazeY); } }