Browse Source

Update examples

develop
Jerome Wu 6 years ago
parent
commit
b1c30dfad9
  1. 0
      examples/browser/basic.html
  2. 0
      examples/browser/demo.html
  3. 1
      examples/file-input/README.md
  4. 18
      examples/node/basic.js
  5. 7
      examples/node/detect.js
  6. 23
      examples/node/recognize.js

0
examples/file-input/basic.html → examples/browser/basic.html

0
examples/file-input/demo.html → examples/browser/demo.html

1
examples/file-input/README.md

@ -1 +0,0 @@ @@ -1 +0,0 @@
#

18
examples/node/basic.js

@ -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();
});

7
examples/node/detect.js

@ -1,10 +1,13 @@ @@ -1,10 +1,13 @@
// replace this with require('tesseract.js')
#!/usr/bin/env node
const path = require('path');
const { TesseractWorker } = require('../../');
const image = path.resolve(__dirname, '../../tests/assets/images/cosmic.png');
const [,, imagePath] = process.argv;
const image = path.resolve(__dirname, (imagePath || '../../tests/assets/images/cosmic.png'));
const tessWorker = new TesseractWorker();
console.log(`Detecting ${image}`);
tessWorker.detect(image)
.progress((info) => {
console.log(info);

23
examples/node/recognize.js

@ -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…
Cancel
Save