Python实现从图片提取文字
1.Python3的pillow、pytesseract包 可使用pip install pillow、pip install pytesseract命令安装
识别引擎tesseract-ocr下载安装加入环境变量,下载chi_sim.traineddata放在Tesseract-OCR\tessdata目录下
2.代码
- from PIL import Image
- import pytesseract
- image = Image.open('a20170914155348.jpg')
- imtext = pytesseract.image_to_string(image,lang='chi_sim')
- print(imtext)
3.效果