@@ -22,78 +22,67 @@ 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
47+ QVector<Gaze> window;
48+ int i = 0 ;
3449
35- // QVector<Gaze> window;
36- while (session_gazes.size () != 0 ) { // While there are still points
37- // Initialize the window over the first points to not cover the duration threshold
38- QVector<Gaze> window;
39- int i = 0 ;
40- while (window.size () != duration_window && session_gazes.size () != 0 ) {
41- window.push_back (session_gazes[i]);
42- ++i;
43- }
50+ while (getLengthOfWindow (window) < duration_window && i < session_gazes.size ()) {
51+ window.push_back (session_gazes[i]);
52+ ++i;
53+ }
4454
45- // If dispersion of window points <= threshold
46- if (computeGazeDifference (window) <= dispersion) {
47- // Add additional points to the window until dispersion > threshold
48- while (computeGazeDifference (window) <= dispersion && i < session_gazes.size ()) {
55+ while (i < session_gazes.size ()) {
56+ if ((computeGazeDifference (window) <= dispersion) && (getLengthOfWindow (window) >= duration_window)) {
57+ while (computeGazeDifference (window) <= dispersion) {
58+ if (i < session_gazes.size () - 1 ) {
59+ window.push_back (session_gazes[i]);
60+ ++i;
61+ }
62+ else { break ; }
63+ }
64+ if (isWindowConsistenlySpaced (window,max_gaze_span)) {
65+ fixations.push_back (computeFixationEstimate (window));
66+ window.clear ();
4967 window.push_back (session_gazes[i]);
5068 ++i;
5169 }
52- // Not a fixation ant the centroid of the windows points
53- fixations.push_back (computeFixationEstimate (window));
54- // Remove window points from points
55- for (int x = 0 ; x < window.size (); ++x) {
56- session_gazes.pop_front ();
70+ else {
71+ window.pop_front ();
5772 }
5873 }
74+ else if (getLengthOfWindow (window) < duration_window) {
75+ window.push_back (session_gazes[i]);
76+ ++i;
77+ }
5978 else {
60- session_gazes.pop_front ();
79+ window.pop_front ();
80+ if (getLengthOfWindow (window) < duration_window) {
81+ window.push_back (session_gazes[i]);
82+ ++i;
83+ }
6184 }
6285 }
63- // QVector<Gaze> window;
64- // int i = 0;
65-
66- // while(i < duration_window && i < session_gazes.size()) {
67- // window.push_back(session_gazes[i]);
68- // ++i;
69- // }
70-
71- // while(i < session_gazes.size()) {
72- // if((computeGazeDifference(window) <= dispersion) && (window.size() >= duration_window)) {
73- // while(computeGazeDifference(window) <= dispersion) {
74- // if(i < session_gazes.size() - 1) {
75- // window.push_back(session_gazes[i]);
76- // ++i;
77- // }
78- // else { break; }
79- // }
80- // fixations.push_back(computeFixationEstimate(window));
81- // window.clear();
82- // window.push_back(session_gazes[i]);
83- // ++i;
84- // }
85- // else if(window.size() < duration_window) {
86- // window.push_back(session_gazes[i]);
87- // ++i;
88- // }
89- // else {
90- // window.pop_front();
91- // if(window.size() < duration_window) {
92- // window.push_back(session_gazes[i]);
93- // ++i;
94- // }
95- // }
96- // }
9786
9887 return fixations;
9988}
@@ -113,6 +102,6 @@ Fixation IDTAlgorithm::computeFixationEstimate(QVector<Gaze> fixation_points) {
113102}
114103
115104QString IDTAlgorithm::generateFixationSettings () {
116- return " IDT," + QString::number (dispersion) + " ," + QString::number (duration_window);
105+ return " IDT," + QString::number (dispersion) + " ," + QString::number (duration_window) + " , " + QString::number (max_gaze_span) ;
117106}
118107
0 commit comments