这是我的代码。
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
im = Image.open(file location)
print(im)
text = pytesseract.image_to_string(im)
print(text)
输出: PIL.PngImagePlugin.PngImageFile图像模式= RGBA大小= 680x680在0x11B17380E48>] >>
因此,我的图像正在打印,但是当使用函数image_to_string时,仅打印空白字符串。没有错误消息,所以我不确定我在做什么错。
这是我正在使用的图像。
这是我的代码。从PIL导入pytesseract导入图像pytesseract.pytesseract.tesseract_cmd = r“ C:\ Program Files(x86)\ Tesseract-OCR \ tesseract.exe” im = Image.open(文件位置)print(im)文本= ...] >
要显示图像,您需要使用im.show()
,并且要检测文本,请尝试使用计算机字体而不是您自己的笔迹(未经培训的笔迹。