Pycharm + Anaconda 下 tesseract-ocr的安装配置
步骤1:
去网站 https://digi.bib.uni-mannheim.de/tesseract/ 下载exe文件,然后一路'next',选择安装目录到指定文件夹,最后确定。
步骤2:
设置环境变量:
2.1 添加用户环境变量
2.2 添加系统环境变量
2.3 新建系统环境变量
步骤3:
3.1 在cmd 下 pip install pytesseract 安装对应的python库文件
3.2 打开如下py文件,修改绝对路径
步骤4:
测试文件:
import cv2
import pytesseract
img = cv2.imread('./images/test.png')
test = pytesseract.image_to_string(img)
print(test)
test.png
result:
This is a lot of 12 point text to test the
ocr code and see if it works on all types
of file format.
The quick brown dog jumped over the
lazy fox. The quick brown dog jumped
over the lazy fox. The quick brown dog
jumped over the lazy fox. The quick
brown dog jumped over the lazy fox.