modified capture photo method logic in ocr
This commit is contained in:
@@ -340,30 +340,30 @@ function cameraCapture() {
|
|||||||
const snapshot = this.$refs.snapshot;
|
const snapshot = this.$refs.snapshot;
|
||||||
snapshot.src = canvas.toDataURL('image/png');
|
snapshot.src = canvas.toDataURL('image/png');
|
||||||
|
|
||||||
// ✅ Wait until the SNAPSHOT image loads before cropper!
|
|
||||||
snapshot.onload = () => {
|
snapshot.onload = () => {
|
||||||
snapshot.classList.remove('hidden');
|
snapshot.classList.remove('hidden');
|
||||||
video.classList.add('hidden');
|
video.classList.add('hidden');
|
||||||
|
|
||||||
this.photoTaken = true;
|
this.photoTaken = true;
|
||||||
this.stopCamera(); // ✅ Now camera turns off immediately
|
this.stopCamera();
|
||||||
|
|
||||||
// ✅ Ensure previous cropper destroyed
|
if (this.cropper) this.cropper.destroy();
|
||||||
if (this.cropper) {
|
|
||||||
this.cropper.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Start Cropper only after image rendered
|
requestAnimationFrame(() => {
|
||||||
this.cropper = new Cropper(snapshot, {
|
this.cropper = new Cropper(snapshot, {
|
||||||
aspectRatio: NaN,
|
aspectRatio: NaN,
|
||||||
dragMode: 'crop',
|
dragMode: 'crop',
|
||||||
viewMode: 1,
|
viewMode: 1,
|
||||||
autoCropArea: 1,
|
autoCropArea: 0.9,
|
||||||
background: false,
|
background: true,
|
||||||
|
responsive: true,
|
||||||
|
movable: true,
|
||||||
|
zoomable: true,
|
||||||
|
});
|
||||||
|
console.log("✅ Cropper initialized");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
async uploadCroppedImage() {
|
async uploadCroppedImage() {
|
||||||
|
|||||||
Reference in New Issue
Block a user