changed logic in ocr
This commit is contained in:
@@ -39,8 +39,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
</script> --}}
|
</script> --}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div x-data="cameraCapture()" x-init="initCamera()" class="space-y-2">
|
<div x-data="cameraCapture()" x-init="initCamera()" class="space-y-2">
|
||||||
<video x-ref="video" width="320" height="240" autoplay playsinline class="border rounded"></video>
|
<video x-ref="video" width="320" height="240" autoplay playsinline class="border rounded"></video>
|
||||||
<canvas x-ref="canvas" width="320" height="240" class="hidden"></canvas>
|
<canvas x-ref="canvas" width="320" height="240" class="hidden"></canvas>
|
||||||
@@ -52,8 +50,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
<x-filament::button color="gray" @click="switchCamera" x-show="!photoTaken">Switch Camera</x-filament::button>
|
<x-filament::button color="gray" @click="switchCamera" x-show="!photoTaken">Switch Camera</x-filament::button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- <input type="hidden" name="{{ $getName() }}" x-ref="hiddenInput"> --}}
|
|
||||||
<input type="hidden" name="photo_data" x-ref="hiddenInput">
|
<input type="hidden" name="{{ $getName() }}" x-ref="hiddenInput">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -62,7 +60,6 @@ function cameraCapture() {
|
|||||||
stream: null,
|
stream: null,
|
||||||
currentFacingMode: 'user', // 'user' = front, 'environment' = back
|
currentFacingMode: 'user', // 'user' = front, 'environment' = back
|
||||||
photoTaken: false,
|
photoTaken: false,
|
||||||
recognizedText: '',
|
|
||||||
|
|
||||||
async initCamera() {
|
async initCamera() {
|
||||||
try {
|
try {
|
||||||
@@ -107,20 +104,6 @@ function cameraCapture() {
|
|||||||
this.$refs.hiddenInput.value = dataUrl;
|
this.$refs.hiddenInput.value = dataUrl;
|
||||||
},
|
},
|
||||||
|
|
||||||
async verifyPhoto() {
|
|
||||||
this.recognizedText = 'Processing...';
|
|
||||||
|
|
||||||
const snapshot = this.$refs.snapshot;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await Tesseract.recognize(snapshot.src, 'eng');
|
|
||||||
this.recognizedText = result.data.text.trim();
|
|
||||||
} catch (err) {
|
|
||||||
console.error('OCR Error:', err);
|
|
||||||
this.recognizedText = 'Error reading text from image.';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async retakePhoto() {
|
async retakePhoto() {
|
||||||
this.photoTaken = false;
|
this.photoTaken = false;
|
||||||
this.$refs.snapshot.classList.add('hidden');
|
this.$refs.snapshot.classList.add('hidden');
|
||||||
|
|||||||
Reference in New Issue
Block a user