-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrescale.py
More file actions
38 lines (29 loc) · 985 Bytes
/
rescale.py
File metadata and controls
38 lines (29 loc) · 985 Bytes
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
import cv2 as cv
def rescaleFrame(frame, scale=0.75):
# Images, Videos and Live Video
width = int(frame.shape[1] * scale)
height = int(frame.shape[0] * scale)
dimensions = (width, height)
return cv.resize(frame, dimensions, interpolation=cv.INTER_AREA)
def changeRes(width, height):
# Live Video
capture.set(3,width)
capture.set(4,height)
#brightness, 10
capture = cv.VideoCapture('Videos/kelly.mp4')
img = cv.imread('Photos/Kitty.jpg')
rescaled_img = rescaleFrame(img, scale=0.25)
cv.imshow('Kitty larger image', img)
cv.imshow('Kitty', rescaled_img)
while True:
isTrue, frame = capture.read()
frame_resized = rescaleFrame(frame, 0.1)
#frame_resized = rescaleFrame(frame, scale=0.2)
cv.imshow('Video', frame)
cv.imshow('Video resized', frame_resized)
#see if 'd' key was pressed
if cv.waitKey(20) & 0xFF==ord('d'):
break
capture.release()
cv.destroyAllWindows()
#cv.destroyAllWindows() or remove it