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.
38 lines
1.1 KiB
38 lines
1.1 KiB
2 years ago
|
<html>
|
||
|
<head>
|
||
|
<script src="/dist/tesseract.dev.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<textarea id="message">Working...</textarea>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
|
||
|
// This example provides a standardized performance benchmark.
|
||
|
// It does not accept user input.
|
||
|
|
||
2 years ago
|
const { createWorker } = Tesseract;
|
||
2 years ago
|
|
||
2 years ago
|
(async () => {
|
||
2 years ago
|
const worker = await createWorker();
|
||
2 years ago
|
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>
|