-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranscation.py
More file actions
36 lines (22 loc) · 840 Bytes
/
transcation.py
File metadata and controls
36 lines (22 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pynput.mouse import Listener
import pyautogui
import pytesseract
from PIL import Image
def on_click(x, y, button, pressed):
if pressed:
print(f"鼠标点击位置:X={x}, Y={y}")
# with Listener(on_click=on_click) as listener:
# listener.join()
def screen(x, y, width, height, name=""):
# 截取指定区域的图像
screenshot = pyautogui.screenshot(region=(x, y, width, height))
# 保存截图
screenshot.save('screenshot'+name+".png")
def imgToNumber(file_name):
# 打开图像文件
img = Image.open(file_name) # 替换为你的图像文件名
# 配置 Tesseract OCR,只识别数字
custom_config = r'--oem 3 --psm 6 -c tessedit_char_whitelist=0123456789'
# 使用 Tesseract 进行文字识别
text = pytesseract.image_to_string(img, config=custom_config)
return text