Closed gmlloves closed 1 year ago
The return value of createImageBitmap
is a promise. The error is occurring on this line because you are passing a Promise<ImageBitmap>
instead of an ImageBitmap
to ocrClient.loadImage
:
await ocr.loadImage(createImageBitmap(image));
Here image
is already an ImageBitmap
because it came from await createImageBitmap(...)
above.
Regarding this line:
await ocr.loadModel('js/eng.traineddata.js');
Is this file exactly the same as https://raw.githubusercontent.com/tesseract-ocr/tessdata_fast/main/eng.traineddata or did you modify it. That file should not have a .js
extension because it isn't a JavaScript file. It is a binary blob of neural network weights.
Hello, Robert,
The return value of createImageBitmap is a promise. The error is occurring on this line because you are passing a Promise instead of an ImageBitmap to ocrClient.loadImage:
Ups... It was my mistake. It works :)
Is this file exactly the same as https://raw.githubusercontent.com/tesseract-ocr/tessdata_fast/main/eng.traineddata or did you modify it. That file should not have a .js extension because it isn't a JavaScript file. It is a binary blob of neural network weights.
Yes, It is the same file. I just was testing and didn't config the server to return .traineddata files.
Thank you. Gaston
Hello,
I am woking on a Blazor Webassembly app and I'd like to use your library. I tried to modify your example, build it and copy the files (ocr-app.bundle.js, tesseract-core.wasm, tesseract-core-fallback.wasm, tesseract-worker.js) to my project but I got the error:
Failed to execute 'postMessage' on 'MessagePort': # could not be cloned.
Error: Failed to execute 'postMessage' on 'MessagePort': # could not be cloned.
at ocr-app.bundle.js:256
at new Promise ()
at requestResponseMessage (tesseract.js:244)
at Object.apply (tesseract.js:180)
at OCRClient.loadImage (tesseract.js:346)
at async runOCR (ocr.js:34)
https://github.com/robertknight/tesseract-wasm/blob/main/examples/web/ocr-app.js
Index.html (my project)
ocr.js (my project)
Can you help me? Is there a plain script tags (maybe with a CDN) to include it?
Thank you in advance.