From cf01272419a109f891b7b2978de7047c03cf67bc Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 27 Oct 2025 11:07:52 +0530 Subject: [PATCH] Added logic in ocr for capture --- .../views/fields/camera-capture.blade.php | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index b08ec01..af1217d 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -822,11 +822,11 @@ function cameraCapture() { // this.stopDetection(); // }, - async capturePhoto() { +async capturePhoto() { const video = this.$refs.video; const canvas = this.$refs.canvas; - const overlay = this.$refs.overlay; const snapshot = this.$refs.snapshot; + const overlay = this.$refs.overlay; const ctx = canvas.getContext('2d'); canvas.width = video.videoWidth; @@ -837,17 +837,22 @@ function cameraCapture() { this.$refs.hiddenInput.value = snapshotData; this.capturedPhoto = snapshotData; - // ✅ Hide live video immediately → prevents black frame -video.classList.add('hidden'); -overlay.classList.add('hidden'); + // ✅ Hide video and overlays immediately + video.classList.add('hidden'); + overlay.classList.add('hidden'); -// Stop camera stream after hide -if (this.stream) this.stream.getTracks().forEach(track => track.stop()); + // ✅ Set snapshot image and display in same place + 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() {