0
我正在尝试使Tesseract.js工作。tesseract.js示例代码不起作用
我已经从网上取了一个非常简单的代码,明确声明为工作,但事实并非如此。
<html>
<head>
<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script>
<title>Tesseract Test</title>
</head>
<body>
<label for="fileInput">Choose File to OCR:</label>
<input type="file" id="fileInput" name="fileInput"/>
<br />
<br />
<div id="document-content">
</div>
</body>
<script>
document.addEventListener('DOMContentLoaded', function(){
var fileInput = document.getElementById('fileInput');
fileInput.addEventListener('change', handleInputChange);
});
function handleInputChange(event){
var input = event.target;
var file = input.files[0];
console.log(file);
Tesseract.recognize(file)
.progress(function(message){
console.log(message);
})
.then(function(result){
var contentArea = document.getElementById('document-content');
console.log(result);
})
.catch(function(err){
console.error(err);
});
}
</script>
</html>
这是他们的主要网站:http://tesseract.projectnaptha.com/
由于某些原因,我有记录控制台的问题,但它正在显示contentArea中的内容。谢谢 –
也,你知道为什么它只适用于Firefox,但不在浏览器或铬? –
这里是我的小提琴:https://jsfiddle.net/khrismuc/8aL31upr/在Chrome 54和IE 11中正常工作。你检查了控制台吗? –