Last active
November 22, 2021 02:31
-
-
Save badjano/6bda9f53d6d7591d70a0b223cbd21766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
from PIL import ImageGrab | |
from screeninfo import get_monitors | |
monitors = [] | |
for m in get_monitors(): | |
monitors.append((m.x, m.y, m.x + m.width, m.y + m.height)) | |
bbox = monitors[0] | |
while True: | |
img = ImageGrab.grab(bbox=bbox) | |
img_np = np.array(img) | |
frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB) | |
cv2.imshow("Screen", frame) | |
key = cv2.waitKey(1) | |
for i, m in enumerate(monitors): | |
if key == i + 49: | |
bbox = m | |
if key == 27: | |
break | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment