Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught (in promise) RuntimeError: function signature mismatch when using Tesseract.js

Tags:

javascript

Have run into what I suspect is a problem with the async function. The error thrown is: Uncaught (in promise) RuntimeError: function signature mismatch when I'm trying to have my image run through OCR using tesseract.js Any ideas on what I'm doing wrong? Is it the way I've constructed my async function?

This is the relevant snippet. It's indicating that the last line is causing the error

const { createWorker } = require('tesseract.js');

const worker = createWorker();
generateText = () => {
      let uploads = this.state.uploads;
      console.log(uploads);

      for(var i = 0; i < uploads.length; i++) {


        (async () => {
          await worker.load();
          await worker.loadLanguage('eng');
          await worker.initialize('eng');
          const { data: { text } } = await worker.recognize(uploads[i]);
          console.log(text);
          await worker.terminate();
        })();
 }
    }
like image 798
Terribleangel Avatar asked Apr 17 '20 16:04

Terribleangel


1 Answers

Update the library, that error occurs in version 2.1.1 and version 2.1.2 no longer comes out

https://cdnjs.com/libraries/tesseract.js/2.1.2

like image 59
ztvmark Avatar answered Oct 06 '22 01:10

ztvmark