0

I'm trying to extract word from the screen using pytesseract.

the word is white and the background of it is in other colors.

screenshot image

the word of the screenshot is always white but background might be changed.

A straightforward method using pytesseract with image array

sct = mss()
image = np.array(sct.grab(mon))
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
image = cv2.Canny(image, 25, 50)
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
text = pytesseract.image_to_string(img, lang='eng', config='--oem 3 --psm 10 -c tessedit_char_whitelist=abcdefghijklmnopqrstuvwxyz')
try:
    return text.strip()[0].lower()
except IndexError as err:
    print(err)
    return ''

0 Answers0