-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfps_test.py
39 lines (30 loc) · 962 Bytes
/
fps_test.py
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
37
38
39
import sys, time
import cv2 as cv
import numpy as np
from mss import mss
from settings import Settings
from setup import setup
import pyautogui as pag
from loguru import logger
config = Settings()
setup(config)
with mss() as sct:
# Part of the screen to capture
# monitor = {"top": 0, "left": 0, "width": 1000, "height": 570}
monitor = config.get_monitor()
logger.info(monitor)
while "Screen capturing":
last_time = time.time()
# Get raw pixels from the screen, save it to a Numpy array
img = np.array(sct.grab(monitor))
# Display the picture
cv.imshow("OpenCV/Numpy normal", img)
# Display the picture in grayscale
# cv2.imshow('OpenCV/Numpy grayscale',
# cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))
logger.info("fps: {}".format(1 / (time.time() - last_time)))
logger.info(pag.position())
# Press "q" to quit
if cv.waitKey(25) & 0xFF == ord("q"):
cv.destroyAllWindows()
break