modified logic in ocr

This commit is contained in:
dhanabalan
2025-10-24 17:40:50 +05:30
parent a3732936ac
commit 979c65e781

View File

@@ -328,27 +328,16 @@ function cameraCapture() {
}, },
async capturePhoto() {
const video = this.$refs.video;
const canvas = this.$refs.canvas;
const ctx = canvas.getContext('2d');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
ctx.drawImage(video, 0, 0);
const snapshot = this.$refs.snapshot;
snapshot.src = canvas.toDataURL('image/png');
snapshot.onload = () => { snapshot.onload = () => {
snapshot.classList.remove('hidden'); snapshot.classList.remove('hidden');
video.classList.add('hidden'); video.classList.add('hidden');
this.photoTaken = true;
this.stopCamera(); this.stopCamera();
// Destroy old cropper if exists
if (this.cropper) this.cropper.destroy(); if (this.cropper) this.cropper.destroy();
// Initialize cropper
requestAnimationFrame(() => { requestAnimationFrame(() => {
this.cropper = new Cropper(snapshot, { this.cropper = new Cropper(snapshot, {
aspectRatio: NaN, aspectRatio: NaN,
@@ -361,9 +350,13 @@ function cameraCapture() {
zoomable: true, zoomable: true,
}); });
console.log("✅ Cropper initialized"); console.log("✅ Cropper initialized");
// ✅ Update Alpine reactivity so buttons show
this.$nextTick(() => {
this.photoTaken = true;
}); });
}; });
} },
// //
async uploadCroppedImage() { async uploadCroppedImage() {