Jerome Wu
5 years ago
1 changed files with 14 additions and 4 deletions
@ -1,13 +1,23 @@ |
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const path = require('path'); |
const path = require('path'); |
||||||
const Tesseract = require('../../'); |
const { createWorker } = require('../../'); |
||||||
|
|
||||||
const [,, imagePath] = process.argv; |
const [,, imagePath] = process.argv; |
||||||
const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png')); |
const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png')); |
||||||
|
|
||||||
console.log(`Recognizing ${image}`); |
console.log(`Recognizing ${image}`); |
||||||
|
const worker = createWorker({ |
||||||
|
logger: m => console.log(m), |
||||||
|
}); |
||||||
|
|
||||||
Tesseract.recognize(image, 'eng', { logger: m => console.log(m) }) |
(async () => { |
||||||
.then(({ data: { text } }) => { |
await worker.load(); |
||||||
console.log(text); |
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(); |
||||||
|
})(); |
||||||
|
Loading…
Reference in new issue