-
Notifications
You must be signed in to change notification settings - Fork 0
/
123v8.py
60 lines (39 loc) · 1.01 KB
/
123v8.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# img = pyautogui.screenshot()
#cv2.imshow("screenshot", frame)
#!/usr/bin/env python
# coding: utf-8
# In[2]:
import cv2
import numpy as np
import pyautogui
import keyboard
# In[3]:
#print(pyautogui.size())
# In[4]:
SCREEN_SIZE = (1920, 1080)
fourcc = cv2.VideoWriter_fourcc(*"MJPG")
# change output name
out = cv2.VideoWriter("output.avi", fourcc, 20.0, (SCREEN_SIZE))
# In[6]:
while True:
# make a screenshot
img = pyautogui.screenshot()
# convert these pixels to a proper numpy array to work with OpenCV
frame = np.array(img)
# convert colors from BGR to RGB
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# write the frame
out.write(frame)
# show the frame
#cv2.imshow("screenshot", frame)
# if the user clicks q, it exits
#if cv2.waitKey(1) == ord("q"):
# break
#if (input.GetKeyDown(KeyCode.q)):
# break
if keyboard.is_pressed('q'):
break
# make sure everything is closed when exited
cv2.destroyAllWindows()
out.release()
# In[ ]: