modified logic in ocr capture photo
This commit is contained in:
@@ -328,35 +328,50 @@ function cameraCapture() {
|
||||
},
|
||||
|
||||
|
||||
snapshot.onload = () => {
|
||||
snapshot.classList.remove('hidden');
|
||||
video.classList.add('hidden');
|
||||
async capturePhoto() {
|
||||
const video = this.$refs.video;
|
||||
const canvas = this.$refs.canvas;
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
this.stopCamera();
|
||||
canvas.width = video.videoWidth;
|
||||
canvas.height = video.videoHeight;
|
||||
ctx.drawImage(video, 0, 0);
|
||||
|
||||
// Destroy old cropper if exists
|
||||
if (this.cropper) this.cropper.destroy();
|
||||
const snapshot = this.$refs.snapshot;
|
||||
snapshot.src = canvas.toDataURL('image/png');
|
||||
|
||||
// Initialize cropper
|
||||
requestAnimationFrame(() => {
|
||||
this.cropper = new Cropper(snapshot, {
|
||||
aspectRatio: NaN,
|
||||
dragMode: 'crop',
|
||||
viewMode: 1,
|
||||
autoCropArea: 0.9,
|
||||
background: true,
|
||||
responsive: true,
|
||||
movable: true,
|
||||
zoomable: true,
|
||||
});
|
||||
console.log("✅ Cropper initialized");
|
||||
snapshot.onload = () => {
|
||||
snapshot.classList.remove('hidden');
|
||||
video.classList.add('hidden');
|
||||
|
||||
this.stopCamera();
|
||||
|
||||
// Destroy old cropper if exists
|
||||
if (this.cropper) this.cropper.destroy();
|
||||
|
||||
// Initialize cropper
|
||||
requestAnimationFrame(() => {
|
||||
this.cropper = new Cropper(snapshot, {
|
||||
aspectRatio: NaN,
|
||||
dragMode: 'crop',
|
||||
viewMode: 1,
|
||||
autoCropArea: 0.9,
|
||||
background: true,
|
||||
responsive: true,
|
||||
movable: true,
|
||||
zoomable: true,
|
||||
});
|
||||
console.log("✅ Cropper initialized");
|
||||
|
||||
// ✅ Update Alpine reactivity so buttons show
|
||||
this.$nextTick(() => {
|
||||
this.photoTaken = true;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
// ✅ Update Alpine reactivity so buttons show
|
||||
this.$nextTick(() => {
|
||||
this.photoTaken = true;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
//
|
||||
async uploadCroppedImage() {
|
||||
|
||||
Reference in New Issue
Block a user