Skip to content

Commit 3b904c9

Browse files
committed
Merge branch 'removed-the-hardcoded-value' of https://github.com/Nirvanjha2004/web-eye-tracker-front into removed-the-hardcoded-value
2 parents 6eed626 + 0b27350 commit 3b904c9

File tree

2 files changed

+280
-269
lines changed

2 files changed

+280
-269
lines changed

src/views/DoubleCalibrationRecord.vue

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,18 @@
5151
<v-card-text class="text-center px-6 py-6">
5252
<v-icon size="50" color="#FF425A" class="mb-4">mdi-eye-settings</v-icon>
5353
<h2 class="text-h4 font-weight-bold mb-4">Eye Tracking Calibration</h2>
54-
54+
5555
<v-alert color="#002D51" dark class="mb-4 text-left">
5656
<div class="text-body-1">
5757
<p class="font-weight-bold mb-2">This calibration consists of two phases:</p>
5858
<ol class="pl-4">
59-
<li class="mb-1"><strong>Training Phase:</strong> The system learns your eye movement patterns</li>
59+
<li class="mb-1"><strong>Training Phase:</strong> The system learns your eye movement patterns
60+
</li>
6061
<li><strong>Validation Phase:</strong> The system verifies the calibration accuracy</li>
6162
</ol>
6263
</div>
6364
</v-alert>
64-
65+
6566
<v-row class="mb-4">
6667
<v-col cols="6">
6768
<v-alert color="#FF425A" dark dense>
@@ -96,14 +97,18 @@
9697
<v-card-text class="text-center px-6 py-6">
9798
<v-icon size="50" color="#FF425A" class="mb-4">mdi-school</v-icon>
9899
<h2 class="text-h4 font-weight-bold mb-4">Training Phase</h2>
99-
100+
100101
<v-card outlined class="pa-4 mb-4 text-left">
101102
<h3 class="text-h6 font-weight-bold mb-3 text-center">Instructions</h3>
102103
<div class="text-body-1">
103-
<p class="mb-2"><v-icon small color="#FF425A">mdi-eye</v-icon> <strong>Look at the red dot</strong> that appears on screen</p>
104-
<p class="mb-2"><v-icon small color="#FF425A">mdi-keyboard</v-icon> <strong>Press S</strong> when ready to record each point</p>
105-
<p class="mb-2"><v-icon small color="#FF425A">mdi-head</v-icon> <strong>Keep your head still</strong> during the entire process</p>
106-
<p class="mb-0"><v-icon small color="#FF425A">mdi-target</v-icon> <strong>Follow the points</strong> with your eyes only</p>
104+
<p class="mb-2"><v-icon small color="#FF425A">mdi-eye</v-icon> <strong>Look at the red
105+
dot</strong> that appears on screen</p>
106+
<p class="mb-2"><v-icon small color="#FF425A">mdi-keyboard</v-icon> <strong>Press S</strong> when
107+
ready to record each point</p>
108+
<p class="mb-2"><v-icon small color="#FF425A">mdi-head</v-icon> <strong>Keep your head
109+
still</strong> during the entire process</p>
110+
<p class="mb-0"><v-icon small color="#FF425A">mdi-target</v-icon> <strong>Follow the
111+
points</strong> with your eyes only</p>
107112
</div>
108113
</v-card>
109114

@@ -130,21 +135,25 @@
130135
<v-card-text class="text-center px-6 py-6">
131136
<v-icon size="50" color="#FF425A" class="mb-4">mdi-check-decagram</v-icon>
132137
<h2 class="text-h4 font-weight-bold mb-4">Validation Phase</h2>
133-
138+
134139
<v-alert color="#FF425A" dark class="mb-4">
135140
<div class="text-center">
136141
<p class="font-weight-bold mb-1">Training Complete!</p>
137142
<p class="mb-0">Successfully collected {{ circleIrisPoints.length }} training samples</p>
138143
</div>
139144
</v-alert>
140-
145+
141146
<v-card outlined class="pa-4 mb-4 text-left">
142147
<h3 class="text-h6 font-weight-bold mb-3 text-center">Validation Instructions</h3>
143148
<div class="text-body-1">
144-
<p class="mb-2"><v-icon small color="#FF425A">mdi-eye</v-icon> <strong>Look at the red dot</strong> that appears on screen</p>
145-
<p class="mb-2"><v-icon small color="#FF425A">mdi-keyboard</v-icon> <strong>Press S</strong> when ready to record each point</p>
146-
<p class="mb-2"><v-icon small color="#FF425A">mdi-head</v-icon> <strong>Keep your head still</strong> during the entire process</p>
147-
<p class="mb-0"><v-icon small color="#FF425A">mdi-target</v-icon> <strong>Follow the points</strong> with your eyes only</p>
149+
<p class="mb-2"><v-icon small color="#FF425A">mdi-eye</v-icon> <strong>Look at the red
150+
dot</strong> that appears on screen</p>
151+
<p class="mb-2"><v-icon small color="#FF425A">mdi-keyboard</v-icon> <strong>Press S</strong> when
152+
ready to record each point</p>
153+
<p class="mb-2"><v-icon small color="#FF425A">mdi-head</v-icon> <strong>Keep your head
154+
still</strong> during the entire process</p>
155+
<p class="mb-0"><v-icon small color="#FF425A">mdi-target</v-icon> <strong>Follow the
156+
points</strong> with your eyes only</p>
148157
</div>
149158
</v-card>
150159

@@ -167,21 +176,21 @@
167176
<v-card-text class="text-center px-6 py-8">
168177
<v-icon size="50" color="#FF425A" class="mb-4">mdi-check-circle</v-icon>
169178
<h2 class="text-h3 font-weight-bold mb-4">Calibration Complete!</h2>
170-
179+
171180
<v-alert color="#FF425A" dark class="mb-3">
172181
<div class="text-center">
173182
<p class="font-weight-bold mb-1">Training: {{ circleIrisPoints.length }} samples collected</p>
174183
<p class="mb-0">Validation: {{ calibPredictionPoints.length }} samples collected</p>
175184
</div>
176185
</v-alert>
177-
186+
178187
<v-alert color="#002D51" dark class="mb-4">
179188
<div class="text-center">
180189
<v-icon left>mdi-check-circle</v-icon>
181190
<span class="font-weight-bold">Your eye tracking calibration was successful!</span>
182191
</div>
183192
</v-alert>
184-
193+
185194
<p class="text-h6 grey--text mb-4">Processing your calibration data...</p>
186195
</v-card-text>
187196
<v-card-actions class="justify-center pb-8">
@@ -246,9 +255,6 @@ export default {
246255
predByPointCount() {
247256
return this.$store.state.calibration.samplePerPoint
248257
},
249-
pattern() {
250-
return this.$store.state.calibration.pattern
251-
},
252258
mockPattern() {
253259
return this.$store.state.calibration.mockPattern
254260
},
@@ -281,9 +287,10 @@ export default {
281287
},
282288
},
283289
async created() {
290+
console.log("rodou created");
284291
await this.verifyFromRuxailab()
285292
this.$store.commit('setIndex', 0)
286-
this.usedPattern = (this.mockPattern.length > 0) ? this.mockPattern : this.pattern
293+
this.usedPattern = this.generateRuntimePattern()
287294
288295
if (this.usedPattern.length === 0) {
289296
const width = window.innerWidth
@@ -298,8 +305,11 @@ export default {
298305
299306
}
300307
await this.startWebCamCapture();
308+
console.log("chamou drawPoint no created com os valores:", this.usedPattern[0].x, this.usedPattern[0].y);
301309
this.drawPoint(this.usedPattern[0].x, this.usedPattern[0].y, 1)
302310
this.advance(this.usedPattern, this.circleIrisPoints, this.msPerCapture)
311+
console.log("UsedPattern inteiro", this.usedPattern);
312+
303313
},
304314
methods: {
305315
generateCalibrationPattern(pointCount, width, height, offset) {
@@ -420,8 +430,8 @@ export default {
420430
if (th.showStepper) {
421431
return;
422432
}
423-
424-
if ((event.key === "s" || event.key === "S")) {
433+
434+
if ((event.key === "s" || event.key === "S" || event.key === "Enter")) {
425435
if (i < pattern.length) {
426436
document.removeEventListener('keydown', keydownHandler)
427437
th.isCollecting = true
@@ -430,7 +440,7 @@ export default {
430440
431441
th.$store.commit('setIndex', i)
432442
i++
433-
443+
434444
if (i < pattern.length) {
435445
await th.triggerAnimation(pattern[i - 1], pattern[i], this.animationRefreshRate)
436446
document.addEventListener('keydown', keydownHandler)
@@ -463,6 +473,9 @@ export default {
463473
this.stepperStep = 3;
464474
this.showStepper = true;
465475
this.calibrationStarted = false;
476+
477+
console.log("nextStep rodou drawPoint com os valores:", this.usedPattern[0].x, this.usedPattern[0].y);
478+
466479
this.drawPoint(this.usedPattern[0].x, this.usedPattern[0].y, 1)
467480
this.advance(this.usedPattern, this.calibPredictionPoints, this.msPerCapture)
468481
},
@@ -543,6 +556,9 @@ export default {
543556
},
544557
drawPoint(x, y, radius) {
545558
const canvas = document.getElementById('canvas');
559+
560+
console.log('Window size:', window.innerWidth, 'x', window.innerHeight);
561+
546562
canvas.width = window.innerWidth;
547563
canvas.height = window.innerHeight
548564
const ctx = canvas.getContext('2d');
@@ -589,8 +605,8 @@ export default {
589605
delete element.point_x;
590606
delete element.point_y;
591607
})
592-
const screenHeight = window.screen.height
593-
const screenWidth = window.screen.width
608+
const screenHeight = window.innerHeight
609+
const screenWidth = window.innerWidth
594610
595611
let predictions = await this.$store.dispatch('sendData', {
596612
fromRuxailab: false,
@@ -599,7 +615,7 @@ export default {
599615
screenHeight,
600616
screenWidth,
601617
k: this.$store.state.calibration.pointNumber,
602-
threshold: this.$store.state.calibration.threshold
618+
threshold: this.$store.state.calibration.threshold
603619
})
604620
605621
if (typeof predictions === 'string') {
@@ -612,6 +628,7 @@ export default {
612628
}
613629
for (var a = 0; a < this.usedPattern.length; a++) {
614630
const element = predictions[this.usedPattern[a].x.toString().split('.')[0]][this.usedPattern[a].y.toString().split('.')[0]]
631+
615632
this.usedPattern[a].precision = element.PrecisionSD.toFixed(2)
616633
this.usedPattern[a].accuracy = element.Accuracy.toFixed(2)
617634
this.usedPattern[a].predictionX = element.predicted_x
@@ -734,6 +751,39 @@ export default {
734751
await this.recordWebCam.stop();
735752
this.calibFinished = true;
736753
},
754+
755+
generateRuntimePattern() {
756+
const width = window.innerWidth
757+
const height = window.innerHeight
758+
const offset = this.offset || 100
759+
const points = this.$store.state.calibration.pointNumber || 9
760+
761+
const minCols = 3
762+
const cols = Math.max(minCols, Math.round(Math.sqrt(points)))
763+
const rows = Math.ceil(points / cols)
764+
765+
766+
const usableWidth = width - 2 * offset
767+
const usableHeight = height - 2 * offset
768+
769+
const stepX = usableWidth / (cols - 1)
770+
const stepY = usableHeight / (rows - 1)
771+
772+
const pattern = []
773+
774+
for (let i = 0; i < rows; i++) {
775+
for (let j = 0; j < cols; j++) {
776+
if (pattern.length < points) {
777+
pattern.push({
778+
x: offset + j * stepX,
779+
y: offset + i * stepY
780+
})
781+
}
782+
}
783+
}
784+
785+
return pattern
786+
}
737787
},
738788
};
739789
</script>
@@ -1027,7 +1077,7 @@ kbd {
10271077
/* Fix dialog centering - without scoped */
10281078
.v-dialog__content {
10291079
width: 100% !important;
1030-
align-items: center !important;
1080+
align-items: center !important;
10311081
justify-content: center !important;
10321082
}
10331083
</style>

0 commit comments

Comments
 (0)