Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 12, 2020 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e96031413/f3cb180008a4a1fbf09ad6f5059f6058 to your computer and use it in GitHub Desktop.
Save e96031413/f3cb180008a4a1fbf09ad6f5059f6058 to your computer and use it in GitHub Desktop.
screening your PC with Python(pillow, numpy, openCV)
'''
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