识别单张图片程序如下:
# -*-encoding:utf-8-*-
import pytesseract
from PIL import Image
def main():
image = Image.open("./test_images/e.JPG")
# image.show() #打开图片1.jpg
text = pytesseract.image_to_string(image, lang='eng') # 使用简体中文解析图片
print(text)
with open("output.txt", "w") as f: # 将识别出来的文字存到本地
print(text)
f.write(str(text))
if __name__ == '__main__':
main()