Currently my program searches for the picture of the word Opponents on the 
screen then moves a bit a takes a picture of the number below it.

When using pytesseract to try and convert the photo of the single number to 
a string it often grabs random characters such as "va, or "a" instead of 
the number causing the line which converts the string to an integer to fail.

Above is a attached screenshot of what my program is currently taking a 
picture of. Any help to give me an idea on how to better pre-process the 
screenshot so it gets read with better accuracy would be much appreciated 
as I'm new to this. 

{Part of Code I'm Using}

import pyautogui
import time
import pytesseract
import cv2
import imutils
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = r'S:\Tesseract\tesseract.exe'

opponent= None
while opponent is None:
    opponent=pyautogui.locateOnScreen(r'S:\Downloads 2\oppon.png', 
grayscale = True, confidence=.8)
print(opponent)
x=opponent[0]
y=opponent[1]
w=opponent[2]
h=opponent[3]
x=x+40
y=y+14
w=w-72

if opponent is not None:
    im2 = pyautogui.screenshot(r'S:\Downloads 2\my_screenshot2.png', 
region=(x,y,w,h))
    newim2=im2.resize((500,360), Image.ANTIALIAS)
    newim2.save(r'S:\Downloads 2\my_screenshot2.png', "PNG", optimize=True)
    
loopTest=(pytesseract.image_to_string(newim2, config='--psm 8 --oem 3'))
print(loopTest)
loopTest=int(loopTest)

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tesseract-ocr+unsubscr...@googlegroups.com.
To post to this group, send email to tesseract-ocr@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/039f25c3-d211-406e-8012-92a8bbe7edf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to