侧边栏壁纸
博主头像
silianpan博主等级

Feel no regret for this life.

  • 累计撰写 40 篇文章
  • 累计创建 22 个标签
  • 累计收到 3 条评论

tesseract支持中文识别

silianpan
2022-03-18 / 0 评论 / 0 点赞 / 825 阅读 / 510 字
温馨提示:
本文最后更新于 2022-03-18,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

下载中文识别库

https://github.com/tesseract-ocr/tessdata

image.png

放到tesseract安装目录share目录下

mac:/usr/local/Cellar/tesseract/4.0.0_1/share

安装pytesseract

pip install pytesseract

测试

import tesserocr
import pytesseract
from PIL import Image

image = Image.open('code4.png')

image = image.convert('L')
threshold = 127
table = []
for i in range(256):
    if i < threshold:
        table.append(0)
    else:
        table.append(1)

image = image.point(table, '1')
image.show()

# result = tesserocr.image_to_text(image)
result = pytesseract.image_to_string(Image.open('code5.png'), lang='chi_sim')
print(result)
0

评论区