【发布时间】:2021-08-06 10:09:37
【问题描述】:
我正在尝试从图像中检测文本 但由于某些未知原因而失败。
import pytesseract as pt
from PIL import Image
import re
image = Image.open('sample.jpg')
custom_config = r'--oem 3 --psm 7 outbase digits'
number = pt.image_to_string(image, config=custom_config)
print('Number: ', number)
Number: 0 50 100 200 250 # This is the output that I am getting.
Expected --> 0,0,0,0,0,1,0,8
【问题讨论】:
-
嗨 @scee 欢迎来到 SO!您提到转换失败。您能否提供更多有关您收到的错误消息(如果有)的详细信息?你的操作系统是什么?
-
@vvy,我正在使用 macos。转换不一定会失败,但它会产生错误的输出。我会更新问题。
-
在将其发送到tesseract之前,请尝试使用一些形态学操作,例如阈值。 tesseract 在黑白图像中效果更好。
标签: python computer-vision ocr tesseract python-tesseract