Created
March 17, 2016 19:04
-
-
Save trishume/b25492f25fc8ebe01dd9 to your computer and use it in GitHub Desktop.
Tobii EyeX UDP data shipper to VMWare VM host.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Used to send data from a VMWare VM running the EyeX software | |
// with a Steelseries Sentry to a Mac OSX host over UDP. | |
namespace MinimalGazeDataStream | |
{ | |
using EyeXFramework; | |
using System; | |
using System.Net; | |
using System.Net.Sockets; | |
using System.Text; | |
using Tobii.EyeX.Framework; | |
public static class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | |
IPAddress addr = IPAddress.Parse("192.168.181.1"); | |
IPEndPoint ep = new IPEndPoint(addr, 11249); | |
using (var eyeXHost = new EyeXHost()) | |
{ | |
// Create a data stream: lightly filtered gaze point data. | |
// Other choices of data streams include EyePositionDataStream and FixationDataStream. | |
using (var lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) | |
// using (var lightlyFilteredGazeDataStream = eyeXHost.CreateFixationDataStream(FixationDataMode.Sensitive)) | |
{ | |
using (var eyeStream = eyeXHost.CreateEyePositionDataStream()) | |
{ | |
// Start the EyeX host. | |
eyeXHost.Start(); | |
// Write the data to the console. | |
lightlyFilteredGazeDataStream.Next += (s, e) => | |
{ | |
string msg = String.Format("{{\"gaze\":[{0},{1}],\"time\": {2}}}", e.X, e.Y, e.Timestamp); | |
byte[] sendbuf = Encoding.ASCII.GetBytes(msg); | |
sock.SendTo(sendbuf, ep); | |
// Console.WriteLine("G: {0}", msg); | |
}; | |
eyeStream.Next += (s, e) => | |
{ | |
string msg = String.Format("{{\"leftEye\":[{0},{1},{2}],\"rightEye\":[{3},{4},{5}],\"time\": {6}}}", | |
e.LeftEye.X, e.LeftEye.Y, e.LeftEye.Z, | |
e.RightEye.X, e.RightEye.Y, e.RightEye.Z, | |
e.Timestamp); | |
byte[] sendbuf = Encoding.ASCII.GetBytes(msg); | |
sock.SendTo(sendbuf, ep); | |
// Console.WriteLine("E: {0}", msg); | |
}; | |
// Let it run until a key is pressed. | |
Console.WriteLine("Listening for gaze data, press any key to exit..."); | |
Console.In.Read(); | |
} | |
} | |
} | |
} | |
} | |
} |
Thanks for posting this! Unfortunately I got a bit stuck on the setup. Would you be able to describe in a bit more detail the steps to set up the project?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll need to put it in a visual studio solution, and add the EyeXHost project and Client.Net20 dll as references.