From 5fc489075c9e60245ed944b367d3cf7ce28f69b8 Mon Sep 17 00:00:00 2001 From: Gribanov Dmitry <74065724+GribanovDS@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:12:02 +0300 Subject: [PATCH 1/5] added --raw and ---out possibilities --- EyeLog/Program.cs | 51 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/EyeLog/Program.cs b/EyeLog/Program.cs index 4f275c2..1b44358 100644 --- a/EyeLog/Program.cs +++ b/EyeLog/Program.cs @@ -1,5 +1,5 @@ -using Tobii.Interaction; - +using Tobii.Interaction; +using System.IO; using System ; using System.Collections.Generic; using System.Linq; @@ -23,11 +23,39 @@ internal class Program private static long lastClicksCount; private static long EXIT_TIMEOUT = 1000; + static bool rawMode = false; + static StreamWriter logWriter = null; + + static void Main(string[] args) { + foreach (var arg in args) + { + if (arg == "--raw") + { + rawMode = true; + Console.WriteLine("Running in RAW mode..."); + } + else if (arg.StartsWith("--out=")) + { + var path = arg.Substring("--out=".Length); + try + { + logWriter = new StreamWriter(path, append: true); + logWriter.AutoFlush = true; + Console.WriteLine($"Logging to file: {path}"); + } + catch (Exception ex) + { + Console.Error.WriteLine("Failed to open log file: " + ex.Message); + } + } + } + host = new Host(); host.EnableConnection(); - host.Streams.CreateGazePointDataStream().Next += OnGaze; + host.Streams.CreateGazePointDataStream().Next += OnGaze; + new Thread(new ThreadStart(InputCycle)).Start(); new Thread(new ThreadStart(EyeCycle)).Start(); } @@ -159,12 +187,27 @@ private static void InputCycle() } } + private static void OnGaze(object sender, StreamData e) { CurrentEyeValue = e; ts = DateTime.Now.ToFileTime(); + + string line; + if (rawMode) + line = $"{e.Data.X},{e.Data.Y},{e.Data.Timestamp}"; + else + line = $"{e.Data.X}:{e.Data.Y}"; + + Console.WriteLine(line); + + if (logWriter != null) + { + logWriter.WriteLine(line); + } } - + + } } From bfa66bdbc0171c835a158fc0a64c68503ad99309 Mon Sep 17 00:00:00 2001 From: Gribanov Dmitry <74065724+GribanovDS@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:19:22 +0300 Subject: [PATCH 2/5] Update README.md --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3cda23a..26008e0 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ Before running EyeLog, make sure you have the following prerequisites installed: 2. **C# Development Environment**: You need a C# development environment to compile and run the code. Visual Studio is recommended, but you can use any C# IDE of your choice. +3. **Visual C++ Redistributable (x64)**: Required for Tobii native libraries. + Download and install from: [Microsoft Visual C++ Redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe). + ## Getting Started 1. Clone or download the EyeLog repository to your local machine. @@ -20,31 +23,60 @@ Before running EyeLog, make sure you have the following prerequisites installed: ## Usage -EyeLog listens for user input and gaze data, allowing you to interact with it via the command line. Here are the available commands and how to use them: - -- **Define Areas of Interest**: You can define custom areas of interest on the screen by inputting their coordinates and dimensions in the following format: `x1,y1,width1,height1;x2,y2,width2,height2;...`. For example: - ``` - 100,100,200,200;300,300,150,150; - ``` - -- **Change Click Timeout**: You can adjust the click detection timeout by typing `timeout:`. For example, to set a timeout of 1500 milliseconds (1.5 seconds), type: - ``` - timeout:1500 - ``` - -- **Exit the Program**: You can exit the program at any time by using your system's exit command (e.g., pressing Ctrl+C). +EyeLog listens for user input and gaze data, allowing you to interact with it via the command line. Here are the available options and commands: + +### Command-Line Flags + +- **`--raw`** + When this flag is provided, EyeLog will output raw gaze data directly to the console in the format: +``` +X,Y,Timestamp +``` +This is useful if you want unprocessed eye-tracking data. + +- **`--out `** +Use this flag to write output logs to a file in addition to the console. For example: +``` +EyeLog.exe --out gaze_log.txt +``` +This will create (or append to) a file named `gaze_log.txt` containing the log data. + +### Interactive Commands + +- **Define Areas of Interest**: +You can define custom areas of interest on the screen by inputting their coordinates and dimensions in the following format: +``` +x1,y1,width1,height1;x2,y2,width2,height2;... +``` +Example: +``` +100,100,200,200;300,300,150,150; +``` + +- **Change Click Timeout**: +You can adjust the click detection timeout by typing `timeout:`. +Example: +``` +timeout:1500 +``` + +- **Exit the Program**: +Exit at any time by using your system's exit command (e.g., pressing `Ctrl+C`). ## How It Works EyeLog runs two main threads: -1. **InputCycle Thread**: This thread listens for user input via the command line. You can use it to define areas of interest and adjust the click timeout. +1. **InputCycle Thread**: Listens for user input via the command line. You can use it to define areas of interest and adjust the click timeout. -2. **EyeCycle Thread**: This thread continuously monitors the user's gaze data and tracks when it enters, exits, or stays within the defined areas of interest. It also logs click events based on the specified timeout. +2. **EyeCycle Thread**: Continuously monitors the user's gaze data and tracks when it enters, exits, or stays within the defined areas of interest. It also logs click events based on the specified timeout. ## Output -EyeLog outputs information to the console, including: +EyeLog outputs information to the console (and optionally a file if `--out` is specified): + +- **Raw Mode (`--raw`)**: +Continuous gaze coordinates in `X,Y,Timestamp` format. - **Enter**: When the user's gaze enters an area of interest, it logs the area's index. - **Exit**: When the user's gaze exits an area of interest, it logs an "exit" message. @@ -56,7 +88,11 @@ Feel free to customize and extend EyeLog according to your needs. You can add mo ## Troubleshooting -If you encounter any issues or have questions about EyeLog, please refer to the Tobii Interaction SDK documentation or seek assistance from the Tobii support community. +If you encounter issues: +- Make sure Tobii Experience (or Tobii Interaction SDK services) is running. +- Verify you installed the [Visual C++ Redistributable (x64)](https://aka.ms/vs/17/release/vc_redist.x64.exe). +- Confirm your project is built for **x64** (to match Tobii SDK libraries). +- Refer to the Tobii Interaction SDK documentation or seek assistance from the Tobii support community. ## License @@ -64,4 +100,4 @@ This project is provided under the [MIT License](LICENSE.md). --- -Enjoy using EyeLog to track and log eye movements and interactions! If you find it helpful, consider contributing to the project or sharing your enhancements with the community. \ No newline at end of file +Enjoy using EyeLog to track and log eye movements and interactions! If you find it helpful, consider contributing to the project or sharing your enhancements with the community. From 7a7c75eb5fb21ddde4707c9e5f53044da3a2defe Mon Sep 17 00:00:00 2001 From: Gribanov Dmitry <74065724+GribanovDS@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:20:03 +0300 Subject: [PATCH 3/5] Update README.md From e57d548662ba0fdf798574f7b074a31389b47780 Mon Sep 17 00:00:00 2001 From: Gribanov Dmitry <74065724+GribanovDS@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:34:49 +0300 Subject: [PATCH 4/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26008e0..35b7a6f 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ X,Y,Timestamp ``` This is useful if you want unprocessed eye-tracking data. -- **`--out `** +- **`--out=`** Use this flag to write output logs to a file in addition to the console. For example: ``` -EyeLog.exe --out gaze_log.txt +EyeLog.exe --out=gaze_log.txt ``` This will create (or append to) a file named `gaze_log.txt` containing the log data. From 6da90ad9ee61fb3c94dd0a3fefc8b8fc91c4810b Mon Sep 17 00:00:00 2001 From: Gribanov Dmitry <74065724+GribanovDS@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:17:19 +0300 Subject: [PATCH 5/5] Update Program.cs --- EyeLog/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/EyeLog/Program.cs b/EyeLog/Program.cs index 1b44358..bc0b7cc 100644 --- a/EyeLog/Program.cs +++ b/EyeLog/Program.cs @@ -199,8 +199,6 @@ private static void OnGaze(object sender, StreamData e) else line = $"{e.Data.X}:{e.Data.Y}"; - Console.WriteLine(line); - if (logWriter != null) { logWriter.WriteLine(line);