-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideoTest.py
42 lines (32 loc) · 992 Bytes
/
videoTest.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
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
w = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
h = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
print(str(w) + ", " + str(h))
# Define the codec and create VideoWriter object
# -----fourcc = cv2.VideoWriter_fourcc(*'XVID') # Videowriter_fourcc does not exist?!?!
# fourcc = cv2.cv.CV_FOURCC(*'XVID')
out = cv2.VideoWriter('output.avi', -1, 20.0, (1280,720))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:# boolean signifying a frame was captured
frame = cv2.flip(frame, 180)
# 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()
"""while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
"""