diff --git a/Take_screenshot/README.md b/Take_screenshot/README.md new file mode 100644 index 0000000..92e67dc --- /dev/null +++ b/Take_screenshot/README.md @@ -0,0 +1,20 @@ +# Take a Screenshot : + +A simple implementation on how to take screenshots . + + #### Required Modules : + - Numpy + ```bash + pip install numpy + ``` + - Opencv + ```bash + pip install opencv-python + ``` + - Pyautogui + ```bash + pip3 install pyautogui --user + ``` + #### Results : + + ![alt text](https://github.com/moadmmh/Awesome-OpenCV/blob/master/Take_Screenshot/test.png) diff --git a/Take_screenshot/screenshot.py b/Take_screenshot/screenshot.py new file mode 100644 index 0000000..b189167 --- /dev/null +++ b/Take_screenshot/screenshot.py @@ -0,0 +1,14 @@ +#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) diff --git a/Take_screenshot/test.png b/Take_screenshot/test.png new file mode 100644 index 0000000..f77c769 Binary files /dev/null and b/Take_screenshot/test.png differ