mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
commit
e9325bf322
20
Take_screenshot/README.md
Normal file
20
Take_screenshot/README.md
Normal file
|
@ -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)
|
14
Take_screenshot/screenshot.py
Normal file
14
Take_screenshot/screenshot.py
Normal file
|
@ -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)
|
BIN
Take_screenshot/test.png
Normal file
BIN
Take_screenshot/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 272 KiB |
Loading…
Reference in New Issue
Block a user