您好,为什么pytesseract无法读取此数字,我的结果是:cre
pytesseract.pytesseract.tesseract_cmd = "C:\\Users\\X\\AppData\\Local\\Tesseract-OCR\\tesseract.exe"
im = pyautogui.screenshot(region=(265, 110, 50, 20))
im.save("screenshot.png")
print(pytesseract.image_to_string(Image.open("screenshot.png")))
任何人都知道我可以如何改善结果?
您应该在运行Tesseract之前对图像进行预处理(带有opencv库的python代码):
import cv2
pytesseract.pytesseract.tesseract_cmd = "C:\\Users\\X\\AppData\\Local\\Tesseract-OCR\\tesseract.exe"
im = pyautogui.screenshot(region=(265, 110, 50, 20))
im= cv2.bitwise_not(im)
im.save("screenshot.png")
print(pytesseract.image_to_string(Image.open("screenshot.png")))