Jerome Wu
6 years ago
7 changed files with 34 additions and 27 deletions
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
// replace this with require('tesseract.js')
|
||||
const path = require('path'); |
||||
const { TesseractWorker } = require('../../'); |
||||
|
||||
const image = path.resolve(__dirname, '../../tests/assets/images/cosmic.png'); |
||||
const tessWorker = new TesseractWorker(); |
||||
|
||||
tessWorker.recognize(image) |
||||
.then((data) => { |
||||
console.log('then\n', data.text); |
||||
}) |
||||
.catch((err) => { |
||||
console.log('catch\n', err); |
||||
}) |
||||
.finally(() => { |
||||
console.log('finally\n'); |
||||
process.exit(); |
||||
}); |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
const path = require('path'); |
||||
const { TesseractWorker } = require('../../'); |
||||
|
||||
const [,, imagePath] = process.argv; |
||||
const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png')); |
||||
const tessWorker = new TesseractWorker(); |
||||
|
||||
console.log(`Recognizing ${image}`); |
||||
|
||||
tessWorker.recognize(image) |
||||
.progress((info) => { |
||||
console.log(info); |
||||
}) |
||||
.then((data) => { |
||||
console.log(data.text); |
||||
}) |
||||
.catch((err) => { |
||||
console.log('Error\n', err); |
||||
}) |
||||
.finally(() => { |
||||
process.exit(); |
||||
}); |
Loading…
Reference in new issue