Skip to content

Commit ca752a1

Browse files
authored
Merge pull request #101 from Nirvanjha2004/removed-the-hardcoded-value
Removed the hardcoded value and set it to dynamically take it from ruxailab
2 parents 875d472 + 3b904c9 commit ca752a1

File tree

3 files changed

+122
-4
lines changed

3 files changed

+122
-4
lines changed

src/components/calibration/GeneralConfigCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<p class="help-text">Give your calibration a unique identifier</p>
1212
</div>
1313
<div class="custom-outline">
14-
<Slider :value="pointNumber" :min="Number(8)" :max="Number(8)" label="Calibration Points"
14+
<Slider :value="pointNumber" :min="Number(2)" :max="Number(9)" label="Calibration Points"
1515
@input="updatePointNumber" />
16-
<p class="help-text">Number of points to calibrate (9 points recommended)</p>
16+
<p class="help-text">Number of points to calibrate (4-9 points recommended)</p>
1717

1818
<Slider :value="samplePerPoint" :min="Number(90)" :max="Number(90)" label="Samples Per Point" @input="updateSamplePerPoint" />
1919
<p class="help-text">More samples = better accuracy but longer calibration</p>

src/store/calibration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import router from "@/router";
44
export default {
55
state: {
66
calibName: "",
7-
pointNumber: 8,
7+
pointNumber: 9,
88
samplePerPoint: 90,
99
radius: 20,
1010
offset: 100,
@@ -134,7 +134,7 @@ export default {
134134
},
135135
resetAll(state) {
136136
state.calibName = "";
137-
state.pointNumber = 8;
137+
state.pointNumber = 9;
138138
state.samplePerPoint = 90;
139139
state.radius = 20;
140140
state.offset = 100;

src/views/DoubleCalibrationRecord.vue

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,18 @@ export default {
292292
this.$store.commit('setIndex', 0)
293293
this.usedPattern = this.generateRuntimePattern()
294294
295+
if (this.usedPattern.length === 0) {
296+
const width = window.innerWidth
297+
const height = window.innerHeight
298+
const offset = this.offset || 100
299+
const pointCount = this.$store.state.calibration.pointNumber
300+
301+
const generatedPattern = this.generateCalibrationPattern(pointCount, width, height, offset)
302+
303+
this.$store.commit('setMockPattern', generatedPattern)
304+
this.usedPattern = generatedPattern
305+
306+
}
295307
await this.startWebCamCapture();
296308
console.log("chamou drawPoint no created com os valores:", this.usedPattern[0].x, this.usedPattern[0].y);
297309
this.drawPoint(this.usedPattern[0].x, this.usedPattern[0].y, 1)
@@ -300,6 +312,108 @@ export default {
300312
301313
},
302314
methods: {
315+
generateCalibrationPattern(pointCount, width, height, offset) {
316+
const patterns = [];
317+
318+
switch(pointCount) {
319+
case 1:
320+
// Center point only
321+
patterns.push({ x: width/2, y: height/2 });
322+
break;
323+
324+
case 2:
325+
// Left and right edges (horizontal coverage)
326+
patterns.push({ x: offset, y: height/2 });
327+
patterns.push({ x: width - offset, y: height/2 });
328+
break;
329+
330+
case 3:
331+
// Horizontal line: left, center, right
332+
patterns.push({ x: offset, y: height/2 });
333+
patterns.push({ x: width/2, y: height/2 });
334+
patterns.push({ x: width - offset, y: height/2 });
335+
break;
336+
337+
case 4:
338+
// Four corners (optimal for 4-point calibration)
339+
patterns.push({ x: offset, y: offset });
340+
patterns.push({ x: width - offset, y: offset });
341+
patterns.push({ x: offset, y: height - offset });
342+
patterns.push({ x: width - offset, y: height - offset });
343+
break;
344+
345+
case 5:
346+
// Four corners + center (cross pattern)
347+
patterns.push({ x: offset, y: offset });
348+
patterns.push({ x: width - offset, y: offset });
349+
patterns.push({ x: width/2, y: height/2 });
350+
patterns.push({ x: offset, y: height - offset });
351+
patterns.push({ x: width - offset, y: height - offset });
352+
break;
353+
354+
case 6: {
355+
// 3x2 rectangle pattern
356+
const stepX6 = (width - 2 * offset) / 2;
357+
const stepY6 = (height - 2 * offset) / 1;
358+
for (let i = 0; i < 2; i++) {
359+
for (let j = 0; j < 3; j++) {
360+
patterns.push({
361+
x: offset + j * stepX6,
362+
y: offset + i * stepY6,
363+
});
364+
}
365+
}
366+
break;
367+
}
368+
369+
case 7:
370+
// Partial 3x3 grid (strategic selection)
371+
patterns.push({ x: offset, y: offset });
372+
patterns.push({ x: width/2, y: offset });
373+
patterns.push({ x: width - offset, y: offset });
374+
patterns.push({ x: offset, y: height/2 });
375+
patterns.push({ x: width - offset, y: height/2 });
376+
patterns.push({ x: offset, y: height - offset });
377+
patterns.push({ x: width - offset, y: height - offset });
378+
break;
379+
380+
case 8:
381+
// Partial 3x3 grid (without center)
382+
patterns.push({ x: offset, y: offset });
383+
patterns.push({ x: width/2, y: offset });
384+
patterns.push({ x: width - offset, y: offset });
385+
patterns.push({ x: offset, y: height/2 });
386+
patterns.push({ x: width - offset, y: height/2 });
387+
patterns.push({ x: offset, y: height - offset });
388+
patterns.push({ x: width/2, y: height - offset });
389+
patterns.push({ x: width - offset, y: height - offset });
390+
break;
391+
392+
case 9:
393+
default: {
394+
// Full 3x3 grid (current working pattern)
395+
const cols = 3;
396+
const rows = 3;
397+
const usableWidth = width - 2 * offset;
398+
const usableHeight = height - 2 * offset;
399+
const stepX = usableWidth / (cols - 1);
400+
const stepY = usableHeight / (rows - 1);
401+
402+
for (let i = 0; i < rows; i++) {
403+
for (let j = 0; j < cols; j++) {
404+
patterns.push({
405+
x: offset + j * stepX,
406+
y: offset + i * stepY,
407+
});
408+
}
409+
}
410+
break;
411+
}
412+
}
413+
414+
return patterns;
415+
},
416+
303417
startTraining() {
304418
this.showStepper = false;
305419
this.calibrationStarted = true;
@@ -520,6 +634,10 @@ export default {
520634
this.usedPattern[a].predictionX = element.predicted_x
521635
this.usedPattern[a].predictionY = element.predicted_y
522636
}
637+
638+
// Update the store's pattern with the prediction data
639+
this.$store.commit('setPattern', this.usedPattern)
640+
523641
this.$store.dispatch('extractXYValues', { extract: this.circleIrisPoints, hasCalib: true })
524642
this.$store.dispatch('extractXYValues', { extract: this.calibPredictionPoints, hasCalib: false })
525643

0 commit comments

Comments
 (0)