【问题标题】:Pytesseract cant read numbers on screenshotPytesseract 无法读取屏幕截图上的数字
【发布时间】:2020-06-01 15:09:47
【问题描述】:

你好可以弄清楚为什么pytesseract无法读取这个数字,我的结果:cre

Screenshot

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")))

有人知道我可以如何改善结果吗?

【问题讨论】:

标签: python image ocr python-tesseract


【解决方案1】:

您应该在运行 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")))

【讨论】:

    猜你喜欢
    • 2023-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-29
    • 1970-01-01
    • 2021-04-14
    • 2020-10-23
    • 1970-01-01
    相关资源
    最近更新 更多