尽管尝试了所有的-psm,但Pytesseract还是不能识别数字。

问题描述 投票:-1回答:1

我一直在试图得到一些数字,从 此图 但 pytesseract 只给我随机的字母。我试过很多-psm选项,但似乎没有用。这是我使用的代码。

from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open("Test.png"), config="--psm 6"))

我怎么做才能让它更成功?

python python-3.x python-imaging-library python-tesseract
1个回答
1
投票

试试这个代码。

import cv2
import pytesseract

img = cv2.imread("vuK1z.png", 0)
thresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV)[1]
custom_config = r'-l eng --oem 3 --psm 6 '
text = pytesseract.image_to_string(thresh, config=custom_config)
print(text)

结果是

550,000
© www.soinside.com 2019 - 2024. All rights reserved.