Created
January 13, 2021 11:45
-
-
Save LewisGet/ca6bf71bbf811af56da58875e11d41fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 cv2 | |
import mss | |
import numpy as np | |
""" | |
1. Install python3 | |
2. Setting python path | |
``` | |
python -m pip install numpy | |
python -m pip install opencv-python | |
python -m pip install mss | |
``` | |
""" | |
screen_offset_x, screen_offset_y = 1920, 40 | |
screen_size_x, screen_size_y = 1920, 1080 | |
capture_size_x, capture_size_y = 600, 320 | |
with mss.mss() as sct: | |
# Part of the screen to capture | |
monitor = { | |
"top": (int) (screen_offset_y + (screen_size_y - capture_size_y) / 2), | |
"left": (int) (screen_offset_x + ((screen_size_x - capture_size_x) / 2)), | |
"width": capture_size_x, "height": capture_size_y | |
} | |
while "Screen capturing": | |
# Get raw pixels from the screen, save it to a Numpy array | |
img = np.array(sct.grab(monitor)) | |
img = cv2.resize(img, (600 *3, 320 *3)) | |
cv2.imshow("zoom", img) | |
# Press "q" to quit | |
if cv2.waitKey(25) & 0xFF == ord("q"): | |
cv2.destroyAllWindows() | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment