You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
546 B
24 lines
546 B
6 years ago
|
#!/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();
|
||
|
});
|