tesseract.js
Advanced tools
Comparing version 5.0.3 to 5.0.4
@@ -54,4 +54,8 @@ # API | ||
- `errorHandler` a function to handle worker errors, a quick example is `err => console.error(err)` | ||
- `config` an object of customized options which are set prior to initialization | ||
- This argument allows for setting "init only" Tesseract parameters | ||
- Most Tesseract parameters can be set after a worker is initialized, using either `worker.setParameters` or the `options` argument of `worker.recognize`. | ||
- A handful of Tesseract parameters, referred to as "init only" parameters in Tesseract documentation, cannot be modified after Tesseract is initialized--these can only be set using this argument | ||
- Examples include `load_system_dawg`, `load_number_dawg`, and `load_punc_dawg` | ||
**Examples:** | ||
@@ -61,3 +65,3 @@ | ||
const { createWorker } = Tesseract; | ||
const worker = await createWorker({ | ||
const worker = await createWorker('eng', 1, { | ||
langPath: '...', | ||
@@ -69,3 +73,3 @@ logger: m => console.log(m), | ||
<a name="worker-recognize"></a> | ||
### Worker.recognize(image, options, jobId): Promise | ||
### Worker.recognize(image, options, output, jobId): Promise | ||
@@ -154,2 +158,3 @@ Worker.recognize() provides core function of Tesseract.js as it executes OCR | ||
- `oem` a enum to indicate the OCR Engine Mode you use | ||
- `config` an object of customized options which are set prior to initialization (see details above) | ||
- `jobId` Please see details above | ||
@@ -156,0 +161,0 @@ |
@@ -12,3 +12,3 @@ ## Local Installation | ||
```javascript | ||
const worker = await createWorker({ | ||
const worker = await createWorker('eng', 1, { | ||
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v5.0.0/dist/worker.min.js', | ||
@@ -15,0 +15,0 @@ langPath: 'https://tessdata.projectnaptha.com/4.0.0', |
@@ -7,3 +7,3 @@ # Overview | ||
``` | ||
```javascript | ||
(async () => { | ||
@@ -26,3 +26,3 @@ const worker = await Tesseract.createWorker('eng'); | ||
``` | ||
```javascript | ||
const scheduler = Tesseract.createScheduler(); | ||
@@ -29,0 +29,0 @@ |
{ | ||
"name": "tesseract.js", | ||
"version": "5.0.3", | ||
"version": "5.0.4", | ||
"description": "Pure Javascript Multilingual OCR", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -252,5 +252,5 @@ /** | ||
// In the latter case we convert to config file text here | ||
if (typeof config === 'object') { | ||
if (config && typeof config === 'object' && Object.keys(config).length > 0) { | ||
configStr = JSON.stringify(config).replace(/,/g, '\n').replace(/:/g, ' ').replace(/["'{}]/g, ''); | ||
} else { | ||
} else if (config && typeof config === 'string') { | ||
configStr = config; | ||
@@ -264,3 +264,3 @@ } | ||
api = new TessModule.TessBaseAPI(); | ||
let status = api.Init(null, langs, oem); | ||
let status = api.Init(null, langs, oem, configFile); | ||
if (status === -1) { | ||
@@ -294,3 +294,3 @@ // Cache is deleted if initialization fails to avoid keeping bad data in cache | ||
await loadLanguage({ workerId, payload: { langs: loadLanguageLangsWorker, options: loadLanguageOptionsWorker } }); // eslint-disable-line max-len | ||
status = api.Init(null, langs, oem); | ||
status = api.Init(null, langs, oem, configFile); | ||
if (status === -1) { | ||
@@ -297,0 +297,0 @@ log('Language data refresh failed.'); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1451995