forked from Shahrayar123/Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (23 loc) · 736 Bytes
/
Copy pathmain.py
File metadata and controls
30 lines (23 loc) · 736 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
import cv2
import numpy as np
import pyautogui
SCREEN_SIZE = tuple(pyautogui.size())
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('video.avi', fourcc, 20.0, (SCREEN_SIZE))
webcam = cv2.VideoCapture(0)
while True:
img = pyautogui.screenshot()
img = np.array(img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
_, frame = webcam.read()
fr_height, fr_width, _ = frame.shape
img[0:fr_height, 0: fr_width, :] = frame[0:fr_height, 0: fr_width, :]
cv2.imshow('frame', img)
out.write(img)
# Press 'q' to quit
if cv2.waitKey(1) & 0xFF == ord('q'):
print("Recording Stopped")
break
out.release()
cv2.destroyAllWindows()