@@ -22,48 +22,62 @@ double computeGazeDifference(QVector<Gaze> gazes) {
2222 double final = (xmax - xmin) + (ymax - ymin);
2323 return final ;
2424}
25+ long long getLengthOfWindow (QVector<Gaze> gazes) {
26+ if (gazes.size () <= 1 ) { return 0 ; }
27+ return gazes[gazes.size () - 1 ].system_time - gazes[0 ].system_time ;
28+ }
29+ bool isWindowConsistenlySpaced (QVector<Gaze> gazes, int maximum_space) {
30+ for (int i = 0 ; i < gazes.size () - 1 ; ++i) {
31+ if (gazes[i+1 ].system_time - gazes[i].system_time > maximum_space) {
32+ return false ;
33+ }
34+ }
35+ return true ;
36+ }
2537
26- IDTAlgorithm::IDTAlgorithm (QVector<Gaze> gazes, int _duration, int _dispersion) : FixationAlgorithm(gazes) {
38+ IDTAlgorithm::IDTAlgorithm (QVector<Gaze> gazes, int _duration, int _dispersion, int _max_gaze_span ) : FixationAlgorithm(gazes) {
2739 duration_window = _duration;
2840 dispersion = _dispersion;
41+ max_gaze_span = _max_gaze_span;
2942}
3043
3144QVector<Fixation> IDTAlgorithm::generateFixations () {
3245
3346 // This code follows the IDT Algorithm
34-
35- // Step 1 should already be done
36-
37- // Step 2 - Calculate velocity between each point and generate Fixations
3847 QVector<Gaze> window;
3948 int i = 0 ;
4049
41- while (i < duration_window && i < session_gazes.size ()) {
50+ while (getLengthOfWindow (window) < duration_window && i < session_gazes.size ()) {
4251 window.push_back (session_gazes[i]);
4352 ++i;
4453 }
4554
4655 while (i < session_gazes.size ()) {
47- if ((computeGazeDifference (window) <= dispersion) && (window. size ( ) >= duration_window)) {
56+ if ((computeGazeDifference (window) <= dispersion) && (getLengthOfWindow (window ) >= duration_window)) {
4857 while (computeGazeDifference (window) <= dispersion) {
4958 if (i < session_gazes.size () - 1 ) {
5059 window.push_back (session_gazes[i]);
5160 ++i;
5261 }
5362 else { break ; }
5463 }
55- fixations.push_back (computeFixationEstimate (window));
56- window.clear ();
57- window.push_back (session_gazes[i]);
58- ++i;
64+ if (isWindowConsistenlySpaced (window,max_gaze_span)) {
65+ fixations.push_back (computeFixationEstimate (window));
66+ window.clear ();
67+ window.push_back (session_gazes[i]);
68+ ++i;
69+ }
70+ else {
71+ window.pop_front ();
72+ }
5973 }
60- else if (window. size ( ) < duration_window) {
74+ else if (getLengthOfWindow (window ) < duration_window) {
6175 window.push_back (session_gazes[i]);
6276 ++i;
6377 }
6478 else {
6579 window.pop_front ();
66- if (window. size ( ) < duration_window) {
80+ if (getLengthOfWindow (window ) < duration_window) {
6781 window.push_back (session_gazes[i]);
6882 ++i;
6983 }
@@ -88,6 +102,6 @@ Fixation IDTAlgorithm::computeFixationEstimate(QVector<Gaze> fixation_points) {
88102}
89103
90104QString IDTAlgorithm::generateFixationSettings () {
91- return " IDT," + QString::number (dispersion) + " ," + QString::number (duration_window);
105+ return " IDT," + QString::number (dispersion) + " ," + QString::number (duration_window) + " , " + QString::number (max_gaze_span) ;
92106}
93107
0 commit comments