I'm currently exploring the use of Tesseract within one of my components for OCR processing on a file.
.ts:
import * as Tesseract from 'tesseract.js';
fileToUpload: File = null;
handleFileInput(files: FileList) {
this.fileToUpload = files.item(0);
}
imageOcr() {
Tesseract.recognize(this.fileToUpload)
.progress(message => console.log(message))
.catch(err => console.error(err))
.then(res => console.log(res))
.finally(resultOrError => console.log(resultOrError));
}
.html
<div>
<h6>Local Image OCR</h6>
<input type="file" accept=".jpg,.png,.jpeg,.webp" (change)="handleFileInput($event.target.files)">
<button (click)="imageOcr()">click</button>
</div>
While following this guide, I encountered the following error message:
"blob:http://localhost:4200/65999042-8757-4264-b92d-ed5e0a0e4c27:1 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:4200/dist/worker.dev.js?nocache=qf0eq67rus' failed to load.
at blob:http://localhost:4200/65999042-8757-4264-b92d-ed5e0a0e4c27:1:1"
What steps should I take to resolve this issue and successfully implement Tesseract functionality?