Created
October 3, 2019 14:13
-
-
Save jeromewu/4c7c3de9b06b86fbd7fa4771ec25be94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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