Compare commits
39 Commits
dependabot
...
master
Author | SHA1 | Date |
---|---|---|
Réda Housni Alaoui | 80aef15861 | 2 years ago |
Balearica | 263dbb87b1 | 2 years ago |
Balearica | c9200839df | 2 years ago |
Balearica | 1b87e30ae3 | 2 years ago |
Balearica | bce7cd84fe | 2 years ago |
Balearica | 2c77f33461 | 2 years ago |
Balearica | d8b29522c4 | 2 years ago |
Balearica | dd6c40b681 | 2 years ago |
Balearica | 5ff17fdeb1 | 2 years ago |
Balearica | 363690a421 | 2 years ago |
Balearica | b64eba3db0 | 2 years ago |
Balearica | 85e73216be | 2 years ago |
Balearica | b419e45114 | 2 years ago |
Balearica | ea33463120 | 2 years ago |
Balearica | 90c8d99b3c | 2 years ago |
Balearica | 0e368c69d6 | 2 years ago |
Balearica | ba394673bd | 2 years ago |
Balearica | 44d322e6ff | 2 years ago |
Balearica | e3c4a6bc6e | 2 years ago |
Balearica | f372818146 | 2 years ago |
Balearica | 8b567609e3 | 2 years ago |
Balearica | 13b95f6371 | 2 years ago |
Balearica | a9ac00ccac | 2 years ago |
Balearica | 75ddd63041 | 2 years ago |
Balearica | 1136e0a941 | 2 years ago |
Balearica | 2e478bd8a5 | 2 years ago |
WintrySnowman | 67848464ac | 2 years ago |
Balearica | be956cd889 | 2 years ago |
Balearica | 61d0e553c6 | 2 years ago |
Balearica | 74be03c5b9 | 2 years ago |
Balearica | 9442d9cb69 | 2 years ago |
Your Name | 6aba9599ec | 2 years ago |
Your Name | 58d28944d3 | 2 years ago |
Balearica | a8287a99aa | 2 years ago |
Balearica | 66085a7d70 | 2 years ago |
Susan Cheng | 50a53f51d9 | 3 years ago |
Andrei Alecu | 01e8335768 | 3 years ago |
jeromewu | adcb5b8759 | 3 years ago |
Jerome Wu | 294ced5c85 | 4 years ago |
34 changed files with 12480 additions and 5844 deletions
@ -1,17 +1,18 @@
@@ -1,17 +1,18 @@
|
||||
# Image Format |
||||
|
||||
Support Format: **bmp, jpg, png, pbm** |
||||
The main Tesseract.js functions (ex. recognize, detect) take an `image` parameter. The image formats and data types supported are listed below. |
||||
|
||||
The main Tesseract.js functions (ex. recognize, detect) take an `image` parameter, which should be something that is like an image. What's considered "image-like" differs depending on whether it is being run from the browser or through NodeJS. |
||||
Support Image Formats: **bmp, jpg, png, pbm, webp** |
||||
|
||||
On a browser, an image can be: |
||||
- an `img`, `video`, or `canvas` element |
||||
- a `File` object (from a file `<input>`) |
||||
- a `Blob` object |
||||
- a path or URL to an accessible image |
||||
- a base64 encoded image fits `data:image\/([a-zA-Z]*);base64,([^"]*)` regexp |
||||
For browser and Node, supported data types are: |
||||
- string with base64 encoded image (fits `data:image\/([a-zA-Z]*);base64,([^"]*)` regexp) |
||||
- buffer |
||||
|
||||
In Node.js, an image can be |
||||
- a path to a local image |
||||
- a Buffer storing binary image |
||||
- a base64 encoded image fits `data:image\/([a-zA-Z]*);base64,([^"]*)` regexp |
||||
For browser only, supported data types are: |
||||
- `File` or `Blob` object |
||||
- `img` or `canvas` element |
||||
|
||||
For Node only, supported data types are: |
||||
- string containing a path to local image |
||||
|
||||
Note: images must be a supported image format **and** a supported data type. For example, a buffer containing a png image is supported. A buffer containing raw pixel data is not supported. |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
<html> |
||||
<head> |
||||
<script src="/dist/tesseract.dev.js"></script> |
||||
</head> |
||||
<body> |
||||
<textarea id="message">Working...</textarea> |
||||
|
||||
<script> |
||||
const { createWorker } = Tesseract; |
||||
const worker = createWorker(); |
||||
(async () => { |
||||
await worker.load(); |
||||
await worker.loadLanguage('eng'); |
||||
await worker.initialize('eng'); |
||||
|
||||
const fileArr = ["../data/meditations.jpg", "../data/tyger.jpg", "../data/testocr.png"]; |
||||
let timeTotal = 0; |
||||
for (let file of fileArr) { |
||||
let time1 = Date.now(); |
||||
for (let i=0; i < 10; i++) { |
||||
await worker.recognize(file); |
||||
} |
||||
let time2 = Date.now(); |
||||
const timeDif = (time2 - time1) / 1e3; |
||||
timeTotal += timeDif; |
||||
document.getElementById('message').innerHTML += "\n" + file + " [x10] runtime: " + timeDif + "s"; |
||||
} |
||||
document.getElementById('message').innerHTML += "\nTotal runtime: " + timeTotal + "s"; |
||||
|
||||
})(); |
||||
</script> |
||||
</body> |
||||
</html> |
After Width: | Height: | Size: 1011 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 408 KiB |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
const path = require('path'); |
||||
const { createWorker } = require('../../'); |
||||
|
||||
const worker = createWorker(); |
||||
|
||||
(async () => { |
||||
await worker.load(); |
||||
await worker.loadLanguage('eng'); |
||||
await worker.initialize('eng'); |
||||
const fileArr = ["../data/meditations.jpg", "../data/tyger.jpg", "../data/testocr.png"]; |
||||
let timeTotal = 0; |
||||
for (let file of fileArr) { |
||||
let time1 = Date.now(); |
||||
for (let i=0; i < 10; i++) { |
||||
await worker.recognize(file) |
||||
} |
||||
let time2 = Date.now(); |
||||
const timeDif = (time2 - time1) / 1e3; |
||||
timeTotal += timeDif; |
||||
|
||||
console.log(file + " [x10] runtime: " + timeDif + "s"); |
||||
} |
||||
console.log("Total runtime: " + timeTotal + "s"); |
||||
|
||||
await worker.terminate(); |
||||
})(); |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
import commonjs from "@rollup/plugin-commonjs"; |
||||
|
||||
export default [ |
||||
{ |
||||
input: "dist/tesseract.min.js", |
||||
output: { |
||||
file: "dist/tesseract.esm.min.js", |
||||
format: "esm", |
||||
banner: "/* eslint-disable */", |
||||
}, |
||||
plugins: [commonjs()], |
||||
}, |
||||
]; |
After Width: | Height: | Size: 1011 B |
After Width: | Height: | Size: 3.7 KiB |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue