-
Notifications
You must be signed in to change notification settings - Fork 0
/
Take_Video.py
45 lines (27 loc) · 1.04 KB
/
Take_Video.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
def Take_Video():
import numpy as np
import cv2
import time as tm
import speech_recognition as sr
from Speak_Text import SpeakText
time = str(tm.localtime().tm_mday) + '_' + str(tm.localtime().tm_hour)+'_'+str(tm.localtime().tm_min)+'.avi'
r = sr.Recognizer()
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(time,fourcc, 20.0, (640,480))
SpeakText('To prevent false trigger of a break function, in order to stop the program you need to press q in the keyboard!')
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
# write the flipped frame
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()