Added logic in ocr for capture

This commit is contained in:
dhanabalan
2025-10-27 11:07:52 +05:30
parent d22b060ec8
commit cf01272419

View File

@@ -822,11 +822,11 @@ function cameraCapture() {
// this.stopDetection(); // this.stopDetection();
// }, // },
async capturePhoto() { async capturePhoto() {
const video = this.$refs.video; const video = this.$refs.video;
const canvas = this.$refs.canvas; const canvas = this.$refs.canvas;
const overlay = this.$refs.overlay;
const snapshot = this.$refs.snapshot; const snapshot = this.$refs.snapshot;
const overlay = this.$refs.overlay;
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
canvas.width = video.videoWidth; canvas.width = video.videoWidth;
@@ -837,17 +837,22 @@ function cameraCapture() {
this.$refs.hiddenInput.value = snapshotData; this.$refs.hiddenInput.value = snapshotData;
this.capturedPhoto = snapshotData; this.capturedPhoto = snapshotData;
// ✅ Hide live video immediately → prevents black frame // ✅ Hide video and overlays immediately
video.classList.add('hidden'); video.classList.add('hidden');
overlay.classList.add('hidden'); overlay.classList.add('hidden');
// Stop camera stream after hide // ✅ Set snapshot image and display in same place
if (this.stream) this.stream.getTracks().forEach(track => track.stop()); snapshot.src = snapshotData;
snapshot.classList.remove('hidden');
// ✅ Stop video stream (after hiding)
if (this.stream) {
this.stream.getTracks().forEach(track => track.stop());
}
this.stopDetection();
}
snapshot.src = snapshotData;
snapshot.classList.remove('hidden');
this.stopDetection();
},
async verifyPhoto() { async verifyPhoto() {