1.下载

tesseract下载地址:https://digi.bib.uni-mannheim.de/tesseract/

Tesseract 4使用教程(一)

其中文件名中带有dev的为开发版本,不带dev的为稳定版本,可以选择下载不带dev的版本。

2.双击安装

Tesseract 4使用教程(一)

 

 

 一路next 到 如下界面

Tesseract 4使用教程(一)

 

 

 选择需要的语言,选中后在安装过程会下载勾选的语言,可能需要FQ,下载不下来只能单独下在

3.安装完成后,pip需要的python库pytesseract

pip install pytesseract

4.配置环境变量,将Tesseract-OCR的安装路径加到环境变量中

Tesseract 4使用教程(一)

 

 

 5.配置TESSDATA_PREFIX环境,将Tesseract-OCR安装路径的tessdata加入到环境中,不然有可能会报错

Tesseract 4使用教程(一)

Tesseract 4使用教程(一)

 6.如果你在安装时没能成功安装勾选的语言包,可从如下地址下载

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

Tesseract 4使用教程(一)

 

 

 中文简体,中文繁体

7.将语言包放到tessdata文件夹下即可

Tesseract 4使用教程(一)

 

 

 8.修改pytesseract.py

tesseract_cmd = '本地的安装路径'

Tesseract 4使用教程(一)

 

 

 9.重启一下

10.测试

from PIL import Image
import pytesseract
import cv2
img = cv2.imread("wz.jpg", cv2.IMREAD_UNCHANGED)
text = pytesseract.image_to_string((Image.open("wz.jpg")), lang='chi_sim')
print(text)
cv2.imshow("img", img)
cv2.waitKey(-1)

效果:

Tesseract 4使用教程(一)

 

相关文章:

  • 2021-07-22
  • 2021-04-30
  • 2022-12-23
  • 2021-04-08
  • 2021-09-21
  • 2021-12-07
  • 2021-07-04
  • 2021-08-18
猜你喜欢
  • 2022-12-23
  • 2021-11-15
  • 2022-01-17
  • 2022-01-06
  • 2021-08-25
  • 2021-09-27
  • 2021-07-02
相关资源
相似解决方案