Skip to content

Instantly share code, notes, and snippets.

@jeromewu
Created October 3, 2019 14:13
Show Gist options
  • Save jeromewu/4c7c3de9b06b86fbd7fa4771ec25be94 to your computer and use it in GitHub Desktop.
Save jeromewu/4c7c3de9b06b86fbd7fa4771ec25be94 to your computer and use it in GitHub Desktop.
const { createWorker, createScheduler } = require('tesseract.js');
const image = 'https://tesseract.projectnaptha.com/img/eng_bw.png';
const scheduler = createScheduler();
(async () => {
for (let i = 0; i < 4; i++) {
const w = createWorker();
await w.load();
await w.loadLanguage('eng');
await w.initialize('eng');
scheduler.addWorker(w);
}
const rets = await Promise.all(Array(10).fill(0).map(() => (
scheduler.addJob('recognize', image);
)));
console.log(rets.map(({ data: { text } }) => text));
await scheduler.terminate();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment