forked from jeromewu/tesseract.js-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
29 lines (27 loc) · 864 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<!-- https://electronjs.org/docs/tutorial/security#csp-meta-tag -->
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<script>
const { createWorker } = require('tesseract.js');
const path = require('path');
const worker = createWorker({
cachePath: path.join(__dirname, 'lang-data'),
logger: m => console.log(m),
});
(async () => {
await worker.load();
await worker.loadLanguage('eng');
await worker.initialize('eng');
const { data: { text } } = await worker.recognize(path.join(__dirname, 'images', 'testocr.png'));
console.log(text);
await worker.terminate();
})();
</script>
</body>
</html>