Skip to content

Commit beee0d2

Browse files
committed
Replace IDT algorithm with new version - not tested yet
1 parent 01574a2 commit beee0d2

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

idtalgorithm.cpp

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,68 @@ QVector<Fixation> IDTAlgorithm::generateFixations() {
3232

3333
//This code follows the IDT Algorithm
3434

35-
//Step 1 should already be done
36-
37-
//Step 2 - Calculate velocity between each point and generate Fixations
38-
QVector<Gaze> window;
39-
int i = 0;
40-
41-
while(i < duration_window && i < session_gazes.size()) {
42-
window.push_back(session_gazes[i]);
43-
++i;
44-
}
45-
46-
while(i < session_gazes.size()) {
47-
if((computeGazeDifference(window) <= dispersion) && (window.size() >= duration_window)) {
48-
while(computeGazeDifference(window) <= dispersion) {
49-
if(i < session_gazes.size() - 1) {
50-
window.push_back(session_gazes[i]);
51-
++i;
52-
}
53-
else { break; }
54-
}
55-
fixations.push_back(computeFixationEstimate(window));
56-
window.clear();
57-
window.push_back(session_gazes[i]);
58-
++i;
59-
}
60-
else if(window.size() < duration_window) {
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) {
6141
window.push_back(session_gazes[i]);
6242
++i;
6343
}
64-
else {
65-
window.pop_front();
66-
if(window.size() < duration_window) {
44+
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()) {
6749
window.push_back(session_gazes[i]);
6850
++i;
6951
}
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();
57+
}
58+
}
59+
else {
60+
session_gazes.pop_front();
7061
}
7162
}
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+
// }
7297

7398
return fixations;
7499
}

0 commit comments

Comments
 (0)