modified logic for signle pdf in ocr
This commit is contained in:
@@ -74,11 +74,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
<x-filament::button color="primary" @click="verify" x-show="photoTaken" class="inline-flex w-auto">Verify</x-filament::button>
|
||||
</div> --}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{-- <input type="hidden" name="{{ $getName() }}" x-ref="hiddenInput"> --}}
|
||||
{{-- <input type="hidden" x-ref="hiddenInput" name="camera_capture"> --}}
|
||||
{{-- <input type="hidden" x-ref="hiddenInput" id="camera_capture_field" name="camera_capture_file">
|
||||
@@ -875,14 +870,36 @@ function cameraCapture() {
|
||||
});
|
||||
|
||||
const detectedText = result.data.text.trim();
|
||||
// alert("Detected Text:\n" + (detectedText || "[No text detected]"));
|
||||
// Extract serial numbers (digits only)
|
||||
const matches = detectedText.match(/\d+/g) || [];
|
||||
this.serialNumbers = matches.slice(0, 4); // take first 4 serials
|
||||
// const matches = detectedText.match(/\d+/g) || [];
|
||||
|
||||
// const serialRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i;
|
||||
// const match = detectedText.match(serialRegex);
|
||||
|
||||
// this.serialNumbers = matches.slice(0, 4); // take first 4 serials
|
||||
const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i;
|
||||
const match = detectedText.match(serialWithLabelRegex);
|
||||
|
||||
if (match && match[1]) {
|
||||
//Scenario Found "Serial No"
|
||||
this.serialNumbers = [match[1].trim()];
|
||||
console.log("Serial with Label:", this.serialNumbers[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Extract first 4 numbers
|
||||
const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || [];
|
||||
this.serialNumbers = generalNums.slice(0, 4);
|
||||
|
||||
if (this.serialNumbers.length == 0) {
|
||||
alert("No serial numbers detected!");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Serial Numbers List:", this.serialNumbers);
|
||||
}
|
||||
|
||||
this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers);
|
||||
//this.$refs.serialInput.value = JSON.stringify(this.serialNumbers);
|
||||
alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value);
|
||||
// ✅ Save to Laravel Session using POST API
|
||||
fetch('/save-serials-to-session', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
@@ -937,7 +954,6 @@ function cameraCapture() {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async retakePhoto() {
|
||||
this.photoTaken = false;
|
||||
this.$refs.snapshot.classList.add('hidden');
|
||||
|
||||
Reference in New Issue
Block a user