0

According to this answer, mss is supposed to be very fast, but there no more a mss.mss.get_pixels() method and mss.mss.grab() is giving me poor results (0.074s on 1440p screen for grab()). I get pretty much same results the most of the time using PIL.ImageGrab.grab() or pyautogui.screenshot(). Is this normal ?

I tried to install 32-bit Python to see if the problem was the 64-bit version, but no results

I also made a simple benchmark

import mss
import PIL
import pyautogui
from time import time

sct = mss.mss()
m = {
    'left': 0,
    'top': 0,
    'width': 2440,
    'height': 1440
}

t = time()
data = sct.grab(m)
t = time() - t
print("MSS grab(): {}".format(t))

t = time()
data = PIL.ImageGrab.grab()
t = time() - t
print("PIL grab(): {}".format(t))

t = time()
data = pyautogui.screenshot()
t = time() - t
print("pyautogui screenshot(): {}".format(t))

Here are the results:

MSS grab(): 0.07446518135070801
PIL grab(): 0.10441708564758301
pyautogui screenshot(): 0.07911845970153809

Edit: MSS is doing better than everything else but i am currently trying to use openCV with it and 70ms to just get a frame is not fast enough

Valink
  • 1
  • 2

0 Answers0