-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchange_speed.py
30 lines (28 loc) · 1.07 KB
/
change_speed.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
import numpy as np
import cv2
import time
###########################################
####Global Parameter ####
G_VideoCapFrom0 = cv2.VideoCapture('rgb_zhuanpan.avi')
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output3.avi',fourcc,5.0, (720,1280))
###########################################
####Sub Function ####
def F_PlayVideoUntilPressQ():
while(G_VideoCapFrom0.isOpened()):
ret, frame = G_VideoCapFrom0.read()
if ret==True:
frame=cv2.flip(frame, 1, dst=None)
out.write(frame)
else:
#judge : can not load video or finished play
#either can cause error:error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
print("can not load video or finished play")
break
if cv2.waitKey(1) & 0xFF == ord('q'):
break
###########################################
####Main Function ####
F_PlayVideoUntilPressQ()
G_VideoCapFrom0.release()
cv2.destroyAllWindows()