Jerome Wu
5 years ago
1 changed files with 14 additions and 4 deletions
@ -1,13 +1,23 @@
@@ -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(); |
||||
})(); |
||||
|
Loading…
Reference in new issue