我正在尝试使用 python 创建实时 OCRmss和pytesseract。
到目前为止,我已经能够捕获整个屏幕,其 FPS 稳定为 30。如果我想捕获大约 500x500 的较小区域,我已经能够获得 100+ FPS。
然而,一旦我添加这行代码,text = pytesseract.image_to_string(img)FPS 就会飙升 0.8。有什么方法可以优化我的代码以获得更好的 FPS?该代码还能够检测文本,只是速度非常慢。
from mss import mss
import cv2
import numpy as np
from time import time
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\\Users\\Vamsi\\AppData\\Local\\Programs\\Tesseract-OCR\\tesseract.exe'
with mss() as sct:
# Part of the screen to capture
monitor = {"top": 200, "left": 200, "width": 500, "height": 500}
while "Screen capturing":
begin_time = time()
# Get raw pixels from the screen, save it to …Run Code Online (Sandbox Code Playgroud)