我的 pytesseract 不工作(我需要帮助)
my pytesseract is not working(i need help)
我的计划是制作一个机器人来回答 Messenger 上的机器人
Messenger bot 消息是随机数字或数学问卷 bot
所以我想制作一个可以回答 Messenger 机器人问题的机器人
我编写了这样的代码:
import pyautogui
import pytesseract
from PIL import Image
我想每10秒截图一次
pyautogui.sleep(2)
睡两秒钟让我有时间从 pycharm 切换到 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
结果如下:
Tee oxHj
我尝试使用元组调整图像大小,但我仍然得到错误的结果....我希望你们帮助我,这样我就可以提高我的技能....谢谢
当我反转图像时它起作用了。但是我无法使用 .png 格式,所以我尝试使用 .jpg 格式并且它有效。你可以试试这个。
import pytesseract
from PIL import Image, ImageOps
img = Image.open('f1.jpg')
img = ImageOps.invert(img)
img = pytesseract.image_to_string(img)
print(img)
希望我帮到了你。
我的计划是制作一个机器人来回答 Messenger 上的机器人
Messenger bot 消息是随机数字或数学问卷 bot
所以我想制作一个可以回答 Messenger 机器人问题的机器人
我编写了这样的代码:
import pyautogui
import pytesseract
from PIL import Image
我想每10秒截图一次
pyautogui.sleep(2)
睡两秒钟让我有时间从 pycharm 切换到 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
结果如下:
Tee oxHj
我尝试使用元组调整图像大小,但我仍然得到错误的结果....我希望你们帮助我,这样我就可以提高我的技能....谢谢
当我反转图像时它起作用了。但是我无法使用 .png 格式,所以我尝试使用 .jpg 格式并且它有效。你可以试试这个。
import pytesseract
from PIL import Image, ImageOps
img = Image.open('f1.jpg')
img = ImageOps.invert(img)
img = pytesseract.image_to_string(img)
print(img)
希望我帮到了你。