Awesome-Python-Scripts/Take_screenshot/screenshot.py

15 lines
387 B
Python
Raw Normal View History

2019-01-18 21:43:59 +00:00
#Needed packages
import numpy as np
import cv2
import pyautogui
#take screenshot using pyautogui
image = pyautogui.screenshot()
#since the pyautogui takes as a PIL(pillow) and in RGB we need to convert it to numpy array and BGR
#so we can write it to the disk
image = cv2.cvtColor(np.array(image),cv2.COLOR_RGB2BGR)
#writing it to the disk using opencv
cv2.imwrite("test.png",image)