Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Eye-Tracking Classroom
/
gaze-server.cs
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
27926ae6
authored
Sep 30, 2019
by
Stefan Schreistetter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added server-side gaze simulation via mouse input.
parent
a3cc0c2e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
4 deletions
+37
-4
GazeWebSocketServer/GazeServer.cs
+2
-0
GazeWebSocketServer/GazeWebSocketServer.csproj
+2
-0
GazeWebSocketServer/Program.cs
+29
-0
TrackerBridge/GazeDataProcessor.cs
+4
-4
No files found.
GazeWebSocketServer/GazeServer.cs
View file @
27926ae6
...
...
@@ -11,6 +11,7 @@ namespace GazeWebSocketServer
class
GazeServer
{
private
WebSocketServer
wssv
;
public
Boolean
isRunning
=
false
;
public
GazeServer
(
Int32
port
,
String
endpoint
)
{
wssv
=
new
WebSocketServer
(
port
);
...
...
@@ -20,6 +21,7 @@ namespace GazeWebSocketServer
public
void
Start
()
{
wssv
.
Start
();
isRunning
=
true
;
}
public
void
Publish
(
GazeData
gazeData
)
...
...
GazeWebSocketServer/GazeWebSocketServer.csproj
View file @
27926ae6
...
...
@@ -39,6 +39,8 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
...
...
GazeWebSocketServer/Program.cs
View file @
27926ae6
...
...
@@ -5,6 +5,8 @@ using WebSocketSharp;
using
WebSocketSharp.Server
;
using
Tobii.Research
;
using
TrackerBridge
;
using
System.Windows.Forms
;
using
System.Drawing
;
namespace
GazeWebSocketServer
{
...
...
@@ -16,22 +18,49 @@ namespace GazeWebSocketServer
ConfigurationData
.
InitializeUnexistingWithDefaults
();
ConfigurationData
config
=
ConfigurationData
.
ParseToObject
();
if
(
args
[
0
]
==
"-d"
)
{
Task
.
Run
(()
=>
SimulateGazeData
(
300
));
}
else
{
TobiiEyeTracker
tobiiEyeTracker
=
new
TobiiEyeTracker
(
config
.
TrackerSerialNumber
);
tobiiEyeTracker
.
ConnectionEvent
+=
OnConnectionEstablished
;
tobiiEyeTracker
.
ConnectionTimeout
+=
OnConnectionTimeout
;
tobiiEyeTracker
.
GazeDataAvailable
+=
OnGazeDataAvailable
;
tobiiEyeTracker
.
Connect
();
}
gazeServer
=
new
GazeServer
(
config
.
WebSocketPort
,
config
.
WebSocketEndpoint
);
gazeServer
.
Start
();
Console
.
ReadLine
();
}
private
static
void
SimulateGazeData
(
UInt16
frequencyHz
)
{
TimeSpan
period
=
new
TimeSpan
(
Convert
.
ToInt64
((
1.0
/
frequencyHz
)
*
10
e7
));
while
(
true
)
{
DateTime
start
=
DateTime
.
Now
;
Point
mousePosition
=
Control
.
MousePosition
;
GazeData
data
=
new
GazeData
(
mousePosition
.
X
,
mousePosition
.
Y
,
mousePosition
.
X
,
mousePosition
.
Y
,
0
,
0
);
if
(
gazeServer
!=
null
&&
gazeServer
.
isRunning
)
{
gazeServer
.
Publish
(
data
);
}
TimeSpan
delay
=
period
-
(
DateTime
.
Now
-
start
);
Thread
.
Sleep
(
delay
.
Ticks
>=
0
?
delay
.
Milliseconds
:
0
);
}
}
private
static
void
OnGazeDataAvailable
(
TobiiEyeTracker
sender
,
GazeData
data
)
{
Console
.
WriteLine
(
data
);
if
(
gazeServer
!=
null
&&
gazeServer
.
isRunning
)
{
gazeServer
.
Publish
(
data
);
}
}
private
static
void
OnConnectionTimeout
(
TobiiEyeTracker
sender
)
{
...
...
TrackerBridge/GazeDataProcessor.cs
View file @
27926ae6
...
...
@@ -21,10 +21,10 @@ namespace TrackerBridge
public
GazeData
Extract
(
GazeDataEventArgs
e
)
{
GazeData
data
=
new
GazeData
(
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
X
*
screenWidth
,
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
*
screenHeight
,
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
X
*
screenWidth
,
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
*
screenHeight
,
GazeData
data
=
new
GazeData
(
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
X
*
screenWidth
,
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
*
screenHeight
,
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
X
*
screenWidth
,
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
*
screenHeight
,
e
.
DeviceTimeStamp
,
e
.
SystemTimeStamp
);
return
data
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment