sudo add-apt-repository ppa:alex-p/tesseract-ocr
pip install pytesseract
# 安装OCR引擎
sudo apt-get install tesseract-ocr
# 安装训练数据(equ为数学公式包)
sudo apt-get install tesseract-ocr-eng tesseract-ocr-chi-sim tesseract-ocr-equ
pytesseract是google做的ocr库,可以识别图片中的文字.
import pytesseract
from PIL import Image
image = Image.open("1.jpg")
text = pytesseract.image_to_string(image,lang='chi_sim') #使用简体中文解析图片
print(text)