OCR 和 pytesseract 检测图像中的数字

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

currentbid.png

我正在尝试检测此图像中的数字,它给了我字母或错误的数字。

这是我的图像,我正在尝试检测数字,我尝试了很多使用超正方体进行灰度和反转的东西,但似乎没有任何效果,它总是给我诸如 ADA 之类的字母或错误的数字,比如如果图像说 98.7M 它会给我19 9947 )M,我认为这个句号把它弄乱了,但我无法删除它或更改字体。我该如何修复或训练它?

这是我当前的代码:

pyautogui.screenshot("bidpossible.png", region=(900, 310, 450, 60)) #bidpossible
originalImage = cv2.imread('bidpossible.png')


grayImage = cv2.cvtColor(originalImage, cv2.COLOR_BGR2GRAY)

(_, blackAndWhiteImage) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY_INV)

custom_config = r'--psm 8'


text = pytesseract.image_to_string(blackAndWhiteImage, config=custom_config)
print('Extracted Text: ', text)
python ocr tesseract pyautogui python-tesseract
1个回答
0
投票

使用尝试获得浅蓝色的滤镜怎么样?


grayImage[(grayImage<210)] = 255
grayImage[(grayImage>210) & (grayImage<230)] = 0


custom_config = f'--psm 7'
text = pytesseract.image_to_string(grayImage, config=custom_config)
print(f'Extracted Text: ', text)
© www.soinside.com 2019 - 2024. All rights reserved.