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
87e44eed
authored
Aug 29, 2019
by
Stefan Schreistetter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added filtering to GazeDataProcessor.
parent
4dca5182
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
6 deletions
+120
-6
GazeWebSocketServer/DSP/FIRfilt.cs
+81
-0
GazeWebSocketServer/GazeDataProcessor.cs
+38
-6
GazeWebSocketServer/GazeWebSocketServer.csproj
+1
-0
No files found.
GazeWebSocketServer/DSP/FIRfilt.cs
0 → 100644
View file @
87e44eed
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
GazeWebSocketServer.DSP
{
class
FIRfilt
{
public
Double
[]
Coefficients
{
get
=>
coefficients
;
private
set
{
coefficients
=
value
;
Initialize
();
}
}
public
Boolean
OutputValid
{
get
;
private
set
;
}
public
Double
?
Output
{
get
{
if
(
OutputValid
)
{
return
output
;
}
else
{
return
null
;
}
}
}
private
Double
output
;
private
Double
[]
ringBuffer
;
private
Int64
currentValueIndex
;
private
Double
[]
coefficients
;
public
FIRfilt
(
Double
[]
coefficients
)
{
Coefficients
=
coefficients
;
}
public
static
FIRfilt
[]
createFilterArray
(
Double
[]
coefficients
,
Int64
numberOfFilters
)
{
FIRfilt
[]
firFilts
=
new
FIRfilt
[
numberOfFilters
];
for
(
Int64
index
=
0
;
index
<
firFilts
.
Length
;
index
++)
{
firFilts
[
index
]
=
new
FIRfilt
(
coefficients
);
}
return
firFilts
;
}
private
void
Initialize
()
{
ringBuffer
=
new
Double
[
Coefficients
.
Length
];
for
(
Int64
index
=
0
;
index
<
ringBuffer
.
Length
;
index
++)
{
ringBuffer
[
index
]
=
0.0
;
}
currentValueIndex
=
0
;
output
=
0.0
;
OutputValid
=
false
;
}
public
void
Input
(
Double
input
)
{
ringBuffer
[
currentValueIndex
]
=
input
;
output
=
0.0
;
for
(
Int64
index
=
0
;
index
<
ringBuffer
.
Length
;
index
++)
//parallelizable
{
output
+=
ringBuffer
[(
currentValueIndex
+
index
)
%
Coefficients
.
Length
]
*
Coefficients
[
index
];
}
currentValueIndex
=
(
currentValueIndex
+
1
)
%
Coefficients
.
Length
;
if
(!
OutputValid
&&
currentValueIndex
==
0
)
{
OutputValid
=
true
;
}
}
}
}
GazeWebSocketServer/GazeDataProcessor.cs
View file @
87e44eed
...
@@ -5,26 +5,58 @@ using System.Linq;
...
@@ -5,26 +5,58 @@ using System.Linq;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Tobii.Research
;
using
Tobii.Research
;
using
GazeWebSocketServer.DSP
;
namespace
GazeWebSocketServer
namespace
GazeWebSocketServer
{
{
class
GazeDataProcessor
class
GazeDataProcessor
{
{
readonly
float
screenHeight
;
private
readonly
Double
screenHeight
;
readonly
float
screenWidth
;
private
readonly
Double
screenWidth
;
private
FIRfilt
filtLeftEyeX
;
private
FIRfilt
filtLeftEyeY
;
private
FIRfilt
filtRightEyeX
;
private
FIRfilt
filtRightEyeY
;
public
GazeDataProcessor
()
public
GazeDataProcessor
()
{
{
screenHeight
=
Convert
.
ToSingle
(
SystemParameters
.
PrimaryScreenHeight
);
screenHeight
=
Convert
.
ToSingle
(
SystemParameters
.
PrimaryScreenHeight
);
screenWidth
=
Convert
.
ToSingle
(
SystemParameters
.
PrimaryScreenWidth
);
screenWidth
=
Convert
.
ToSingle
(
SystemParameters
.
PrimaryScreenWidth
);
FIRfilt
[]
filters
=
FIRfilt
.
createFilterArray
(
new
Double
[]
{
0.00490811980494201
,
0.00394529962944205
,
-
0.00964707695734475
,
-
0.0111481165779560
,
-
0.00440433399899739
,
-
0.0148433230170450
,
-
0.000941679361561877
,
0.0373490622242201
,
0.0175330755932427
,
-
0.00111444062672272
,
0.0512529971125828
,
0.0232019172099006
,
-
0.0659097689575874
,
-
0.0163424387855043
,
-
0.0336732269089631
,
-
0.238683101182416
,
-
0.108915205128799
,
0.367003181497664
,
0.367003181497664
,
-
0.108915205128799
,
-
0.238683101182416
,
-
0.0336732269089631
,
-
0.0163424387855043
,
-
0.0659097689575874
,
0.0232019172099006
,
0.0512529971125828
,
-
0.00111444062672272
,
0.0175330755932427
,
0.0373490622242201
,
-
0.000941679361561877
,
-
0.0148433230170450
,
-
0.00440433399899739
,
-
0.0111481165779560
,
-
0.00964707695734475
,
0.00394529962944205
,
0.00490811980494201
},
4
);
filtLeftEyeX
=
filters
[
0
];
filtLeftEyeY
=
filters
[
1
];
filtRightEyeX
=
filters
[
2
];
filtRightEyeY
=
filters
[
3
];
}
}
public
GazeData
Extract
(
GazeDataEventArgs
e
)
public
GazeData
Extract
(
GazeDataEventArgs
e
)
{
{
GazeData
data
=
new
GazeData
(
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
X
*
screenWidth
,
if
(
e
.
LeftEye
.
GazePoint
.
Validity
==
Validity
.
Valid
)
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
*
screenHeight
,
{
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
X
*
screenWidth
,
filtLeftEyeX
.
Input
(
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
X
);
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
*
screenHeight
,
filtLeftEyeY
.
Input
(
e
.
LeftEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
);
}
if
(
e
.
RightEye
.
GazePoint
.
Validity
==
Validity
.
Valid
)
{
filtRightEyeX
.
Input
(
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
X
);
filtRightEyeY
.
Input
(
e
.
RightEye
.
GazePoint
.
PositionOnDisplayArea
.
Y
);
}
GazeData
data
=
new
GazeData
(
filtLeftEyeX
.
Output
.
HasValue
?
Convert
.
ToSingle
(
filtLeftEyeX
.
Output
*
screenWidth
)
:
Single
.
NaN
,
filtLeftEyeY
.
Output
.
HasValue
?
Convert
.
ToSingle
(
filtLeftEyeY
.
Output
*
screenHeight
)
:
Single
.
NaN
,
filtRightEyeX
.
Output
.
HasValue
?
Convert
.
ToSingle
(
filtRightEyeX
.
Output
*
screenWidth
)
:
Single
.
NaN
,
filtRightEyeY
.
Output
.
HasValue
?
Convert
.
ToSingle
(
filtRightEyeY
.
Output
*
screenHeight
)
:
Single
.
NaN
,
e
.
DeviceTimeStamp
,
e
.
DeviceTimeStamp
,
e
.
SystemTimeStamp
);
e
.
SystemTimeStamp
);
return
data
;
return
data
;
...
...
GazeWebSocketServer/GazeWebSocketServer.csproj
View file @
87e44eed
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="ConfigurationData.cs" />
<Compile Include="ConfigurationData.cs" />
<Compile Include="DSP\FIRfilt.cs" />
<Compile Include="EyeTrackerClient.cs" />
<Compile Include="EyeTrackerClient.cs" />
<Compile Include="GazeCoordinateBehavior.cs" />
<Compile Include="GazeCoordinateBehavior.cs" />
<Compile Include="GazeData.cs" />
<Compile Include="GazeData.cs" />
...
...
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