Created
January 12, 2020 07:42
-
-
Save e96031413/f3cb180008a4a1fbf09ad6f5059f6058 to your computer and use it in GitHub Desktop.
screening your PC with Python(pillow, numpy, openCV)
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
''' | |
original from https://clay-atlas.com/blog/2019/08/16/python-screening-tutorial/ | |
''' | |
from PIL import ImageGrab | |
import numpy as np | |
import cv2 | |
image = ImageGrab.grab() | |
width, height = image.size | |
fourcc = cv2.VideoWriter_fourcc(*'XVID') | |
video = cv2.VideoWriter('test.avi', fourcc, 25, (width, height)) #File will be saved as "test.avi" | |
while True: | |
img_rgb = ImageGrab.grab() | |
img_bgr = cv2.cvtColor(np.array(img_rgb), cv2.COLOR_RGB2BGR) | |
video.write(img_bgr) | |
cv2.imshow('imm', img_bgr) | |
if cv2.waitKey(1) & 0xFF == ord('q'): #Press "q" key to end the screening | |
break | |
video.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment