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.
56 lines
1.0 KiB
56 lines
1.0 KiB
6 years ago
|
# Tesseract.js Examples
|
||
|
|
||
|
### basic
|
||
|
|
||
|
```javascript
|
||
|
import Tesseract from 'tesseract.js';
|
||
|
|
||
|
const { TesseractWorker } = Tesseract;
|
||
|
const worker = new TessearctWorker();
|
||
|
|
||
|
worker
|
||
|
.recognize('http://jeroen.github.io/images/testocr.png')
|
||
|
.then((result) => {
|
||
|
console.log(result);
|
||
|
});
|
||
|
```
|
||
|
|
||
|
### with detailed progress
|
||
|
|
||
|
```javascript
|
||
|
import Tesseract from 'tesseract.js';
|
||
|
|
||
|
const { TesseractWorker } = Tesseract;
|
||
|
const worker = new TessearctWorker();
|
||
|
|
||
|
worker
|
||
|
.recognize('http://jeroen.github.io/images/testocr.png')
|
||
|
.progress((p) => {
|
||
|
console.log('progress', p);
|
||
|
})
|
||
|
.then((result) => {
|
||
|
console.log(result);
|
||
|
});
|
||
|
```
|
||
|
|
||
|
### with multiple languages (separate by '+'')
|
||
|
|
||
|
```javascript
|
||
|
import Tesseract from 'tesseract.js';
|
||
|
|
||
|
const { TesseractWorker } = Tesseract;
|
||
|
const worker = new TessearctWorker();
|
||
|
|
||
|
worker
|
||
|
.recognize(
|
||
|
'http://jeroen.github.io/images/testocr.png',
|
||
|
{ lang: 'eng+chi_tra' }
|
||
|
)
|
||
|
.progress((p) => {
|
||
|
console.log('progress', p);
|
||
|
})
|
||
|
.then((result) => {
|
||
|
console.log(result);
|
||
|
});
|
||
|
```
|