sudo apt-get install tesseract-ocr sudo apt-get install python-imaging pip install pytesseract 中文库 sudo apt-get install tesseract-ocr-chi-sim
import pytesseractfrom PIL import Image im=Image.open('/home/chenyang/PycharmProjects/python_ocr/1.png')print(pytesseract.image_to_string(im,lang='chi_sim'))
如果图片有噪点
可以进行二值化处理
import pytesseractimport cv2from PIL import Image image_text=cv2.imread("/home/chenyang/PycharmProjects/python_ocr/1.png")image_text1=image_text>180image_text[image_text1]=255image_text1=image_text<130image_text[image_text1]=0im=Image.fromarray(image_text)print(pytesseract.image_to_string(im,lang='chi_sim'))