|Python|3.9.2 |
|-pytesseract 客户端-|-5.0-|
| pytesseract 依赖库| 0.3.8 |
| 语言包|chi_sim.traineddata、chi_sim_vert.traineddata |
CSDN资源地址:https://download.csdn.net/download/yanxilou/76285648
客户端:https://github.com/UB-Mannheim/tesseract/wiki
语言包:https://github.com/tesseract-ocr/tessdata
依赖库: pip install pytesseract
opencv ocr。语言包放到这里:
修改cmd路径:
from PIL import Image
import pytesseractdef read_text(text_path):# 打开图片im = Image.open(text_path)# 转化为8bit的黑白图片imgry = im.convert('L')# 二值化,采用阈值分割算法,threshold为分割点threshold = 140table = []for j in range(256):if j < threshold:table.append(0)else:table.append(1)out = imgry.point(table, '1')# 识别文本text = pytesseract.image_to_string(out, lang="chi_sim", config='--psm 6')return text
if __name__ == '__main__':print(read_text(r'.\img\demo.png'))
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态