Merge pull request #51 from moadmmh/master

Take a screenshot
This commit is contained in:
Ayush Bhardwaj 2019-01-24 16:19:36 +05:30 committed by GitHub
commit e9325bf322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

20
Take_screenshot/README.md Normal file
View 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)

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB