图片文字识别

<script src='https://unpkg.com/tesseract.js@v2.1.0/dist/tesseract.min.js'></script>
<script>
function recognize_image(){
    document.getElementById('transcription').innerText = "(等待中...)"
    Tesseract.recognize(
      '33.png',
      'chi_sim',
      { logger: m => console.log(m) }
    ).then(({ data: { text } }) => {
      console.log(text);
      document.getElementById('transcription').className = "done"
        document.getElementById('transcription').innerText = text;
    })
</script>
 <div id="main">
 <img id="pic" src="33.png" onload = "recognize_image()">
 <div id="transcription"></div>
 </div>

You may also like...

发表评论

邮箱地址不会被公开。 必填项已用*标注