diff --git a/examples/node/recognize.js b/examples/node/recognize.js index 6baf35c..01b54fe 100755 --- a/examples/node/recognize.js +++ b/examples/node/recognize.js @@ -1,13 +1,23 @@ #!/usr/bin/env node const path = require('path'); -const Tesseract = require('../../'); +const { createWorker } = require('../../'); const [,, imagePath] = process.argv; const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png')); console.log(`Recognizing ${image}`); +const worker = createWorker({ + logger: m => console.log(m), +}); -Tesseract.recognize(image, 'eng', { logger: m => console.log(m) }) - .then(({ data: { text } }) => { - console.log(text); +(async () => { + await worker.load(); + await worker.loadLanguage('eng'); + await worker.initialize('eng'); + await worker.setParameters({ + user_defined_dpi: '300', }); + const { data: { text } } = await worker.recognize(image); + console.log(text); + await worker.terminate(); +})();