diff --git a/.gitignore b/.gitignore index 499bd98..61ced85 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ pnpm-debug.log* *.njsproj *.sln *.sw? + +# Firebase config (local only) +src/firebase.js diff --git a/src/App.vue b/src/App.vue index 23c43a1..fff870f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -12,3 +12,24 @@ export default { name: 'App', }; + + diff --git a/src/main.js b/src/main.js index 219cc2f..b22b838 100644 --- a/src/main.js +++ b/src/main.js @@ -2,18 +2,15 @@ import Vue from 'vue' import App from './App.vue' import router from './router' import store from './store' -import vuetify from './plugins/vuetify'; +import vuetify from './plugins/vuetify' import './services/axios' import firebase from 'firebase/app' import 'firebase/firestore' import { envConfig } from './config/environment' -Vue.config.productionTip = false - const firebaseConfig = envConfig.firebase; -// Initialize Firebase -firebase.initializeApp(firebaseConfig); +Vue.config.productionTip = false new Vue({ router, diff --git a/src/store/calibration.js b/src/store/calibration.js index beb8026..c7504ae 100644 --- a/src/store/calibration.js +++ b/src/store/calibration.js @@ -1,7 +1,13 @@ +<<<<<<< HEAD import axios from 'axios'; import firebase from 'firebase/app'; import 'firebase/firestore'; import router from '@/router'; +======= +import axios from "axios"; +import firebase from "@/firebase"; +import router from "@/router"; +>>>>>>> 2b1bb29 (feat(calibration): fullscreen mode and camera preview fix) export default { state: { calibName: "", @@ -23,6 +29,9 @@ export default { threshold: 200, calibrations: [], fromDashboard: false, + // New single-point calibration features + calibrationMode: 'multi-point', // 'multi-point' | 'single-point' + singlePointPosition: null, // Will be calculated as screen center runtime: { circleIrisPoints: [], calibPredictionPoints: [], @@ -119,6 +128,22 @@ export default { setFromDashboard(state, newFromDashboard) { state.fromDashboard = newFromDashboard; }, + + // New single-point calibration mutations + setCalibrationMode(state, mode) { + state.calibrationMode = mode; + // If switching to single-point, set pointNumber to 1 + if (mode === 'single-point') { + state.pointNumber = 1; + } else { + state.pointNumber = 9; // Default multi-point + } + }, + + setSinglePointPosition(state, position) { + state.singlePointPosition = position; + }, + setRuntimeData(state, payload) { state.runtime.circleIrisPoints = payload.circleIrisPoints; state.runtime.calibPredictionPoints = payload.calibPredictionPoints; @@ -155,6 +180,9 @@ export default { state.threshold = 200; state.calibrations = []; state.fromDashboard = false; + // Reset single-point calibration properties + state.calibrationMode = 'multi-point'; + state.singlePointPosition = null; }, }, actions: { @@ -180,20 +208,29 @@ export default { return positions; }, - async saveCalib(context) { - const state = context.state; - const db = firebase.firestore(); - const calibrationData = { ...state }; - delete calibrationData.calibrations; - try { - const calibrationsCollection = db.collection("calibrations"); - await calibrationsCollection.add(calibrationData); - console.log("Data successfully saved to calibrations collection!"); - context.dispatch("getAllCalibs"); - } catch (error) { - console.error("Error saving data to calibrations collection:", error); - } - }, + + // Generate single-point calibration pattern (center of screen) + generateSinglePointPattern({ commit }, { width, height }) { + const centerPoint = { + x: width / 2, + y: height / 2, + }; + + commit('setSinglePointPosition', centerPoint); + return [centerPoint]; + }, + async saveCalib({ state, dispatch }) { + try { + const data = { ...state }; + delete data.calibrations; + + await firebase.firestore().collection("calibrations").add(data); + dispatch("getAllCalibs"); + } catch (e) { + console.error("Save failed:", e); + } + }, + async finishCalibration({ state, dispatch }) { console.log("[Calibration] finishCalibration started"); @@ -250,48 +287,63 @@ export default { commit("setMsPerCapture", calibData.msPerCapture); router.push("/postCalibration"); }, - async getAllCalibs({ commit }) { - try { - const db = firebase.firestore(); - const calibrationsCollection = await db - .collection("calibrations") - .get(); + async getAllCalibs({ commit }) { + try { + const snapshot = await firebase + .firestore() + .collection("calibrations") + .get(); - const calibrations = []; - calibrationsCollection.forEach((doc) => { - var averageAccuracy = 0; - var averagePrecision = 0; - var data = doc.data(); - data.pattern.forEach((element) => { - averageAccuracy += Number(element.accuracy); - averagePrecision += Number(element.precision); - }); - data.averageAccuracy = averageAccuracy / data.pattern.length; - data.averagePrecision = averagePrecision / data.pattern.length; - calibrations.push({ - id: doc.id, - model: doc.data().models, - ...data, - }); - }); + const calibrations = []; - commit("setCalibrations", calibrations); - } catch (error) { - console.error("Error getting calibrations:", error); - throw error; - } - }, - async deleteCalib({ dispatch }, calib) { - try { - const db = firebase.firestore(); - const calibrationsCollection = db.collection("calibrations"); - await calibrationsCollection.doc(calib.id).delete(); - dispatch("getAllCalibs"); - } catch (error) { - console.error("Error deleting calibration:", error); - return { success: false, message: "Failed to delete calibration" }; + snapshot.forEach((doc) => { + const data = doc.data(); + + let averageAccuracy = 0; + let averagePrecision = 0; + + if (data.runtime?.usedPattern?.length) { + const total = data.runtime.usedPattern.length; + + averageAccuracy = + data.runtime.usedPattern.reduce( + (sum, p) => sum + Number(p.accuracy || 0), + 0 + ) / total; + + averagePrecision = + data.runtime.usedPattern.reduce( + (sum, p) => sum + Number(p.precision || 0), + 0 + ) / total; } - }, + + calibrations.push({ + id: doc.id, + ...data, + averageAccuracy: Number(averageAccuracy.toFixed(2)), + averagePrecision: Number(averagePrecision.toFixed(2)), + }); + }); + + commit("setCalibrations", calibrations); + } catch (err) { + console.error("Error getting calibrations:", err); + } + }, + async deleteCalib({ dispatch }, calib) { + try { + await firebase + .firestore() + .collection("calibrations") + .doc(calib.id) + .delete(); + + dispatch("getAllCalibs"); + } catch (e) { + console.error("Delete failed:", e); + } + }, async sendData(context, data) { let formData = new FormData(); diff --git a/src/views/CameraConfiguration.vue b/src/views/CameraConfiguration.vue index bd395db..73c38c0 100644 --- a/src/views/CameraConfiguration.vue +++ b/src/views/CameraConfiguration.vue @@ -1,4 +1,5 @@