Added logic for verfication serials
This commit is contained in:
@@ -386,6 +386,42 @@ function cameraCapture() {
|
|||||||
// await this.verifyOCR(dataUrl);
|
// await this.verifyOCR(dataUrl);
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
// async verify() {
|
||||||
|
// const filePath = this.$refs.hiddenInput.value; // e.g., "temp/capture_1760764396.jpeg"
|
||||||
|
|
||||||
|
// if (!filePath) {
|
||||||
|
// alert("No captured image found!");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// const response = await fetch('/verify-ocr', {
|
||||||
|
// method: 'POST',
|
||||||
|
// headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
// 'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
|
// },
|
||||||
|
// body: JSON.stringify({ path: filePath })
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const data = await response.json();
|
||||||
|
|
||||||
|
// console.log(data);
|
||||||
|
|
||||||
|
// if (data.success) {
|
||||||
|
// alert("OCR Result: " + data.text);
|
||||||
|
// console.error(data.text);
|
||||||
|
// } else {
|
||||||
|
// alert("OCR Failed: " + data.error);
|
||||||
|
// console.error(data.error);
|
||||||
|
// }
|
||||||
|
// } catch (err) {
|
||||||
|
// console.error(err.message);
|
||||||
|
// alert("OCR request failed: " + err.message);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
|
||||||
|
|
||||||
async verify() {
|
async verify() {
|
||||||
const filePath = this.$refs.hiddenInput.value; // e.g., "temp/capture_1760764396.jpeg"
|
const filePath = this.$refs.hiddenInput.value; // e.g., "temp/capture_1760764396.jpeg"
|
||||||
|
|
||||||
@@ -406,21 +442,19 @@ function cameraCapture() {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
alert("OCR Result: " + data.text);
|
// data.text is now an array of serials
|
||||||
console.error(data.text);
|
console.log("Serials:", data.text);
|
||||||
|
alert("OCR Result:\n" + data.text.join("\n")); // show nicely
|
||||||
} else {
|
} else {
|
||||||
|
console.error("OCR Error:", data.error);
|
||||||
alert("OCR Failed: " + data.error);
|
alert("OCR Failed: " + data.error);
|
||||||
console.error(data.error);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err.message);
|
console.error("OCR request failed:", err.message);
|
||||||
alert("OCR request failed: " + err.message);
|
alert("OCR request failed: " + err.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
async retakePhoto() {
|
async retakePhoto() {
|
||||||
this.photoTaken = false;
|
this.photoTaken = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user