Issue
my plan is to make a bot that will answer a bot on messenger
the messenger bot messages are randomized number or a math questionaire bot
so i want to make a bot that will answer the messenger bots qustions
i made a code like this:
import pyautogui
import pytesseract
from PIL import Image
i want to take screenshot every 10 seconds
pyautogui.sleep(2)
sleep for two seconds to give me time to switch from pycharm to messenger
pyautogui.screenshot('x_value.png', confidence=0.8)
img = Image.open('x_value.png')
img = pytesseract.image_to_string(img)
print(img)
here is the taken screenshot by my bot
here is the result:
Tee oxHj
i tried resizing the image using tuple but I still get the wrong result....i hope ypu guys help me so i can improve my skills....thank you
Solution
It worked when I inverted the image. But I wasn't able to use .png format so I tried in .jpg format and it worked. You can try this.
import pytesseract
from PIL import Image, ImageOps
img = Image.open('f1.jpg')
img = ImageOps.invert(img)
img = pytesseract.image_to_string(img)
print(img)
Hope I helped.
Answered By - Aunny
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.