我一直在试图得到一些数字,从 此图 但 pytesseract 只给我随机的字母。我试过很多-psm选项,但似乎没有用。这是我使用的代码。
from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open("Test.png"), config="--psm 6"))
我怎么做才能让它更成功?
试试这个代码。
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