恶魔没什么打开手机打开手机的空间大街上看见的开始速度速度速度速度是且我企鹅哦速度速度 速度速度恶魔没什么打开手机打开手机的空间大街上看见的开始速度速度速度速度是且我企鹅哦速度速度 速度速度恶魔没什么打开手机打开手机的空间大街上看见的开始速度速度速度速度是且我企鹅哦速度速度 速度速度
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Basic Usage</title>
<script src='https://unpkg.com/tesseract.js@2.1.4/dist/tesseract.min.js'></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.9.1/vconsole.min.js"></script>
<script>
const vconsole = new window.VConsole()
</script>
</head>
<body>
<script>
</script>
<input type="file" id="input" onchange="selectFile()">
<br>
<p id="print"></p>
<script>
function selectFile () {
const file = document.querySelector('#input')
console.log('file:', file.files)
printFile(file.files[0])
function printFile(file) {
var reader = new FileReader();
reader.onload = function(evt) {
console.log(evt.target.result);
work(evt.target.result)
};
reader.readAsDataURL(file);
}
}
const exampleImage = 'ocr.png';
const worker = Tesseract.createWorker({
logger: m => console.log(m)
});
Tesseract.setLogging(true);
// work(exampleImage);
async function work(exampleImage) {
await worker.load();
await worker.loadLanguage('chi_sim');
await worker.initialize('chi_sim');
// await worker.loadLanguage('eng');
// await worker.initialize('eng');
let result = await worker.detect(exampleImage);
console.log(result.data);
result = await worker.recognize(exampleImage);
console.log(result.data);
document.getElementById("print")
.innerHTML = result.data.text;
await worker.terminate();
}
</script>
</body>
</html>