tesseract.js icon indicating copy to clipboard operation
tesseract.js copied to clipboard

How to package all the code

Open zhao-i opened this issue 3 years ago • 1 comments

hello,

I want using tesseract.js 2.1.5 in a electron app, and I have a questions need help.

when I did not add config for createWorker, will get an error code :

for example Error: Cannot find module ' ... \worker-script\node\index.js'

when specifying a relative workerPath or use default http url, the path after splicing is wrong. so, I try to specify an absolute path, It ran successfully! but those modules will not be packaged and will not work on other computers, because other computers dnot have 100% same module.

How can I avoid this problem?

thanks, this my code:


//main process
let worker

if (!worker_is_ready) {

    worker = createWorker({
      // workerPath: './node_modules/tesseract.js/src/worker-script/node',
      // workerPath: 'https://unpkg.com/[email protected]/dist/worker.min.js'
      // workerPath:  "D:/new el/vue-electron-ui/app/node_modules/tesseract.js/src/worker-script/node",
      // langPath: path.join(__dirname,'tessdata'),
      cacheMethod: 'readOnly',
      gzip:false

    });

    await worker.load()
    await worker.loadLanguage('eng');
    await worker.initialize('eng');
    await worker.setParameters({ tessedit_char_whitelist: '0123456789' });
    worker_is_ready = true;

  }

  const { data: { text } } = await worker.recognize(image);

  handle(text);

}

zhao-i avatar Jan 03 '22 06:01 zhao-i

Why has none of the contributors responded to this?
Based on the lack of response to this and other user's issues, I wonder if this package being actively supported?

ewrayjohnson avatar Jul 16 '22 16:07 ewrayjohnson

See this example.

https://github.com/Balearica/tesseract.js-electron

Balearica avatar Sep 25 '22 03:09 Balearica