-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreenCapture.py
More file actions
37 lines (32 loc) · 960 Bytes
/
screenCapture.py
File metadata and controls
37 lines (32 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import numpy as np
import cv2
import platform
from sys import argv
if platform.system() == 'Linux':
import pyscreenshot as ig
else:
from PIL import ImageGrab as ig
if len(argv) < 3 :
print("Not enough parameters..")
print("Usage : screenCapture.py width height")
exit()
try:
width = int(argv[1])
height = int(argv[2])
except ValueError:
print("Error : Please provide integer values...")
print("Usage : screenCapture.py width height")
exit()
print("Live screen capture begin, press q or Ctrl+C to quit")
while(True):
try:
screen = np.array(ig.grab(bbox=(0,0,width,height)))
cv2.imshow('live',cv2.cvtColor(screen,cv2.COLOR_BGR2RGB))
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
print("Exiting..")
break
except KeyboardInterrupt:
print("Exiting..")
cv2.destroyAllWindows()
break