Files: d456a6cc8589489e558e6164750474ed2cfc961e / test / test-79-npm / tesseract.js / tesseract.js.js
590 bytesRaw
1 | ; |
2 | |
3 | var fs = require('fs'); |
4 | var path = require('path'); |
5 | var Tesseract = require('tesseract.js'); |
6 | var image = path.join(__dirname, 'hello.jpg'); |
7 | |
8 | Tesseract.recognize(image).then(function (data) { |
9 | if (data && data.text && typeof data.text === 'string') { |
10 | if (data.text.toLowerCase().indexOf('hello') >= 0) { |
11 | console.log('ok'); |
12 | } else { |
13 | console.log(data.text.replace(/\n/g, '\\n')); |
14 | } |
15 | } else { |
16 | console.log(data); |
17 | } |
18 | }).catch(function (error) { |
19 | console.log(error); |
20 | }).finally(function () { |
21 | fs.unlinkSync('eng.traineddata'); |
22 | process.exit(); |
23 | }); |
24 |
Built with git-ssb-web