changed logic in ocr

This commit is contained in:
dhanabalan
2025-10-27 11:15:07 +05:30
parent cefac4e8f3
commit 2dc70a6a8c

View File

@@ -839,39 +839,31 @@ function cameraCapture() {
// this.stopDetection(); // this.stopDetection();
// }, // },
async capturePhoto() { capturePhoto() {
const video = this.$refs.video; const video = this.$refs.video;
const canvas = this.$refs.canvas; const canvas = this.$refs.canvas;
const snapshot = this.$refs.snapshot; const snapshot = this.$refs.snapshot;
const overlay = this.$refs.overlay; const context = canvas.getContext('2d');
const ctx = canvas.getContext('2d');
canvas.width = video.videoWidth; canvas.width = video.videoWidth;
canvas.height = video.videoHeight; canvas.height = video.videoHeight;
ctx.drawImage(video, 0, 0);
const snapshotData = canvas.toDataURL('image/png'); context.drawImage(video, 0, 0, canvas.width, canvas.height);
this.$refs.hiddenInput.value = snapshotData;
this.capturedPhoto = snapshotData;
// ✅ Hide video and overlays immediately //const dataUrl = canvas.toDataURL('image/png');
video.classList.add('hidden'); const dataUrl = canvas.toDataURL('image/jpeg', 0.95);
overlay.classList.add('hidden');
// ✅ Set snapshot image and display in same place if (this.stream) this.stream.getTracks().forEach(track => track.stop());
snapshot.src = snapshotData;
snapshot.src = dataUrl;
snapshot.classList.remove('hidden'); snapshot.classList.remove('hidden');
video.classList.add('hidden');
this.photoTaken = true;
// ✅ Stop video stream (after hiding) this.$refs.hiddenInput.value = dataUrl;
if (this.stream) { console.log('Captured Image:', dataUrl);
this.stream.getTracks().forEach(track => track.stop());
}
this.stopDetection();
}, },
async verifyPhoto() { async verifyPhoto() {
if (!this.capturedPhoto) { if (!this.capturedPhoto) {
alert("Please capture a photo first!"); alert("Please capture a photo first!");