试图检测图像中的文本,但出于某种原因,pytesseract在尝试检测文本时仅返回三(3)条空行,在我的示例中为试图提取“ BNC 116”。
# https://stackabuse.com/pytesseract-simple-python-optical-character-recognition/
from PIL import Image
import pytesseract
def ocr_core(filename):
text = pytesseract.image_to_string(Image.open(filename))
return text
directory = 'images/'
print(ocr_core(directory + 'car.png'))
我已经包含了指向代码作者的链接。