-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlive_feed_rotating.py
61 lines (39 loc) · 1.1 KB
/
live_feed_rotating.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
57
58
59
60
61
import cv2
import time
def main():
windowName = "Live Video Feed"
cv2.namedWindow(windowName)
cap = cv2.VideoCapture(0)
if cap.isOpened():
ret, frame = cap.read()
else:
ret = False
rows, columns, channels = frame.shape
angle = 360
scale = 0.1
# scale = 1
while True:
ret, frame = cap.read()
if angle == 360:
angle = 0
# angle = 0
scale=0.5
# if scale < 2:
# scale = scale + 0.1
# if scale >= 2:
# scale = 0.1
# print(scale)
R = cv2.getRotationMatrix2D((columns/2, rows/2), angle, scale)
angle-=1
print(R)
output = cv2.warpAffine(frame, R, (columns, rows))
cv2.imshow(windowName, output)
# angle = angle + 1
time.sleep(0.01)
if cv2.waitKey(1) == 27:
break
cv2.destroyWindow(windowName)
cv2.destroyAllWindows()
cap.release()
if __name__ == "__main__":
main()