-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotation.py
More file actions
executable file
·57 lines (45 loc) · 1.52 KB
/
Copy pathRotation.py
File metadata and controls
executable file
·57 lines (45 loc) · 1.52 KB
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
import cv2
import numpy as np
#Rotation of the image
img = cv2.imread('img/butterfly.jpg')
num_rows, num_cols = img.shape[:2]
rotation_matrix = cv2.getRotationMatrix2D((num_cols/2,num_rows/2),30,1)
img_rotation = cv2.warpAffine(img, rotation_matrix,(num_cols,num_rows))
cv2.imshow('Rotation',img_rotation)
cv2.imwrite("img/img_rotation.jpg", img_rotation)
#rotation of the video
cap = cv2.VideoCapture(0)
#counter for the new windows
num = int(input("How many Windows do you want?: "))
ventanas = []
for i in range(num):
ventana_= f'Video {i}'
ventanas.append(ventana_)
while(cap.isOpened()):
ret, frame = cap.read()
if ret:
# video = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
video = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
video = cv2.warpAffine(frame, rotation_matrix,(num_cols,num_rows))
# video = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV)
# video = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# video = cv2.resize(video, (0, 0), fx=0.5, fy=0.5)
for ventana in ventanas:
cv2.imshow(ventana, video)
'''
Close the video with the following keys
Number ASII Key
113 q
81 Q
120 x
88 X
27 ESC
13 Enter
'''
key = cv2.waitKey(1) & 0xFF
if key == ord('q') or key == ord('Q') or key == ord('x') or key == ord('X') or key == 27 or key == 13:
break
else:
break
cap.release()
cv2.destroyAllWindows()