From c3259710f67a658d0f1da81c20fdbe2d27fe30bc Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 24 Oct 2025 17:12:56 +0530 Subject: [PATCH] modified logic in ocr --- .../views/fields/camera-capture.blade.php | 90 +++---------------- 1 file changed, 10 insertions(+), 80 deletions(-) diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index f684e26..17818a8 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -323,80 +323,6 @@ function cameraCapture() { await this.initCamera(); }, - // async capturePhoto() { - // const video = this.$refs.video; - // const canvas = this.$refs.canvas; - // const context = canvas.getContext('2d'); - - // canvas.width = video.videoWidth; - // canvas.height = video.videoHeight; - // context.drawImage(video, 0, 0, canvas.width, canvas.height); - - // // Show snapshot - // const snapshot = this.$refs.snapshot; - // snapshot.src = canvas.toDataURL('image/png'); - // snapshot.classList.remove('hidden'); - // video.classList.add('hidden'); - - // // Convert canvas to file - // canvas.toBlob(async blob => { - // const file = new File([blob], 'capture.png', { type: 'image/png' }); - // console.log("File ready for upload:", file); - - // // Upload to temp folder - // const formData = new FormData(); - // formData.append('photo', file); - - // const response = await fetch('/temp-upload', { - // method: 'POST', - // headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, - // body: formData - // }); - - // const data = await response.json(); - // if (data.success) { - // this.$refs.hiddenInput.value = data.path; // Filament form hidden input - // console.log("Saved to temp:", data.path); - // } else { - // alert('Failed to save image.'); - // } - // }, 'image/png', 1.0); // 1.0 = highest quality - - // this.photoTaken = true; - - // // Create cropper on image - // // this.cropper = new Cropper(snapshot, { - // // aspectRatio: NaN, // User free crop area - // // viewMode: 1 - // // }); - - // if (this.stream) this.stream.getTracks().forEach(track => track.stop()); - // }, - - - // async verifyOCR(dataUrl) { - // try { - // const { data: { text } } = await Tesseract.recognize( - // dataUrl, - // 'eng', - // { logger: m => console.log(m) } - // ); - // alert("OCR Result: " + text); - // } catch (err) { - // console.error(err); - // alert("OCR Failed: " + err.message); - // } - // }, - - // async verify() { - // const dataUrl = this.$refs.hiddenInput.value; - // if (!dataUrl) { - // alert("No captured image found!"); - // return; - // } - // await this.verifyOCR(dataUrl); - // }, - async capturePhoto() { const video = this.$refs.video; @@ -419,13 +345,17 @@ function cameraCapture() { this.stopCamera(); // ✅ Now start Cropper (only after image becomes visible) - this.cropper?.destroy(); + // this.cropper?.destroy(); + // this.cropper = new Cropper(snapshot, { + // aspectRatio: NaN, // free crop + // dragMode: 'crop', + // viewMode: 1, + // autoCropArea: 0.8, + // background: false, + // }); this.cropper = new Cropper(snapshot, { - aspectRatio: NaN, // free crop - dragMode: 'crop', - viewMode: 1, - autoCropArea: 0.8, - background: false, + aspectRatio: NaN, // User free crop area + viewMode: 1 }); }; },