ocr.py 406 B

12345678910111213141516
  1. import pytesseract
  2. from PIL import Image, ImageGrab
  3. import tkinter as tk
  4. import threading
  5. print(pytesseract.pytesseract.tesseract_cmd)
  6. # 定义截图和OCR识别函数
  7. def capture_and_ocr(region):
  8. # 读取屏幕截图
  9. screenshot = ImageGrab.grab(bbox=region)
  10. # 使用Tesseract进行文字识别
  11. result = pytesseract.image_to_string(screenshot, lang='chi_sim')
  12. return result