Your Name
2 years ago
5 changed files with 63 additions and 0 deletions
@ -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,30 @@ |
|||||||
|
#!/usr/bin/env node
|
||||||
|
const path = require('path'); |
||||||
|
const { createWorker } = require('../../'); |
||||||
|
|
||||||
|
const worker = createWorker({ |
||||||
|
// logger: m => console.log(m)
|
||||||
|
}); |
||||||
|
|
||||||
|
(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(); |
||||||
|
})(); |
Loading…
Reference in new issue