-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path058.tesseract.js 图片转文字.html
30 lines (29 loc) · 2.15 KB
/
058.tesseract.js 图片转文字.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
30
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./assets/global.css" />
</head>
<body>
<script type="module">
import Tesseract from "https://gcore.jsdelivr.net/npm/tesseract.js@5/dist/tesseract.esm.min.js";
(async () => {
const worker = await Tesseract.createWorker("eng", 1, {
corePath:
"https://gcore.jsdelivr.net/npm/tesseract.js-core@5/tesseract-core-simd-lstm.wasm.js",
workerPath:
"https://gcore.jsdelivr.net/npm/tesseract.js@5/dist/worker.min.js",
langPath:
"https://gcore.jsdelivr.net/npm/@tesseract.js-data/eng/4.0.0_best_int",
});
const ret = await worker.recognize(
"https://tesseract.projectnaptha.com/img/eng_bw.png"
);
console.log(ret.data.text);
await worker.terminate();
})();
</script>
</body>
</html>