From a621df56fd7f43d99427a058f8f269245758e609 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 18 Oct 2025 09:48:58 +0530 Subject: [PATCH] changed init camera logic in ocr --- .../views/fields/camera-capture.blade.php | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index 5051b16..23148fe 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -185,20 +185,35 @@ document.addEventListener('DOMContentLoaded', () => { photoTaken: false, photo1: '', + // async initCamera() { + // try { + // if (this.stream) this.stream.getTracks().forEach(track => track.stop()); + + // this.stream = await navigator.mediaDevices.getUserMedia({ + // video: { facingMode: this.currentFacingMode } + // }); + + // this.$refs.video.srcObject = this.stream; + // } catch (err) { + // console.error("Camera error:", err); + // alert("Cannot access camera. Enable permissions or use HTTPS."); + // } + // }, async initCamera() { try { - if (this.stream) this.stream.getTracks().forEach(track => track.stop()); - this.stream = await navigator.mediaDevices.getUserMedia({ - video: { facingMode: this.currentFacingMode } + video: { + width: { ideal: 1920 }, + height: { ideal: 1080 }, + }, + audio: false }); - this.$refs.video.srcObject = this.stream; } catch (err) { - console.error("Camera error:", err); - alert("Cannot access camera. Enable permissions or use HTTPS."); + console.error('Error accessing camera:', err); } - }, + } + async switchCamera() { this.currentFacingMode = this.currentFacingMode === 'user' ? 'environment' : 'user';