diff --git a/src/components/calibration/ConfigModal.vue b/src/components/calibration/ConfigModal.vue new file mode 100644 index 0000000..bdd5a5c --- /dev/null +++ b/src/components/calibration/ConfigModal.vue @@ -0,0 +1,60 @@ + + + + \ No newline at end of file diff --git a/src/components/calibration/GeneralConfigCard.vue b/src/components/calibration/GeneralConfigCard.vue index 630b884..1ab3a29 100644 --- a/src/components/calibration/GeneralConfigCard.vue +++ b/src/components/calibration/GeneralConfigCard.vue @@ -10,10 +10,10 @@
- -
diff --git a/src/components/calibration/Offset.vue b/src/components/calibration/Offset.vue index f567ad3..671a85b 100644 --- a/src/components/calibration/Offset.vue +++ b/src/components/calibration/Offset.vue @@ -64,16 +64,13 @@ export default { generatePoints(offsetX, offsetY, width, height, pointNum) { const possiblePatterns = [ [ - { x: width / 2, y: height / 2 } - ], - [ - { x: offsetX, y: height / 2 }, - { x: width - offsetX, y: height / 2 } + { x: offsetX, y: height - offsetY }, + { x: width - offsetX, y: offsetY }, ], [ - { x: offsetX, y: height / 2 }, - { x: width / 2, y: offsetY }, - { x: width - offsetX, y: height / 2 } + { x: offsetX, y: height - offsetY }, + { x: width / 2, y: height / 2 }, + { x: width - offsetX, y: offsetY }, ], [ { x: offsetX, y: offsetY }, diff --git a/src/components/calibration/PointModal.vue b/src/components/calibration/PointModal.vue new file mode 100644 index 0000000..4ad399b --- /dev/null +++ b/src/components/calibration/PointModal.vue @@ -0,0 +1,96 @@ + + + + \ No newline at end of file diff --git a/src/components/general/DraggableFloatingButton.vue b/src/components/general/DraggableFloatingButton.vue new file mode 100644 index 0000000..79f1079 --- /dev/null +++ b/src/components/general/DraggableFloatingButton.vue @@ -0,0 +1,81 @@ + + + + + + \ No newline at end of file diff --git a/src/store/calibration.js b/src/store/calibration.js index ea60b34..bda1db4 100644 --- a/src/store/calibration.js +++ b/src/store/calibration.js @@ -3,7 +3,7 @@ export default { state: { calibName: '', pointNumber: 5, - samplePerPoint: 10, + samplePerPoint: 20, radius: 20, offset: 50, backgroundColor: '#FFFFFFFF', @@ -13,7 +13,9 @@ export default { leftEyeTreshold: 5, rightEyeTreshold: 5, index: 0, - msPerCapture: 10, + msPerCapture: 50, + pattern: [], + mockPattern: [] }, mutations: { setCalibName(state, newCalibName) { @@ -34,6 +36,17 @@ export default { setPattern(state, newPattern) { state.pattern = newPattern; }, + setMockPatternElement(state, newPatternLike) { + if (!state.mockPattern.includes(newPatternLike)) { + state.mockPattern.push(newPatternLike) + } else { + const index = state.mockPattern.indexOf(newPatternLike); + state.mockPattern.splice(index, 1); + } + }, + setMockPattern(state, newMockPattern) { + state.mockPattern = newMockPattern + }, setBackgroundColor(state, newBackgroundColor) { state.backgroundColor = newBackgroundColor }, @@ -55,7 +68,7 @@ export default { setIndex(state, newIndex) { state.index = newIndex }, - setMsPerCapture(state, newMsPerCapture){ + setMsPerCapture(state, newMsPerCapture) { state.msPerCapture = newMsPerCapture } }, @@ -85,7 +98,8 @@ export default { "Content-Type": "multipart/form-data", }, }); - console.log(res); + return res.data + // console.log(res); } } } \ No newline at end of file diff --git a/src/views/CalibrationConfig.vue b/src/views/CalibrationConfig.vue index 999e5b1..b3919f4 100644 --- a/src/views/CalibrationConfig.vue +++ b/src/views/CalibrationConfig.vue @@ -12,12 +12,13 @@ - +
@@ -25,12 +26,15 @@ import Toolbar from "@/components/general/Toolbar.vue"; import GeneralConfigCard from "@/components/calibration/GeneralConfigCard.vue"; import MiscConfigCard from "@/components/calibration/MiscConfigCard.vue"; +import DraggableFloatingButton from '@/components/general/DraggableFloatingButton.vue'; + export default { components: { Toolbar, GeneralConfigCard, MiscConfigCard, + DraggableFloatingButton }, methods: { changePage() { diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 32a1579..db73646 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -8,25 +8,34 @@ - + + diff --git a/src/views/DoubleCalibrationRecord.vue b/src/views/DoubleCalibrationRecord.vue index 554f973..3f6fd13 100644 --- a/src/views/DoubleCalibrationRecord.vue +++ b/src/views/DoubleCalibrationRecord.vue @@ -10,21 +10,21 @@
+ style="z-index: 1;position: absolute; top: 35%; left: 50%; transform: translate(-50%, -50%);"> slowly press 'S' while looking at the point to begin
-
press 'S' one +
press 'S' one more time
-
+
+ style="position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);">
you've collected {{ circleIrisPoints.length }} train points
Next Step
-
+
you've collected {{ calibPredictionPoints.length }} validation points
@@ -61,6 +61,7 @@ export default { animationRefreshRate: 10, animationFrames: 250, innerCircleRadius: 5, + usedPattern: [], }; }, computed: { @@ -76,6 +77,9 @@ export default { pattern() { return this.$store.state.calibration.pattern }, + mockPattern() { + return this.$store.state.calibration.mockPattern + }, backgroundColor() { return this.$store.state.calibration.backgroundColor }, @@ -104,10 +108,14 @@ export default { return this.$store.state.calibration.isControlled }, }, + created() { + this.$store.commit('setIndex', 0) + this.usedPattern = (this.mockPattern.length > 0) ? this.mockPattern : this.pattern + }, async mounted() { await this.startWebCamCapture(); - this.drawPoint(this.pattern[0].x, this.pattern[0].y, 1) - this.advance(this.pattern, this.circleIrisPoints, this.msPerCapture) + this.drawPoint(this.usedPattern[0].x, this.usedPattern[0].y, 1) + this.advance(this.usedPattern, this.circleIrisPoints, this.msPerCapture) }, methods: { advance(pattern, whereToSave, timeBetweenCaptures) { @@ -118,6 +126,7 @@ export default { if (i <= pattern.length - 1) { document.removeEventListener('keydown', keydownHandler) await th.extract(pattern[i], timeBetweenCaptures) + th.$store.commit('setIndex', i) i++ if (i != pattern.length) { @@ -127,7 +136,7 @@ export default { } else { th.$store.commit('setIndex', i) document.removeEventListener('keydown', keydownHandler) - th.savePoint(whereToSave, th.pattern) + th.savePoint(whereToSave, th.usedPattern) const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); ctx.clearRect(0, 0, canvas.width, canvas.height) @@ -137,13 +146,13 @@ export default { document.addEventListener('keydown', keydownHandler) }, nextStep() { - this.pattern.forEach(element => { + this.usedPattern.forEach(element => { delete element.data; }); this.$store.commit('setIndex', 0) this.currentStep = 2 - this.drawPoint(this.pattern[0].x, this.pattern[0].y, 1) - this.advance(this.pattern, this.calibPredictionPoints, this.msPerCapture) + this.drawPoint(this.usedPattern[0].x, this.usedPattern[0].y, 1) + this.advance(this.usedPattern, this.calibPredictionPoints, this.msPerCapture) }, async extract(point, timeBetweenCaptures) { point.data = []; @@ -170,7 +179,6 @@ export default { } else { const newPrediction = { leftIris: leftIris[0], rightIris: rightIris[0] }; point.data.push(newPrediction); - console.log(point.data.length); const radius = (this.radius / this.predByPointCount) * a this.drawPoint(point.x, point.y, radius) a++; @@ -251,11 +259,29 @@ export default { }) const screenHeight = window.screen.height; const screenWidth = window.screen.width; - await this.$store.dispatch('sendData', { circleIrisPoints: this.circleIrisPoints, calibPredictionPoints: this.calibPredictionPoints, screenHeight: screenHeight, screenWidth: screenWidth }) + var predictions = + await this.$store.dispatch('sendData', { circleIrisPoints: this.circleIrisPoints, calibPredictionPoints: this.calibPredictionPoints, screenHeight: screenHeight, screenWidth: screenWidth }) + + if (typeof predictions === 'string') { + predictions = predictions.replace(/NaN/g, '1'); + try { + predictions = JSON.parse(predictions); + } catch (error) { + console.error('Error parsing predictions string:', error); + } + } + for (var a = 0; a < this.usedPattern.length; a++) { + const element = predictions[this.usedPattern[a].x.toString().split('.')[0]][this.usedPattern[a].y.toString().split('.')[0]] + this.usedPattern[a].precision = element.PrecisionSD.toFixed(2) + this.usedPattern[a].accuracy = element.Accuracy.toFixed(2) + this.usedPattern[a].predictionX = element.predicted_x + this.usedPattern[a].predictionY = element.predicted_y + } this.$store.dispatch('extractXYValues', { extract: this.circleIrisPoints, hasCalib: true }) this.$store.dispatch('extractXYValues', { extract: this.calibPredictionPoints, hasCalib: false }) this.stopRecord() - this.$router.push('/dashboard'); + this.$store.commit('setMockPattern', []) + this.$router.push('/postCalibration'); }, savePoint(whereToSave, patternLike) { patternLike.forEach(point => { diff --git a/src/views/PostCalibration.vue b/src/views/PostCalibration.vue index f9916f1..dd59dc5 100644 --- a/src/views/PostCalibration.vue +++ b/src/views/PostCalibration.vue @@ -1,101 +1,186 @@