tesseract.js
Advanced tools
Comparing version 2.0.0-alpha.7 to 2.0.0-alpha.8
@@ -5,2 +5,7 @@ # Tesseract.js Examples | ||
Example repositories: | ||
- Offline version: https://github.com/jeromewu/tesseract.js-offline | ||
- With Vue (similar with React/Angular): https://github.com/jeromewu/tesseract-vue-app | ||
### basic | ||
@@ -7,0 +12,0 @@ |
@@ -9,1 +9,7 @@ FAQ | ||
Tesseract.js will first check if \*.traineddata already exists. (browser: [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API), Node.js: fs, in the folder you execute the command) If the \*.traineddata doesn't exist, it will fetch \*.traineddata.gz from [tessdata](https://github.com/naptha/tessdata), ungzip and store in IndexedDB or fs, you can delete it manually and it will download again for you. | ||
## How can I train my own \*.traineddata? | ||
For tesseract.js v2, check [TrainingTesseract 4.00](https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00) | ||
For tesseract.js v1, check [Training Tesseract 3.03–3.05](https://github.com/tesseract-ocr/tesseract/wiki/Training-Tesseract-3.03%E2%80%933.05) |
{ | ||
"name": "tesseract.js", | ||
"version": "2.0.0-alpha.7", | ||
"version": "2.0.0-alpha.8", | ||
"description": "Pure Javascript Multilingual OCR", | ||
@@ -15,4 +15,4 @@ "main": "src/index.js", | ||
"test:browser-tpl": "mocha-headless-chrome -a incognito -a no-sandbox -a disable-setuid-sandbox -t 300000", | ||
"test:browser:detect": "npm run test:browser-tpl -- -f ./tests/browser/detect.test.html", | ||
"test:browser:recognize": "npm run test:browser-tpl -- -f ./tests/browser/recognize.test.html", | ||
"test:browser:detect": "npm run test:browser-tpl -- -f ./tests/detect.test.html", | ||
"test:browser:recognize": "npm run test:browser-tpl -- -f ./tests/recognize.test.html", | ||
"lint": "eslint src" | ||
@@ -29,2 +29,6 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.5", | ||
"@babel/preset-env": "^7.4.5", | ||
"acorn": "^6.1.1", | ||
"babel-loader": "^8.0.6", | ||
"cors": "^2.8.5", | ||
@@ -48,2 +52,3 @@ "eslint": "^5.9.0", | ||
"dependencies": { | ||
"axios": "^0.18.0", | ||
"check-types": "^7.4.0", | ||
@@ -54,3 +59,3 @@ "is-url": "1.2.2", | ||
"tesseract.js-core": "^2.0.0-beta.10", | ||
"tesseract.js-utils": "^1.0.0-beta.5" | ||
"tesseract.js-utils": "^1.0.0-beta.6" | ||
}, | ||
@@ -57,0 +62,0 @@ "repository": { |
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const common = require('./webpack.config.common'); | ||
@@ -7,2 +8,3 @@ const genConfig = ({ | ||
}) => ({ | ||
...common, | ||
mode: 'development', | ||
@@ -9,0 +11,0 @@ entry, |
const path = require('path'); | ||
const common = require('./webpack.config.common'); | ||
@@ -6,2 +7,3 @@ const genConfig = ({ | ||
}) => ({ | ||
...common, | ||
mode: 'production', | ||
@@ -8,0 +10,0 @@ devtool: 'source-map', |
@@ -12,2 +12,3 @@ /** | ||
const resolveURL = require('resolve-url'); | ||
const axios = require('axios'); | ||
const { defaultOptions } = require('../common/options'); | ||
@@ -43,3 +44,3 @@ const { version } = require('../../package.json'); | ||
* video HTMLElement: extract image source from poster attribute | ||
* canvas HTMLElement: extract image data by converting to Blob | ||
* canvas HTMLElement: extract image data by converting to Blob | ||
* File instance: data from <input type="file" /> | ||
@@ -50,4 +51,6 @@ * @returns {array} binary image in array format | ||
if (check.string(image)) { | ||
return fetch(resolveURL(image)) | ||
.then(resp => resp.arrayBuffer()); | ||
return axios.get(resolveURL(image), { | ||
responseType: 'arraybuffer', | ||
}) | ||
.then(resp => resp.data); | ||
} | ||
@@ -94,3 +97,3 @@ if (check.instance(image, HTMLElement)) { | ||
} | ||
} | ||
}; | ||
@@ -97,0 +100,0 @@ /* |
@@ -36,3 +36,3 @@ /** | ||
global.TesseractCore = global.TesseractCoreWASM; | ||
} else if (check.not.undefined(global.TesseractCoreASM)){ | ||
} else if (check.not.undefined(global.TesseractCoreASM)) { | ||
global.TesseractCore = global.TesseractCoreASM; | ||
@@ -48,3 +48,3 @@ } else { | ||
writeFile: (path, data, type) => { | ||
self.postMessage({ | ||
postMessage({ | ||
jobId: 'Download', | ||
@@ -51,0 +51,0 @@ path, |
@@ -11,3 +11,2 @@ /** | ||
const { readImage, loadLang } = require('tesseract.js-utils'); | ||
const check = require('check-types'); | ||
const pdfTTF = require('./pdf-ttf'); | ||
@@ -63,3 +62,3 @@ const dump = require('./dump'); | ||
* @access private | ||
* @param {string} lang - lang string for Init() | ||
* @param {string} lang - lang string for Init() | ||
* @param {object} customParams - an object of params | ||
@@ -115,3 +114,3 @@ */ | ||
} | ||
if (pdf_auto_download) { | ||
@@ -123,3 +122,3 @@ adapter.writeFile(`${pdf_name}.pdf`, data, 'application/pdf'); | ||
return files; | ||
} | ||
}; | ||
@@ -198,2 +197,13 @@ /** | ||
loadLanguage({ lang, options }, res) | ||
.catch((e) => { | ||
if (e instanceof DOMException) { | ||
/* | ||
* For some reason google chrome throw DOMException in loadLang, | ||
* while other browser is OK, for now we ignore this exception | ||
* and hopefully to find the root cause one day. | ||
*/ | ||
} else { | ||
throw e; | ||
} | ||
}) | ||
.then(() => { | ||
@@ -200,0 +210,0 @@ const progressUpdate = (progress) => { |
@@ -12,3 +12,3 @@ /** | ||
const fs = require('fs'); | ||
const fetch = require('node-fetch'); | ||
const axios = require('axios'); | ||
const isURL = require('is-url'); | ||
@@ -33,4 +33,6 @@ const { fork } = require('child_process'); | ||
if (isURL(image)) { | ||
return fetch(image) | ||
.then(resp => resp.arrayBuffer()); | ||
return axios.get(image, { | ||
responseType: 'arraybuffer', | ||
}) | ||
.then(resp => resp.data); | ||
} | ||
@@ -37,0 +39,0 @@ return readFile(image); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
2284
1
1356882
7
20
44
+ Addedaxios@^0.18.0