-
-
Save daz/11b6aaa681a55cf75a1086f1f5dcf073 to your computer and use it in GitHub Desktop.
Tobii EyeX UDP data shipper to VMWare VM host.
This file contains hidden or 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(); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment