modified logic in ocr
This commit is contained in:
@@ -323,80 +323,6 @@ function cameraCapture() {
|
|||||||
await this.initCamera();
|
await this.initCamera();
|
||||||
},
|
},
|
||||||
|
|
||||||
// async capturePhoto() {
|
|
||||||
// const video = this.$refs.video;
|
|
||||||
// const canvas = this.$refs.canvas;
|
|
||||||
// const context = canvas.getContext('2d');
|
|
||||||
|
|
||||||
// canvas.width = video.videoWidth;
|
|
||||||
// canvas.height = video.videoHeight;
|
|
||||||
// context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
||||||
|
|
||||||
// // Show snapshot
|
|
||||||
// const snapshot = this.$refs.snapshot;
|
|
||||||
// snapshot.src = canvas.toDataURL('image/png');
|
|
||||||
// snapshot.classList.remove('hidden');
|
|
||||||
// video.classList.add('hidden');
|
|
||||||
|
|
||||||
// // Convert canvas to file
|
|
||||||
// canvas.toBlob(async blob => {
|
|
||||||
// const file = new File([blob], 'capture.png', { type: 'image/png' });
|
|
||||||
// console.log("File ready for upload:", file);
|
|
||||||
|
|
||||||
// // Upload to temp folder
|
|
||||||
// const formData = new FormData();
|
|
||||||
// formData.append('photo', file);
|
|
||||||
|
|
||||||
// const response = await fetch('/temp-upload', {
|
|
||||||
// method: 'POST',
|
|
||||||
// headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
|
||||||
// body: formData
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const data = await response.json();
|
|
||||||
// if (data.success) {
|
|
||||||
// this.$refs.hiddenInput.value = data.path; // Filament form hidden input
|
|
||||||
// console.log("Saved to temp:", data.path);
|
|
||||||
// } else {
|
|
||||||
// alert('Failed to save image.');
|
|
||||||
// }
|
|
||||||
// }, 'image/png', 1.0); // 1.0 = highest quality
|
|
||||||
|
|
||||||
// this.photoTaken = true;
|
|
||||||
|
|
||||||
// // Create cropper on image
|
|
||||||
// // this.cropper = new Cropper(snapshot, {
|
|
||||||
// // aspectRatio: NaN, // User free crop area
|
|
||||||
// // viewMode: 1
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// if (this.stream) this.stream.getTracks().forEach(track => track.stop());
|
|
||||||
// },
|
|
||||||
|
|
||||||
|
|
||||||
// async verifyOCR(dataUrl) {
|
|
||||||
// try {
|
|
||||||
// const { data: { text } } = await Tesseract.recognize(
|
|
||||||
// dataUrl,
|
|
||||||
// 'eng',
|
|
||||||
// { logger: m => console.log(m) }
|
|
||||||
// );
|
|
||||||
// alert("OCR Result: " + text);
|
|
||||||
// } catch (err) {
|
|
||||||
// console.error(err);
|
|
||||||
// alert("OCR Failed: " + err.message);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
// async verify() {
|
|
||||||
// const dataUrl = this.$refs.hiddenInput.value;
|
|
||||||
// if (!dataUrl) {
|
|
||||||
// alert("No captured image found!");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// await this.verifyOCR(dataUrl);
|
|
||||||
// },
|
|
||||||
|
|
||||||
|
|
||||||
async capturePhoto() {
|
async capturePhoto() {
|
||||||
const video = this.$refs.video;
|
const video = this.$refs.video;
|
||||||
@@ -419,13 +345,17 @@ function cameraCapture() {
|
|||||||
this.stopCamera();
|
this.stopCamera();
|
||||||
|
|
||||||
// ✅ Now start Cropper (only after image becomes visible)
|
// ✅ Now start Cropper (only after image becomes visible)
|
||||||
this.cropper?.destroy();
|
// this.cropper?.destroy();
|
||||||
|
// this.cropper = new Cropper(snapshot, {
|
||||||
|
// aspectRatio: NaN, // free crop
|
||||||
|
// dragMode: 'crop',
|
||||||
|
// viewMode: 1,
|
||||||
|
// autoCropArea: 0.8,
|
||||||
|
// background: false,
|
||||||
|
// });
|
||||||
this.cropper = new Cropper(snapshot, {
|
this.cropper = new Cropper(snapshot, {
|
||||||
aspectRatio: NaN, // free crop
|
aspectRatio: NaN, // User free crop area
|
||||||
dragMode: 'crop',
|
viewMode: 1
|
||||||
viewMode: 1,
|
|
||||||
autoCropArea: 0.8,
|
|
||||||
background: false,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user