python - tesseract-ocr

1. 安装tesseract-ocr

下载链接:https://digi.bib.uni-mannheim.de/tesseract/
安装后添加环境变量
image
测试安装情况
image

2. 安装pytesseract

pip3 install pytesseract -i https://pypi.tuna.tsinghua.edu.cn/simple

3.添加中文包

下载链接:https://github.com/tesseract-ocr/tessdata_best
chi_sim.traineddata 为简体中文训练集
下载后放在 **\Tesseract-OCR\tessdata 目录

4. 脚本如下

from PIL import Image
import pytesseract
import cv2 as cv
img = Image.open('test.png')
pytesseract.pytesseract.tesseract_cmd = r'C:/Program Files/Tesseract-OCR/tesseract.exe'
res = pytesseract.image_to_string(img, lang='chi_sim')
print(res)

识别效果
image
image

posted @   wstong  阅读(78)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示